Hello, This script gives me a strange error after the mount was done on this server. (pasting the error at the bottom)
DATE=`date '+%Y%m%d'`
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 70 ]
then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" >/tmp/dfh.txt
df -H >> /tmp/dfh.txt
mail -s "$(hostname) -:- Alert: Level 1. Almost out of disk space $usep%"
aabb@ld.com < /tmp/dfh.txt
elif [ $usep -ge 80 ]
then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" >/tmp/dfh.txt
df -H >> /tmp/dfh.txt
mail -s "$(hostname) -:- Alert: Level 2. Almost out of disk space $usep%"
abc@se.com < /tmp/dfh.txt
elif [ $usep -ge 90 ]
then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" >/tmp/dfh.txt
df -H >> /tmp/dfh.txt
mail -s "$(hostname) -:- Alert: Level 3. Disk Space critical - Almost out of disk space $usep%"
abc@kk.com < /tmp/dfh.txt
fi
done
ERROR -
/memory_status_alert.sh: line 10: [: -ge: unary operator expected
./memory_status_alert.sh: line 15: [: -ge: unary operator expected
./memory_status_alert.sh: line 20: [: -ge: unary operator expected
/dataman/proddb_bkp
./memory_status_alert.sh: line 10: [: /ataman/db_bkp: integer expression expected
./memory_status_alert.sh: line 15: [: /ataman/db_bkp: integer expression expected
./memory_status_alert.sh: line 20: [: /ataman/db_bkp: integer expression expected
./memory_status_alert.sh: line 10: [: -ge: unary operator expected
./memory_status_alert.sh: line 15: [: -ge: unary operator expected
./memory_status_alert.sh: line 20: [: -ge: unary operator expected
/dataman/prodapp_bkp
./memory_status_alert.sh: line 10: [: /ataman/app_bkp: integer expression expected
./memory_status_alert.sh: line 15: [: /ataman/app_bkp: integer expression expected
./memory_status_alert.sh: line 20: [: /ataman/app_bkp: integer expression expected
IF df -h is run independantly this is what i get -
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 29G 11G 17G 38% /
/dev/sda6 84G 70G 11G 88% /opt
/dev/sda2 29G 8.7G 19G 33% /home
/dev/sda1 190M 19M 162M 11% /boot
tmpfs 1.7G 0 1.7G 0% /dev/shm
192.168.2.7:/DataVolume/proddb_bkp
915G 433G 482G 48% /atamandb_bkp
192.168.2.7:/DataVolume/prodapp_bkp
915G 433G 482G 48% /ataman/app_bkp
Cant get the problem!! please help!