slight spin on nagios file system check
here is a slight spin on the nagios disk check function – this is for when it is not critical for you to check free/used space on the fs but you still want to be alerted when something is wrong
works both in linux and solaris
#!/bin/bash TMP_FILE=/tmp/disk_usage.tmp.$$ df -h | tr -d '%' | awk '{ if (NR != 1 && $5 >= 95) print $0 }' >$TMP_FILE if [ -s $TMP_FILE ]; then cat $TMP_FILE | sort -rnk5 | head -1 rm -f $TMP_FILE exit 2 fi df -h | tr -d '%' | awk '{ if (NR != 1 && $5 >= 90) print $0 }' >$TMP_FILE if [ -s $TMP_FILE ]; then cat $TMP_FILE | sort -rnk5 | head -1 rm -f $TMP_FILE exit 1 fi rm -f $TMP_FILE echo OK exit 0
Leave a Reply