How to monitor an Apache web server using Monit
Monit
is a tool that can monitor your Apache web server,
MySQL database, or other daemon process. It can restart
the service based on configurable conditions such as
CPU usage, memory usage, number of children, etc. It can log status to a file,
email status, and it has a web interface for monitoring or
restarting the service. Here are the steps I took to install and configure
the Monit tool on Ubuntu Hardy. It merely monitors the
status of my Apache web server and restarts it if it stops. It also
checks if the memory used by Apache is greater than 1 MB and logs
it in /var/log/monit.log.
For more configuration options, see the examples in the default
/etc/monit/monitrc file or the
configuration examples in the monit documentation. I also
found
Ubuntu Geek's guide to be very helpful.
- Install monit
$ sudo apt-get install monit
- Edit the config file
$ sudo nano /etc/monit/monitrc
Insert the following:# check services every 2 minutes set daemon 120 # logging set logfile /var/log/monit.log # web interface set httpd port 2812 and use address localhost # only accept connection from localhost allow localhost # allow localhost to connect to the server allow admin:monit # require user ‘admin’ with password ‘monit’ # monitor apache check process apache2 with pidfile /var/run/apache2.pid start program = "/etc/init.d/apache2 start" if totalmem > 1.0 MB for 2 cycles then alert - Check the file syntax
$ sudo monit -t
- Enable the service
$ sudo nano /etc/default/monit
Change the following line:startup=1
- Start monit
$ sudo /etc/init.d/monit start
- Point your browser at http://localhost:2812 and log in using the user "admin" and the password "monit".
- Click on "apache2" and you can see information about the Apache process.
Post a comment
About
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »
Search Blog
Tags
-
algorithms
(4)
-
aws
(8)
-
blogproject
(20)
-
c_cplusplus
(12)
-
cardstore
(8)
-
colinux
(2)
-
concurrency
(9)
-
conkeror
(2)
-
cygwin
(18)
-
datastructures
(15)
-
datetime
(3)
-
dell
(3)
-
django
(39)
-
emacs
(20)
-
files_directories
(10)
-
install_setup
(7)
-
javascript
(3)
-
keyboard
(6)
-
matplotlib
(5)
-
mercurial
(4)
-
nginx
(2)
-
preferences
(8)
-
processes
(3)
-
pyqt
(18)
-
python
(122)
-
ratpoison
(3)
-
regexes
(5)
-
rsync
(3)
-
softwaretools
(17)
-
sql
(13)
-
ssh
(7)
-
subversion
(6)
-
twisted
(6)
-
ubuntu
(60)
-
urxvt
(5)
-
vxworks
(25)
-
webservices
(4)
-
wmii
(7)
Blogroll
- Adam Gomaa
- Alex Clemesha
- Amir Salihefendic
- Armin Ronacher
- David Beazley
- David Ziegler
- Duncan McGreggor
- Gareth Rushgrave
- Glyph Lefkowitz
- Guido van Rossum
- Ian Bicking
- Jacob Kaplan-Moss
- James Bennett
- James Tauber
- Jesper Noehr
- Matt Harrison
- Nikolay Kolev
- Parand Darugar
- Peter Baumgartner
- Peter Bengtsson
- Rob Hudson
- Simon Willison
- Will McGugan