#!/bin/sh
# Shell script to monitor the disk space,Memory,SWAP Usage and send an email to $ADMIN, if the free avilable percentage of space is >= $ALERT
ADMIN="hareeshvv@gmail.com"
ADMIN1="admin1@mycompany.com"
ADMIN2="admin2@mycompany.com"
# Alert Level Percentage of Disk Usage . Default is 90%
ALERT=90
df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
used=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
mountpoint=`mount | grep $partition | cut -f3 -d" "`
if [ $used -ge $ALERT ]; then
echo "Running out of space \"$partition ($used%) mounted on $mountpoint\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $used" -c $ADMIN1,$ADMIN2 $ADMIN
fi
done
# Alert on RAM and SWAP Usage
MEM=`free -m | grep Mem | awk -F" " {'print $2'}`
USEDMEM=`free -m | grep Mem | awk -F" " {'print $3'}`
SWAP=`free -m | grep Swap | awk -F" " {'print $2'}`
USEDSWAP=`free -m | grep Swap | awk -F" " {'print $3'}`
echo "Total Memory - $MEM" > /tmp/memorystatus
echo "Used - $USEDMEM" >> /tmp/memorystatus
echo "Total Swap - $SWAP" >> /tmp/memorystatus
echo "Used Swap - $USEDSWAP" >> /tmp/memorystatus
echo "on $(hostname) as on $(date)" >> /tmp/memorystatus
mail -s "Memeory Usage" -c $ADMIN1,$ADMIN2 $ADMIN < /tmp/memorystatus
Saturday, November 3, 2007
Subscribe to:
Post Comments (Atom)
AT&T USA | Internet not working | Fix by custom APN
If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...
-
Hi there, You all know how to check TCP port connectivity from a Linux or UNIX machine to a remote machine using telnet as per th exampl...
-
Before you start Ensure that you have installed wvdial, usbmodeswitch and usbmodeswitch_data # dpkg -l | grep wvdial # dpkg -l | grep ...
-
1. Open Applications -> System -> Configuration Editor from the GUI OR Open a terminal, type gconf-editor 2. Go to "...
No comments:
Post a Comment