file system status mail notifications

HI

I want to get an e-mail @ my yahoo address when the file system used space gets more than 89% ,
& the message contents must be the outputs of

df -g

errpt

netstat -i

???????

if [[ `df -h / | tail -1 | awk '{print $5}' | sed 's/%//'` -gt 89 ]] ; then mail my@yahooaddres -s "`hostname` -> \"Disk Space very low\"" </dev/null; fi
1 Like

In sh:

 
#!/bin/sh

#Check free space on the /
# - Change grep command to check others FS
OUT=$(df | grep -w '/' | awk '$5>89{print}')

# Keep the '.' after the '<<' AND just above the 'fi', that's where your email message ends
if [ -n "$OUT" ]; then
    mail -s 'Subject' your@address.com << .
$(df -h)
#Insert everything you want
.
fi;

exit 0
1 Like

UNIX Get An Alert When Disk Is Full

1 Like