Hi,
I have to regularly monitor manually if my diskspace is close to 90% or not. I use to see this by firing df -k. I want to write a script which can run 24*7 hours and would me mail me whenever the disk space is 90% or more..It would be really great if someone can helo me on this.
A primitive script. This will check if total disk space used is >= 90% once in every 10s and if so, an email will be sent. It'll run in an infinite loop until you kill it.
#! /bin/bash
while [ 1 ]
do
total=$(df -k --total | awk 'END{sub (/%$/,"",$5); print $5}')
if [ $total -ge 90 ]
echo "Message" | mailx -s "Alert Subject" user@email.com
fi
sleep 10
done