Monitoring your Network by Cory Rauch 2007-05-06 Category: Linux-System
If you have a bunch of Linux boxes or remotely manage Linux
boxes you may want to consider a monitoring solution. Monitoring
software can be a lifesaver, especially when you're not physically
near the computers in questions. It also provides for smoother
service operation by automatically restarting dead daemons
even before you may know of a problem. But at the same time
some of these software solutions have become quite complicated
and expensive to set up. Well in this article we are going
to cover a simple to set-up, cheap (free), and flexible monitoring
package called 'monit'.
The 'monit' Software Package
The 'monit' package is a daemon monitoring daemon (DMD),
written by Jan-Henrik Haukeland, that monitors service
daemons continuously to provide both status and daemon
restart capability. It also features email alerts, TCP/IP
tcp/udp port checking, Protocol verification (HTTP,
SMTP, FTP, POP, IMAP, NNTP), Daemon binaries verification
via MD5 checksums, and easy configuration.
Installation
Installation is simple: Download the tar-ball and uncompress
in a directory, 'cd' over to that directory, and type:
# ./configure; make
# make install
If all goes well it should have installed the 'monit'
software to your machine. Repeat for each machine until
done.
Next, We need to configure the monitoring done by 'monit'.
Configuration
Monit uses the configuration file '/root/.monitrc' to
monitor the local system. The file is pretty straight
forward, especially with an example to look at. Below
is a sample configuration file for monitoring Apache,
SSH, and NAMED.
Sample /root/.monitrc file:
#
# Sysbotz Sample monit configuration.
#
set daemon 300
set logfile /var/log/monit
check apache with pidfile /var/log/httpd/httpd.pid
start = "/root/apache-start"
stop = "/root/apache-stop"
checksum /usr/local/bin/httpd
timeout(3, 3) and alert me@company.com
host foo.com port 80 protocol http
host bar.org port 80 protocol http
check sshd with pidfile /var/run/sshd.pid
start = "/root/sshd-start"
stop = "/root/sshd-stop"
timeout(3, 3) and alert me@company.com
checksum /usr/local/sbin/sshd
check named with pidfile /var/run/named.pid
start = "/root/named-start"
stop = "/root/named-stop"
checksum /usr/local/sbin/named
timeout(3, 3) and alert me@company.com
port 53 use type udp
The first two lines set the time to poll (polling cycle)
each service and where to store the log file.
The next lines specify the services to check. All service
definitions follow the syntax: check
with pidfile [full path to PID file], then optionally
following with the start and stop commands to use.
Additional options include:
checksum
This enables the daemon binary verification using MD5
checksums to make sure the daemon binary has not changed
during it's running time.
timeout (, ) and alert
This enables the timeout and alert functions which works
by alerting the email address of service problem when
number of restarts in number of polling cycles occurs.
For example, 3 restarts in 3 polling cycles or 3 restarts
in 900 seconds (300 second polling cycle) would trigger
a email alert notification.
host port protocol
This tells monit to check the specified host/port/protocol
combo. An example of use could be to monitor a list
of virtual web-sites on a web server.
Conclusion
The 'monit' monitoring package provides a simple and
neat way of monitoring your services on your network.
Monit provides an extra level of protection from those
daemon deaths and helps you during the troubleshooting
phase too. For best coverage you may want to install
this on all your Linux servers providing important services.
Pushchange members can automatically install this package
across their Linux system by click the 'Pushchange Install'
link below.