2006
10.06

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
The following two tabs change content below.

charlie root

VP of keeping it real / HNIC at pissedoffadmins.com
I bring the cold coffee.

Latest posts by charlie root (see all)

No Comment.

Add Your Comment