Recent Changes - Search:

Softwares

.

Load-alert-bash-script-for-linux-servers

Main.Load-alert-bash-script-for-linux-servers History

Hide minor edits - Show changes to output

January 14, 2013, at 01:18 AM by 15.211.153.75 -
Changed lines 2-3 from:
(:Googlemm:)
to:
(:Googletxt:)
----
Changed lines 75-77 from:
(:Googlemmm:)
to:
----

(:Googlemm:)
Changed line 1 from:
(Google1:)
to:
(:Google1:)
Added lines 1-3:
(Google1:)
(:Googlemm:)
Deleted lines 11-12:
(:Googlemm:)
Changed lines 72-74 from:
/var/log/exim_mainlog if running exim.
to:
/var/log/exim_mainlog if running exim.

(:Googlemmm:)
Changed lines 9-10 from:
to:
(:Googlemm:)
August 26, 2007, at 03:44 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 07, 2007, at 10:21 AM by 117.97.18.220 -
Added lines 5-6:
* File for the script vi /root/loadalert
Changed lines 9-10 from:
* vi /root/loadalert
to:
Added lines 49-51:

August 07, 2007, at 10:20 AM by 117.97.18.220 -
Changed lines 7-8 from:
to:
* vi /root/loadalert
Changed lines 47-51 from:

*%blue% Now add Cron in /var/spool/cron

* * * * * /root/loadalert >/dev/null 2>&1
to:
* Give exec permission

chmod +x /root/loadalert

*%blue% Now add below in roots cron file /var/spool/cron/root

* * * * * /root/loadalert
>/dev/null 2>&1


*Restart crond

/etc/init.d/crond restart

*Check log for errors:

/var/log/cron

*Check Mail log

/var/log/exim_mainlog if running exim.
June 20, 2007, at 11:43 AM by 121.247.152.42 -
Added lines 1-50:
*Load alert bash script for Linux Servers

%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



*%blue% Now add Cron in /var/spool/cron

* * * * * /root/loadalert >/dev/null 2>&1
Edit - History - Print - Recent Changes - Search
Page last modified on January 14, 2013, at 01:18 AM