#1  
Old 3rd May 2008, 23:08
SamTzu SamTzu is offline
HowtoForge Supporter
 
Join Date: Apr 2007
Location: Helsinki
Posts: 436
Thanks: 33
Thanked 56 Times in 39 Posts
Send a message via Skype™ to SamTzu
Thumbs up Monit & Munin

I noticed that there are not so many configuration files available for Monit & Munin so I decided to share my Monit config here in the hope that someone will share theirs and hopefully we can see some Munin config file here (I have had some problems getting anything but the default graphs.)

I would also like to see how can the chrooted Bind be included in Monit?
It has no pid file in My Ubuntu setup.

Also can someone who has already ISPConfig running add something more here? (Like clamav, etc?)


Ubuntu 8.04 LTS
/etc/monit/monitrc

Quote:
set daemon 120

set httpd port 2812 and
# use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server and
allow monit:windows # require user 'admin' with password 'monit'

check system server26.nimet.info
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert

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

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 server9.nimet.info port 80 protocol http
and request "/index.html" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 300 MB for 5 cycles then restart
if children > 200 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout

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

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

check process ntp with pidfile /var/run/ntpd.pid
start program = "/etc/init.d/ntp start"
stop program = "/etc/init.d/ntp stop"
if failed host 127.0.0.1 port 123 type udp then alert
if 5 restarts within 5 cycles then timeout

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 protocol mysql then restart
if 5 restarts within 5 cycles then timeout
depends on mysqld
# depends on mysql

check file mysqld with path /usr/sbin/mysqld
group database
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

#check file mysql with path /etc/init.d/mysql
# group database
# if failed checksum then unmonitor
# if failed permission 755 then unmonitor
# if failed uid root then unmonitor
# if failed gid root then unmonitor

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 process saslauth with pidfile /var/spool/postfix/var/run/saslauthd/saslauthd.pid
start program = "/etc/init.d/saslauthd start"
stop program = "/etc/init.d/saslauthd stop"
group mail
depends saslauthd_init
depends saslauthd_bin
check file saslauthd_init with path /etc/init.d/saslauthd
group mail
check file saslauthd_bin with path /usr/sbin/saslauthd
group mail

check process bind with pidfile /var/lib/named/var/run/bind/run/named.pid
start program = "/etc/init.d/bind9 start"
stop program = "/etc/init.d/bind9 stop"
if failed host 127.0.0.1 port 53 type tcp protocol dns then alert
if failed host 127.0.0.1 port 53 type udp protocol dns then alert
if 5 restarts within 5 cycles then timeout

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

check process imapd 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 110 then restart
if 5 restarts within 5 cycles then timeout

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 110 then restart
if 5 restarts within 5 cycles then timeout

check process pop3d 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

check process pop3d-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 110 then restart
if 5 restarts within 5 cycles then timeout

check process webmin with pidfile /var/webmin/miniserv.pid
group webmin
start program = "/etc/init.d/webmin start"
stop program = "/etc/init.d/webmin stop"
if failed host 127.0.0.1 port 10000 then restart
if 5 restarts within 5 cycles then timeout

check file webmin_rc with path /etc/init.d/webmin
group webmin
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

check process ispconfig with pidfile /root/ispconfig/httpd/logs/httpd.pid
group ispconfig
start program = "/etc/init.d/ispconfig_server start"
stop program = "/etc/init.d/ispconfig_server stop"
if failed host server9.nimet.info port 81 protocol http
and request "/index.html" then restart

#check process cron with pidfile /var/run/cron.pid
# group system
# start program = "/etc/init.d/cron start"
# stop program = "/etc/init.d/cron stop"
# if 5 restarts within 5 cycles then timeout

#check process clamavd with pidfile /var/run/clamd.pid
# group virus
# start program = "/etc/init.d/clamavd start"
# stop program = "/etc/init.d/clamavd stop"
# if failed unixsocket /var/run/clamd then restart
# if 5 restarts within 5 cycles then timeout

#check process spamd with pidfile /var/run/spamd.pid
# group mail
# start program = "/etc/init.d/spamd start"
# stop program = "/etc/init.d/spamd stop"
# if 5 restarts within 5 cycles then timeout
# if cpu usage > 99% for 5 cycles then alert
# if mem usage > 99% for 5 cycles then alert

check device datafs with path /dev/sdb1
start program = "/bin/mount /var/www"
stop program = "/bin/umount /var/www"
if failed permission 660 then unmonitor
if failed uid root then unmonitor
if failed gid disk then unmonitor
if space usage > 80% for 5 times within 15 cycles then alert
if space usage > 99% then stop
if inode usage > 30000 then alert
if inode usage > 99% then stop
group server

check host serverX.nimet.info with address 79.134.108.199
if failed icmp type echo count 3 with timeout 3 seconds then alert
if failed port 25 protocol smtp with timeout 15 seconds then alert
__________________

Sami Mattila
Internet-Content

Telephone:
00358942833310
Email: firstname.lastname@internet-content.org
Shop: http://shop.internet-content.net
Site: http://www.internet-content.net
Blog: http://www.internet-content.net/en/blog
FB: https://www.facebook.com/internetcontent


Last edited by SamTzu; 12th May 2008 at 18:10.
Reply With Quote
Sponsored Links
  #2  
Old 4th May 2008, 19:03
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

The pid file of the chrooted BIND should be in /var/lib/named/var/run/bind/run.

Here's a monit configuration from one of my servers (Debian Etch):

Code:
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

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

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 5 restarts within 5 cycles then timeout

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 www.falkotimme.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 4 cycles then restart
   if children > 250 for 3 cycles then restart
   if children > 300 then restart
   if loadavg(5min) greater than 5 then restart
   if 3 restarts within 5 cycles then timeout

check file apache_errorlog with path /var/log/apache2/error.log
   if match "exit signal Segmentation fault \(11\)$" then exec "/etc/init.d/apache2 restart"

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
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 23rd September 2014, 23:20
qops1981 qops1981 is offline
Junior Member
 
Join Date: Sep 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default Monit Configuration Check

Hey All,

New to this forum. I have a question about my Monit Confiuration:
Code:
set alert dex123@x123.com 

check process nginx with pidfile /var/run/nginx.pid
  start program = "/etc/init.d/nginx start" with timeout 30 seconds
  stop program  = "/etc/init.d/nginx stop"
  if failed host 127.0.0.1 port 80 for 3 cycles then restart
  if 3 restarts within 11 cycles 
  	then exec "/sbin/fuser --kill 80\tcp && /sbin/service nginx restart"
  	then alert # something to test
  1. Is this code valid and will it function correctly?
  2. Can I have multiple "then" events in a row?
  3. Will multiple "then" events in a row execute one at a time or concurrently?
  4. Could I change the && section and just add another "then" event after the 1st "then" event? Example Below.
Code:
then exec "/sbin/fuser --kill 80\tcp"
then exec "/sbin/service nginx restart"
then alert # something to test
Any advice is greatly appreciated!
Thank you,
-Bill
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
ASSP hook for Server Monitoring With munin And monit Slicer HOWTO-Related Questions 2 19th December 2006 21:38
Server Monitoring With munin And monit kdclaver Installation/Configuration 3 14th December 2006 19:52
Munin & Monit Hans Server Operation 16 6th November 2006 18:38
Extension for the monit and munin programs(tut from falko) ColdDoT Server Operation 7 4th May 2006 12:37
Server Monitoring With munin And monit - Page 2 Hans Server Operation 6 28th April 2006 17:17


All times are GMT +2. The time now is 19:33.


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