forked from fiumadlab/madlab_env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.nodeload
executable file
·26 lines (22 loc) · 850 Bytes
/
.nodeload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
nodeload=`cat /proc/loadavg | awk '{print $1}'`
nodeloadint=`echo ${nodeload} | awk -F . '{print $1}'`
numcpus=`cat /proc/cpuinfo | grep -c processor`
nodemem=`free | grep Mem`
nodememtotal=`echo ${nodemem} | awk '{print $2}'`
nodememused=$((`echo ${nodemem} | awk '{print $3}'`))
nodemem=$((99*${nodememused}/${nodememtotal}))
if [ $nodeloadint -ge $((100*${numcpus}/5*4/100)) ]; then
echo -en "\[\e[1;31m\][$nodeload]\[\e[0m\]"
elif [ $nodeloadint -ge $((100*${numcpus}/2*1/100)) ]; then
echo -en "\[\e[1;33m\][$nodeload]\[\e[0m\]"
else
echo -en "\[\e[1;32m\][$nodeload]\[\e[0m\]"
fi
if [ $nodemem -ge 80 ]; then
echo -en "\[\e[1;31m\][$nodemem%]\[\e[0m\]"
elif [ $nodemem -ge 50 ]; then
echo -en "\[\e[1;33m\][$nodemem%]\[\e[0m\]"
else
echo -en "\[\e[1;32m\][$nodemem%]\[\e[0m\]"
fi