unclebyron
MIS
We want to monitor a Linux server for hard drive failure, free space running out etc. and have it send email warnings to our I.T. group. What would be the best program or method to use for this? Thank you.....
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/bin/bash
# This script determines the percentage of disk usage.
# If that percentage is greater than 90% a user is emailed
# a report notifying them of the usage.
#
# Copyright 2006 Daniel McCarthy
# BE SURE TO CHANGE THIS TO YOUR EMAIL ADDRESS ;)
emailUser="email.address@local.com"
typeset -i error="90"
if [ -e temp.txt ]; then
rm temp.txt
fi
for disc in `mount| egrep '^/dev' | egrep -iv 'cdrom|proc|sys|pts' |awk '{print $3}'`
do
typeset -i discUsage=`df -h $disc|cut -c40-42|grep -i [^a-z]`
if [ "$discUsage" -ge "$error" ]; then
echo "Disc usage for $disc is at $discUsage%" >> temp.txt
fi
done
if [ -e temp.txt ]; then
message=`cat temp.txt`
fi
if [ ${#message} -gt 0 ]; then
cat temp.txt | mail -s "Disc Usage Report for: $HOSTNAME" $emailUser
fi