Recent Changes - Search:

Softwares

.

AdvancedServerLoadAlertScriptWithProcessStatus

Main.AdvancedServerLoadAlertScriptWithProcessStatus History

Hide minor edits - Show changes to output

August 26, 2007, at 07:45 PM by 125.21.38.36 -
Changed lines 44-45 from:
mail -s "$SUBJECT" "$EMAIL" < $TEMPFILE
mail -s "$SUBJECT" "$EMAIL1" < $TEMPFILE
to:
mail -s "$SUBJECT $L05" "$EMAIL" < $TEMPFILE
mail -s "$SUBJECT $L05" "$EMAIL1" < $TEMPFILE
August 26, 2007, at 06:55 PM by 125.21.38.36 -
Added lines 3-7:

*Create a file with the script below

vi /root/loadalert
April 19, 2007, at 04:46 AM by 61.17.224.18 -
Added lines 43-48:



*%blue% Now add Cron.

* * * * * /root/loadalert >/dev/null 2>&1
Added lines 1-42:
%red%Advanced Server Load Alert Script With Process Status.

%blue%Get the process status report through e-mail for server load, you can try to add additional info to the code, to get more info through e-mail.


#!/bin/bash
#Wednesday, December 06 2006
EMAIL="your email 1"
EMAIL1="your email 2"
SUBJECT="Alert $(hostname) load average is $L05"
TEMPFILE="/tmp/$(hostname)"
echo "Load average Crossed allowed limit." >> $TEMPFILE
echo "Hostname: $(hostname)" >> $TEMPFILE
echo "Local Date & Time : $(date)" >> $TEMPFILE
echo "| Uptime status: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/usr/bin/uptime >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Top 20 CPU consuming processes: |" >> $TEMPFILE
ps aux | head -1 >> $TEMPFILE
ps aux --no-headers | sort -rn +2 | head -20 >> $TEMPFILE
echo "| Top 10 memory-consuming processes: |" >> $TEMPFILE
ps aux --no-headers| sort -rn +3 | head >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Memory and Swap status: |" >> $TEMPFILE
/usr/bin/free -m >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Active network connection: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/bin/netstat -tnup | grep ESTA >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Disk Space information: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/bin/df -h >> $TEMPFILE
echo "-----------------THE END-------------------" >> $TEMPFILE
L05="$(uptime|awk '{print $(NF-2)}'|cut -d. -f1)"
if test $L05 -gt 5
then
mail -s "$SUBJECT" "$EMAIL" < $TEMPFILE
mail -s "$SUBJECT" "$EMAIL1" < $TEMPFILE
fi
rm -f $TEMPFILE
Edit - History - Print - Recent Changes - Search
Page last modified on August 26, 2007, at 07:45 PM