Script in Monitoring Your LINUX Server

You can use this as pattern in monitoring you server.

1. Create a file "system-check.sh" and paste the code below:
(this will monitor - apache, java, postfix, mail que, mysql and failed logins)

echo
echo "youserver.com.ph"
date
echo
vmstat 5 5|awk -F" " '{print $4" "$5" "$8" "$16}'
echo ---------------------------------
df -k
echo ---------------------------------
ps -eaf | grep httpd
echo ---------------------------------
ps -eaf | grep java
echo ---------------------------------
ps -eaf | grep postfix
echo ---------------------------------
ps -eaf | grep -c smtp
echo ---------------------------------
ps -eaf | grep mysql
echo ---------------------------------
lastb | head

_______________
Note:
you can add a service check by changing syntax below:

ps -eaf | grep <service>
e.g. ps -eaf | grep named

Checking logs:
tail /usr/local/apache/logs/error_log

2. Create a file "system-check.cron" and insert the code below:

#! /bin/sh

a=`eval date +%m'/'%d'/'%Y`

clear
echo
nice system-check.sh > result.txt

mail -s SERVERNAME-$a youremail@com.ph < result.txt

3. Add this in the crontab, this will initiate routine check every 6am, 2pm, and 10pm, and sends you an and email result.

0 6,14,22 * * * /root/scripts/routines.cron > /dev/null 2>&1

Comments

  1. Thanks for making monitoring the server so simple. Thank you for great tips.

    ReplyDelete

Post a Comment

Popular posts from this blog

Radiator Radius Installation connecting to ORACLE (CentOS)

Scraping an Entire Website using LINUX

How to enable clustering in Openfire Enterprise?