From 739cb3ebd4e9d2a24ceb74017ca79da1d192f6e2 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 19 Mar 2013 12:45:35 +0530 Subject: [PATCH] Check HDD Space & Email --- scripts/hddspace.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/hddspace.sh diff --git a/scripts/hddspace.sh b/scripts/hddspace.sh new file mode 100644 index 00000000..aa14ee5a --- /dev/null +++ b/scripts/hddspace.sh @@ -0,0 +1,25 @@ +#!/bin/bash + + + +USEDSPACE=$(df -h | awk '{print $5}' | grep -vi use | cut -d'%' -f1) +for i in $USEDSPACE +do + if [ $i -gt 90 ] + then + (df -h | head -n1; df -h | grep $i; \ + echo; echo "Total Disk Space Used By /tmp = $(du -sh /tmp | awk '{print$1}')") \ + | mail -s "HDD Space Warning For $(hostname)" Mitesh.Shah@rtcamp.com + + elif [ $i -gt 85 ] + then + (df -h | head -n1; df -h | grep $i) \ + | mail -s "HDD Space Warning For $(hostname)" Mitesh.Shah@rtcamp.com + + elif [ $i -gt 80 ] + then + (df -h | head -n1; df -h | grep $i) \ + | mail -s "HDD Space Warning For $(hostname)" Mitesh.Shah@rtcamp.com + + fi +done