🔔 🔔 🔔 Duyuru: 24. Yılımıza özel indirimler sizleri bekliyor ! Kampanya Kodu : TDATA2024 | Detaylı bilgi için tıklayınız.

Server load alerts shell script


Server load alerts shell script


Simple Server load alerts shell script to monitor your server load average, Free Memory and Swap status, Disk space information. etc., Please make sure this script will not cause extra load average on your cpanel server. This shell script will send alert to your email account when the server load goes more than 10.

 

 

cd /root

vi loadalert

EMAIL="your email"
SUBJECT="Alert $(hostname) load average is $L05"
TEMPFILE="/tmp/$(hostname)"
TOPLOAD="10"
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 $TOPLOAD
then
mail -s "$SUBJECT  $L05" "$EMAIL" < $TEMPFILE
fi
rm -f $TEMPFILE

chmod 755 loadalert

Updated this script on your cronjob

echo “*/5 * * * * /root/loadalert >/dev/null 2>&1″ >> /var/spool/cron/root

Restart cron service

/etc/init.d/crond restart

 

Bu cevap yeterince yardımcı oldu mu?

Diğer Dökümanlar


  • cPanel security settings checklist

    You always use cpanel recommended Security Settings to avoid hacking and other suspicious activity. These  cPanel Server Hardening & Security tips will help prevent from hacking. cPanel...

  • cPanel security settings checklist

    You always use cpanel recommended Security Settings to avoid hacking and other suspicious activity. These  cPanel Server Hardening & Security tips will help prevent from hacking. cPanel...

  • sendmail Not running with correct effective GID

    Wed Sep 04 04:11:11 2014] [error] [client 11.44.33.22] sendmail: Not running with correct effective GID.  Is sendmail binary setgid mailtrap?, It may be the problem with your sendmail binary...

  • How to enable NAT behind the cpanel ?

    Most of webhosting providers currently used NAT service for their users. When you install cPanel & WHM, the installer will detect whether your server is on a NAT-configured network. If the...

  • Unable to allocate memory for pool

    Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0 APC or Alternative PHP Cache (APC) is a free and open opcode cache for PHP. APC allows for caching of opcode generated...