2006
11.17
#!/bin/bash

TMP_FILE=/tmp/disk_usage.tmp.$$

df -h | grep '%' | grep -v "/cdrom/" | tr -d '%' | awk '{
   if (NR != 1) {
      if (NF == 6 && $5 >= 95)
         print $2,$3,$4,$5"%",$6;
      else if (NF == 5 && $4 >= 95)
         print $1,$2,$3,$4"%",$5;
   }
}' >$TMP_FILE

if [ -s $TMP_FILE ]; then
   cat $TMP_FILE | sort -rnk4 | head -1
   rm -f $TMP_FILE
   exit 2
fi

df -h | grep '%' | grep -v "/cdrom/" | tr -d '%' | awk '{
   if (NR != 1) {
      if (NF == 6 && $5 >= 90)
         print $2,$3,$4,$5"%",$6;
      else if (NF == 5 && $4 >= 90)
         print $1,$2,$3,$4"%",$5;
   }
}' >$TMP_FILE

if [ -s $TMP_FILE ]; then
   cat $TMP_FILE | sort -rnk4 | 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