nagios ram check for solaris and linux
these scripts work when checking nagios services over ssh (check_by_ssh)
linux:
#!/bin/bash TMP_FILE1=/tmp/ram.free.tmp1.$$ top -b -n1 |head -4 |tail -1 | awk '{free = $4 / $2 * 100; if (free >= 90.0) print $0 }' >$TMP_FILE1 if [ -s $TMP_FILE1 ]; then cat $TMP_FILE1 rm -f $TMP_FILE1 exit 1 fi
solaris:
#!/bin/bash TMP_FILE1=/tmp/ram_free.tmp1.$$ TMP_FILE2=/tmp/ram_free.tmp2.$$ top -b -n 1 | head -4 | tail -1 >$TMP_FILE1 tr -d 'M' <$TMP_FILE1 | awk '{ used = 100 - ($4 / $2 * 100); if (used >= 80.0) print $0 }' >$TMP_FILE2 if [ -s $TMP_FILE2 ]; then cat $TMP_FILE1 rm -f $TMP_FILE1 $TMP_FILE2 exit 1 fi rm -f $TMP_FILE1 $TMP_FILE2
Leave a Reply