Troubleshoot - by Hostrare
Simple Server capacity alerts shell script to monitor your server load center, Free Memory and Swap status, Disk space data. etc., Please make sure this book will not cause an additional load standard on your Cpanel server. This shell script will send an alert to your email account when the server capacity 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." >> $TEMPFILEecho "Hostname: $(hostname)" >> $TEMPFILEecho "Local Date & Time : $(date)" >> $TEMPFILEecho "| Uptime status: |" >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILE/usr/bin/uptime >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILEecho "| Top 20 CPU consuming processes: |" >> $TEMPFILEps aux | head -1 >> $TEMPFILEps aux --no-headers | sort -rn +2 | head -20 >> $TEMPFILEecho "| Top 10 memory-consuming processes: |" >> $TEMPFILEps aux --no-headers| sort -rn +3 | head >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILEecho "| Memory and Swap status: |" >> $TEMPFILE/usr/bin/free -m >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILEecho "| Active network connection: |" >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILE/bin/netstat -tnup | grep ESTA >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILEecho "| Disk Space information: |" >> $TEMPFILEecho "-------------------------------------------" >> $TEMPFILE/bin/df -h >> $TEMPFILEecho "-----------------THE END-------------------" >> $TEMPFILEL05="$(uptime|awk '{print $(NF-2)}'|cut -d. -f1)"if test $L05 -gt $TOPLOADthenmail -s "$SUBJECT $L05" "$EMAIL" < $TEMPFILEfirm -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
our suuport team here for you 24/7
+8801977507015support@hostrare.comsend a leter Whether you are looking for a personal website hosting plan or a business website hosting plan, We are the perfect solution for you. Our powerful website hosting services will not only help you achieve your overall website goals, but will also provide you with the confidence you need in knowing that you are partnered with a reliable and secure website hosting platform.