#1  
Old 6th October 2008, 11:47
Hans Hans is offline
Moderator
 
Join Date: Dec 2005
Location: Montfoort, The Netherlands
Posts: 2,256
Thanks: 212
Thanked 648 Times in 294 Posts
Send a message via Skype™ to Hans
Default Monit on Debian

Monit checks the availability of services on your server and takes the appropriate action such as a restart if it finds a service is not behaving as expected.
If you add/replace the following configuration to your /etc/monit/monitrc file, you can almost monitor any service on your Debian Etch server :

Code:
# Apache2
check process apache with pidfile /var/run/apache2.pid
   group www
   start program = "/etc/init.d/apache2 start"
   stop program  = "/etc/init.d/apache2 stop"
   if failed host monitor.example.com port 80 protocol http
      and request "/monit/token" then restart
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 80% for 5 cycles then restart
   if totalmem > 700 MB for 5 cycles then restart
   if children > 500 then restart
   if loadavg(5min) greater than 10 for 8 cycles then stop
   if 3 restarts within 5 cycles then timeout

# Courier_authdaemon
check process authdaemon with pidfile /var/run/courier/authdaemon/pid
   group services
   start program = "/etc/init.d/courier-authdaemon start"
   stop  program = "/etc/init.d/courier-authdaemon stop"
   if 5 restarts within 5 cycles then timeout

# Bind
check process bind9 with pidfile /var/lib/named/var/run/bind/run/named.pid
   group bind
   start program = "/etc/init.d/bind9 start"
   stop  program = "/etc/init.d/bind9 stop"
   if failed port 53 then restart
   if 5 restarts within 5 cycles then timeout
   if failed port 53 then restart
   if 5 restarts within 5 cycles then timeout

# Cron
check process cron with pidfile /var/run/crond.pid
   start program = "/etc/init.d/cron start"
   stop  program = "/etc/init.d/cron stop"
   group system
   depends cron_init, cron_bin
check file cron_init with path /etc/init.d/cron
   group system
check file cron_bin with path /usr/sbin/cron
   group system

# Courier_imapd
check process imap with pidfile /var/run/courier/imapd.pid
   group mail
   start program = "/etc/init.d/courier-imap start"
   stop  program = "/etc/init.d/courier-imap stop"
   if failed port 143 then restart
   if 5 restarts within 5 cycles then timeout

# Courier_immapd-ssl
check process imapd-ssl with pidfile /var/run/courier/imapd-ssl.pid
   group mail
   start program = "/etc/init.d/courier-imap-ssl start"
   stop  program = "/etc/init.d/courier-imap-ssl stop"
   if failed port 143 then restart
   if 5 restarts within 5 cycles then timeout

# Munin-node
check process munin-node with pidfile /var/run/munin/munin-node.pid
   group services
   start program = "/etc/init.d/munin-node start"
   stop  program = "/etc/init.d/munin-node stop"
   if 5 restarts within 5 cycles then timeout

# MySQL
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop  program = "/etc/init.d/mysql stop"
   if failed host 127.0.0.1 port 3306 then restart
   if failed unix "/var/lib/mysql/mysql.sock" then restart
   if 5 restarts within 5 cycles then timeout
   depends mysqld_init
   depends mysqld_bin
   depends mysqldsafe_bin
check file mysqld_init with path /etc/init.d/mysql
   group database
check file mysqld_bin with path /usr/sbin/mysqld
   group database
check file mysqldsafe_bin with path /usr/bin/mysqld_safe
   group database

# Postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid
   group mail
   start program = "/etc/init.d/postfix start"
   stop  program = "/etc/init.d/postfix stop"
   if failed port 25 protocol smtp then restart
   if 5 restarts within 5 cycles then timeout
   depends on postgrey

# Postgrey
check process postgrey with pidfile /var/run/postgrey.pid
        group postgrey
        start program = "/etc/init.d/postgrey start"
        stop  program = "/etc/init.d/postgrey stop"

# Courier_pop3d
check process pop3 with pidfile /var/run/courier/pop3d.pid
   group mail
   start program = "/etc/init.d/courier-pop start"
   stop  program = "/etc/init.d/courier-pop stop"
   if failed port 110 then restart
   if 5 restarts within 5 cycles then timeout

# Courier_pop3-ssl
check process pop3-ssl with pidfile /var/run/courier/pop3d-ssl.pid
   group mail
   start program = "/etc/init.d/courier-pop-ssl start"
   stop  program = "/etc/init.d/courier-pop-ssl stop"
   if failed port 995 then restart
   if 5 restarts within 5 cycles then timeout

# ProFTPd
check process proftpd with pidfile /var/run/proftpd.pid
   start program = "/etc/init.d/proftpd start"
   stop program  = "/etc/init.d/proftpd stop"
   if failed port 21 protocol ftp then restart
   if 5 restarts within 5 cycles then timeout

# SSHd
check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/ssh start"
   stop program  "/etc/init.d/ssh stop"
   if failed port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

# Syslogd
check process syslogd with pidfile /var/run/syslogd.pid
   start program = "/etc/init.d/sysklogd start"
   stop program = "/etc/init.d/sysklogd stop"
   if 5 restarts within 5 cycles then timeout
check file syslogd_file with path /var/log/syslog
If you decide to copy and paste it into your monitrc file, the services will appear in alphabetical order within the monit application.
Don't forget to replace monitor.example.com with your own domain name.
Also change 700 on the line "if totalmem > 700 MB for 5 cycles then restart" in a suitable value for you.

Of course, only configure the services you've running on your server.
So for example, if you don't run postgrey, please don't mention it within your monitrc file.

The syntax within the monitrc file can be verified by executing the command: monit -t
After changing your monitrc file, restart monit with the command: /etc/init.d/monit restart
Attached Images
 
__________________
Hans

BB-Hosting | Quality Web Hosting since 2005

Last edited by Hans; 6th October 2008 at 12:06.
Reply With Quote
Sponsored Links
  #2  
Old 6th October 2008, 13:14
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,034
Thanks: 264
Thanked 151 Times in 131 Posts
Default

Hi Hans.

Yes Monit is great!
I've been using it for some time now.
I used this howto to install it.
http://www.howtoforge.com/server_mon...it_debian_etch

One small tip. Stop Monit when you update ISPconfig, or Monit might start a service that needs to be off during an ISPconfig update!
__________________
Never execute code written on a Friday or a Monday.
Reply With Quote
  #3  
Old 6th October 2008, 13:53
Hans Hans is offline
Moderator
 
Join Date: Dec 2005
Location: Montfoort, The Netherlands
Posts: 2,256
Thanks: 212
Thanked 648 Times in 294 Posts
Send a message via Skype™ to Hans
 
Default

@Edge,
Thank you for that information.
I will make notice of that as well.
__________________
Hans

BB-Hosting | Quality Web Hosting since 2005
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian suPHP security patch pjdevries Installation/Configuration 8 21st May 2008 08:36
Perfect setup Debian Etch ISPConfig - DNS Server kdclaver Installation/Configuration 16 28th December 2007 01:39
Please help me whit bind9 astra2000 Server Operation 12 10th October 2007 02:43
Bind Failed christoph2k HOWTO-Related Questions 4 28th April 2007 00:57
e-mail problem!!! Debian 3.1 maroonworks Installation/Configuration 18 6th December 2005 14:42


All times are GMT +2. The time now is 16:07.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.