Linux sunucularınızda belli bir load seviyesine ulaştığında size mail atarak ram, disk ve servis dökümü yollar. Buradaki amaç sunucu kilitlenmeden önceki haraketi yakalamak.
############### BASLANGIC ###############
#!/bin/bash
# rm -f loadmonitor.sh;touch loadmonitor.sh;chmod u+x loadmonitor.sh;nano loadmonitor.sh
# ./loadmonitor.sh
CUR_TIME=`date +"%A %b %e %r"`
HOSTNAME=`hostname`
freeM=`free -m`
uptime=`uptime`
df=`df -h`
Load_AVG=`uptime | cut -d'l' -f2 | awk '{print $3}' | cut -d. -f1`
LOAD_CUR=`uptime | cut -d'l' -f2 | awk '{print $3 " " $4 " " $5}' | sed 's/,//'`
#Set the following value according to your requirement.
LIMIT=15
if [ "$Load_AVG" -gt "$LIMIT" ]
then
/bin/ps auxf >> /root/process_out
echo "$CUR_TIME" $'\n' >> /tmp/load.txt
echo "$uptime" $'\n' >> /tmp/load.txt
echo "$freeM" $'\n' >> /tmp/load.txt
echo "$df" $'\n' >> /tmp/load.txt
echo "Ana Sunucu > Yuklenme limiti 15 olarak ayarlanmistir" >> /tmp/load.txt
/usr/bin/mutt -s "UYARI!!! 1DK boyunca yuksek load '$HOSTNAME'" -a /root/process_out -c xxx@xxx.com < /tmp/load.txt
fi
/bin/rm -f /tmp/load.txt
/bin/rm -f /root/process_out
############### BITIS ###############
#* * * * * /bin/sh /root/loadmonitor.sh
