diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-04-16 10:30:15 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-04-16 10:30:15 +0200 |
commit | 55783753ae8f2d857a7225b7a93c1d47039e5a90 (patch) | |
tree | e077b61b0f004141712e7d16876f9c19175ac681 /remote/osx/check_server_status.sh | |
download | conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.gz conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.bz2 conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.xz conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.zip |
OpenShift monitoring
Diffstat (limited to 'remote/osx/check_server_status.sh')
-rwxr-xr-x | remote/osx/check_server_status.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/remote/osx/check_server_status.sh b/remote/osx/check_server_status.sh new file mode 100755 index 0000000..ec7c0f2 --- /dev/null +++ b/remote/osx/check_server_status.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +root=`df -m | grep /dev/disk3s2 | sed -E 's/[[:space:]]+/ /g' | cut -d ' ' -f 4` +fs=`df -m | grep /dev/disk2 | sed -E 's/[[:space:]]+/ /g' | cut -d ' ' -f 4` +cpu=`uptime | sed -E "s/[[:space:]]+/ /g" | tr ' ' '\n' | tail -n 1` +mem=`top -l 1 | grep PhysMem | sed -E "s/[[:space:]]+/ /g"` + +cache=`echo $mem | cut -f 6 -d ' '` +free=`echo $mem | cut -f 10 -d ' '` + +len=`echo $cache | wc -c` +len=`expr $len - 1` +units=`echo $cache | cut -c $len` +len=`expr $len - 1` +size=`echo $cache | cut -c -$len` + +if [ $units == "G" ]; then + size=`expr $size '*' 1024` +elif [ $units != "M" ]; then + size=0 +fi + +len=`echo $free | wc -c` +len=`expr $len - 1` +units=`echo $free | cut -c $len` +len=`expr $len - 1` +fsize=`echo $free | cut -c -$len` +if [ $units == "G" ]; then + size=`expr $fsize '*' 1024 + $size` +elif [ $units == "M" ]; then + size=`expr $fsize + $size` +fi + +mem=$size + +if [ $root -le 8192 ]; then + echo "Only $(($root / 1024)) GB left in the root file system" +fi + +if [ $fs -le 102400 ]; then + echo "Only $(($fs / 1024)) GB left in the PDV file system" +fi + +if [ $mem -le 512 ]; then + echo "The system is starving on memory, $mem MB left free" +fi + +if [ `echo "$cpu < 7.80" | bc` -eq 0 ]; then + echo "The system is starving on cpu, $cpu is load average for the last 15 min" +fi |