Monit is a very simple tool for monitoring daemons or processes in linux.
#First of all, install the monit using apt-get:
#Edit the configuration file:
Process 'test_daemon'
status Running
monitoring status Monitored
pid 31233
parent pid 1
uptime 6m
children 0
memory kilobytes 6700
memory kilobytes total 6700
memory percent 0.6%
memory percent total 0.6%
cpu percent 0.0%
cpu percent total 0.0%
data collected Thu, 12 Nov 2015 06:59:23
System 'system_yourhost'
status Running
monitoring status Monitored
load average [0.00] [0.01] [0.05]
cpu 0.5%us 0.2%sy 0.1%wa
memory usage 311036 kB [2.2%]
swap usage 0 kB [0.0%]
data collected Thu, 12 Nov 2015 06:59:23
#First of all, install the monit using apt-get:
user@yourhost:~# apt-get install monit
#Edit the configuration file:
user@yourhost:~# nano /etc/monit/monitrc
#####
#add to the end of file the following:
set httpd port 2812 and
use address localhost
allow localhost
check process test_daemon with pidfile /var/test_daemon.pid
start program = "/etc/init.d/test_daemon start" with timeout 60 seconds
stop program = "/etc/init.d/test_daemon stop"
#to check the monit status, type:user@yourhost:~# monit status
The Monit daemon 5.4 uptime: 4mProcess 'test_daemon'
status Running
monitoring status Monitored
pid 31233
parent pid 1
uptime 6m
children 0
memory kilobytes 6700
memory kilobytes total 6700
memory percent 0.6%
memory percent total 0.6%
cpu percent 0.0%
cpu percent total 0.0%
data collected Thu, 12 Nov 2015 06:59:23
System 'system_yourhost'
status Running
monitoring status Monitored
load average [0.00] [0.01] [0.05]
cpu 0.5%us 0.2%sy 0.1%wa
memory usage 311036 kB [2.2%]
swap usage 0 kB [0.0%]
data collected Thu, 12 Nov 2015 06:59:23
Monit is configured. Daemon is monitored. That's all!