summaryrefslogtreecommitdiffstats
path: root/roles/ands_monitor/templates/scripts
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-04-16 10:52:27 +0200
committerSuren A. Chilingaryan <csa@suren.me>2018-04-16 10:52:27 +0200
commit3155c744b3924e68213e542b9a22d858bb64cf83 (patch)
tree097457f18cbcda0008d01c865255e92c1a3911a7 /roles/ands_monitor/templates/scripts
parentabea46eb8a3e05f6010247b526b5364ec312f2dc (diff)
downloadands-3155c744b3924e68213e542b9a22d858bb64cf83.tar.gz
ands-3155c744b3924e68213e542b9a22d858bb64cf83.tar.bz2
ands-3155c744b3924e68213e542b9a22d858bb64cf83.tar.xz
ands-3155c744b3924e68213e542b9a22d858bb64cf83.zip
Provision monitoring scripts on request
Diffstat (limited to 'roles/ands_monitor/templates/scripts')
-rwxr-xr-xroles/ands_monitor/templates/scripts/check_server_status.sh.j234
-rwxr-xr-xroles/ands_monitor/templates/scripts/check_uptime_status.sh.j28
2 files changed, 42 insertions, 0 deletions
diff --git a/roles/ands_monitor/templates/scripts/check_server_status.sh.j2 b/roles/ands_monitor/templates/scripts/check_server_status.sh.j2
new file mode 100755
index 0000000..caa63ce
--- /dev/null
+++ b/roles/ands_monitor/templates/scripts/check_server_status.sh.j2
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+fs=`df -lm / | grep -vi Filesystem | sed -e 's/[[:space:]]\+/ /g' | cut -d ' ' -f 4`
+datafs=`df -lm /mnt/ands | grep -vi Filesystem | sed -e 's/[[:space:]]\+/ /g' | cut -d ' ' -f 4`
+mem=`free -g | grep "Mem" | sed -e 's/[[:space:]]\+/ /g' | cut -d ' ' -f 7`
+cpu=`uptime | sed -e "s/[[:space:]]/\n/g" | tail -n 1`
+
+if [ $fs -le 8192 ]; then
+ echo "Only $(($fs / 1024)) GB left in the root file system"
+fi
+
+if [ $datafs -le 1048576 ]; then
+ echo "Only $(($datafs / 1024)) GB left in the data file system"
+fi
+
+if [ $mem -le 16 ]; then
+ echo "The system is starving on memory, $mem GB left free"
+fi
+
+if [ `echo "$cpu < 20" | bc` -eq 0 ]; then
+ echo "The system is starving on cpu, $cpu is load average for the last 15 min"
+fi
+
+vol=$(/opt/MegaRAID/storcli/storcli64 /c0/v0 show | grep -P "^0/0" | grep "Optl" | wc -l)
+if [ -z "$vol" -o "$vol" -eq 0 ]; then
+ echo "Raid volume is not optimal:"
+ /opt/MegaRAID/storcli/storcli64 /c0/v0 show | grep -P "^0/0"
+fi
+
+disks=$(/opt/MegaRAID/storcli/storcli64 /c0 show | grep -P "(HDD|SSD)" | grep -v "Onln" | wc -l)
+if [ -z "$disks" -o "$disks" -ne 0 ]; then
+ echo "Not all disks are online:"
+ /opt/MegaRAID/storcli/storcli64 /c0 show | grep -P "(HDD|SSD)" | grep -v "Onln"
+fi
diff --git a/roles/ands_monitor/templates/scripts/check_uptime_status.sh.j2 b/roles/ands_monitor/templates/scripts/check_uptime_status.sh.j2
new file mode 100755
index 0000000..0602fcb
--- /dev/null
+++ b/roles/ands_monitor/templates/scripts/check_uptime_status.sh.j2
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+up=$(uptime | cut -d ' ' -f 4- | cut -d ',' -f 1 | sed -re 's/^\s*//')
+load=$(uptime | cut -d ' ' -f 4- | cut -d ',' -f 4- | cut -d ':' -f 2 | cut -d ',' -f 3 | sed -re 's/^\s*//')
+disks=$(/opt/MegaRAID/storcli/storcli64 /c0 show | grep -P "(HDD|SSD)" | grep "Onln" | wc -l)
+data=`df -lh /mnt/ands | grep -vi Filesystem | sed -e 's/[[:space:]]\+/ /g' | cut -d ' ' -f 4`
+
+echo -n "1 Up $up \${color gray}/ $disks disks, $data free, load: $load"