<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — [FAQ] How to monitor mail related service with monit]]></title>
	<link rel="self" href="http://www.iredmail.org/forum/feed-atom-topic565.xml" />
	<updated>2010-05-21T23:45:25Z</updated>
	<generator>PunBB</generator>
	<id>http://www.iredmail.org/forum/topic565-faq-how-to-monitor-mail-related-service-with-monit.html</id>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post4037.html#p4037" />
			<content type="html"><![CDATA[<p>After this I just get Firefox is taking too long to respond where do&nbsp; I look for error bugs?</p><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[web2works]]></name>
				<uri>http://www.iredmail.org/forum/user2175.html</uri>
			</author>
			<updated>2010-05-21T23:45:25Z</updated>
			<id>http://www.iredmail.org/forum/post4037.html#p4037</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post3268.html#p3268" />
			<content type="html"><![CDATA[<p>Hi, Snaky.</p><p>You are right, hope it will help others to setup this. <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2010-03-29T18:58:14Z</updated>
			<id>http://www.iredmail.org/forum/post3268.html#p3268</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post3267.html#p3267" />
			<content type="html"><![CDATA[<p>Hi, just a little observation, that might lead to a trap&nbsp; - you are using localhost most of the time for testing servers - that means monit will only test the service listening on 127.0.0.1 - if you have dovecot also listening on another IP, you should also test this IP, because you might not be alerted if anything is wrong with your ip configuration or your firewall or anything else. At least you want your mailserver to be reachable from outside world, maybe <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>so change e.g. the dovecot config to </p><div class="codebox"><pre><code># File: /etc/monit.d/dovecot.monitrc
check process dovecot with pidfile /var/run/dovecot/master.pid
   start program = &quot;/etc/init.d/dovecot start&quot;
   stop program = &quot;/etc/init.d/dovecot stop&quot;
   group mail
   if failed host 74.220.219.116 port 993 type tcpssl sslauto protocol imap then restart
   if failed host 74.220.219.116 port 143 protocol imap  then restart
   if 5 restarts within 5 cycles then timeout
   depends dovecot_init
   depends dovecot_bin
check file dovecot_init with path /etc/init.d/dovecot
   group mail
check file dovecot_bin with path /usr/sbin/dovecot
   group mail</code></pre></div><p>same with postfix - there is an even bigger trap here, because monit assumes 127.0.0.1 if no host is given, so instead of </p><div class="codebox"><pre><code>if failed port 25 protocol smtp then restart</code></pre></div><p>you should write</p><div class="codebox"><pre><code>if failed host 74.220.219.116 port 25 protocol smtp then restart</code></pre></div><p>Also you should use at least one externel email address for alerts, because, well, if your email server is down, you will not receive alerts.</p><p>This all sounds very easy, but I have seen more than one installation where people forgot about these very basic things, mostly just copy-n-pasting configs from the internet without thinking. Hope this will make your monit setup more useful <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>have a nice day,<br />Snaky</p>]]></content>
			<author>
				<name><![CDATA[Snaky]]></name>
				<uri>http://www.iredmail.org/forum/user1999.html</uri>
			</author>
			<updated>2010-03-29T18:54:08Z</updated>
			<id>http://www.iredmail.org/forum/post3267.html#p3267</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post2419.html#p2419" />
			<content type="html"><![CDATA[<p>Reminder: open the port 2812 in iptables<br />change the username:password to your own. Some symbol may not allow</p>]]></content>
			<author>
				<name><![CDATA[hoho]]></name>
				<uri>http://www.iredmail.org/forum/user528.html</uri>
			</author>
			<updated>2010-01-21T03:19:39Z</updated>
			<id>http://www.iredmail.org/forum/post2419.html#p2419</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post2409.html#p2409" />
			<content type="html"><![CDATA[<p>Hi all,<br />I have to add &#039;set daemon 60&#039; to be able to start monit on CentOS</p><p>Don&#039;t know if you have to do too ?</p>]]></content>
			<author>
				<name><![CDATA[mael]]></name>
				<uri>http://www.iredmail.org/forum/user6.html</uri>
			</author>
			<updated>2010-01-20T17:41:09Z</updated>
			<id>http://www.iredmail.org/forum/post2409.html#p2409</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post2401.html#p2401" />
			<content type="html"><![CDATA[<p>@conheotiensinh1983: Thanks for your sharing. Added in my post. <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2010-01-20T03:30:47Z</updated>
			<id>http://www.iredmail.org/forum/post2401.html#p2401</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: [FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post2399.html#p2399" />
			<content type="html"><![CDATA[<p>Hi Zhang,</p><p>Another Way we can install monit by yum (if you use&nbsp; centos or Redhat 5 ) as step:</p><p>Step1: rpm -Uvh <a href="http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm">http://packages.sw.be/rpmforge-release/ … f.i386.rpm</a> //create rpmforge.repo</p><p>Step 2:yum -y install monit</p><p>Beside you can create SSL for access monit by add line</p><p>set httpd port 2812 and<br />&nbsp; SSL ENABLE<br />&nbsp; PEMFILE&nbsp; &nbsp;/var/certs/monit.pem</p><p>My system using monit for monitor system</p><p>Thanks for sharing</p>]]></content>
			<author>
				<name><![CDATA[conheotiensinh1983]]></name>
				<uri>http://www.iredmail.org/forum/user782.html</uri>
			</author>
			<updated>2010-01-20T03:18:01Z</updated>
			<id>http://www.iredmail.org/forum/post2399.html#p2399</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[[FAQ] How to monitor mail related service with monit]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post2397.html#p2397" />
			<content type="html"><![CDATA[<h5>Credits</h5><p>Thanks to <a href="http://www.iredmail.org/forum/user749.html">dasher</a> for <a href="http://www.iredmail.org/forum/topic516-whats-new-in-iredadminv11-view-status-of-mail-related-services.html">his sharing</a>.</p><h5>What monit is</h5><div class="quotebox"><blockquote><p>Monit is a free open source utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.</p><p>Homepage: <a href="http://mmonit.com/monit/">http://mmonit.com/monit/</a></p></blockquote></div><h5>What Monit can do</h5><div class="quotebox"><blockquote><p>Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. You can use Monit to monitor files, directories and filesystems for changes, such as timestamp changes, checksum changes or size changes. You can also monitor remote hosts; Monit can ping a remote host and can check TCP/IP port connections and server protocols. Monit is controlled via an easy to use control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions and recovery status via customizable alert.</p></blockquote></div><h5>How to install it</h5><p><strong>- On RHEL/CentOS, you can download monit from EPEL repository, and then install it manually:</strong><br />&nbsp; + i386: <a href="http://download.fedora.redhat.com/pub/epel/5Server/i386/">http://download.fedora.redhat.com/pub/e … rver/i386/</a><br />&nbsp; + x86_64: <a href="http://download.fedora.redhat.com/pub/epel/5Server/x86_64/">http://download.fedora.redhat.com/pub/e … er/x86_64/</a></p><p><strong>- On Debian/Ubuntu, you can install monit with apt-get directly:</strong><br /></p><div class="codebox"><pre><code># apt-get install monit</code></pre></div><p><strong>- On FreeBSD, you can install it with port tree:</strong><br /></p><div class="codebox"><pre><code># cd /usr/ports/sysutils/monit/
# make install clean</code></pre></div><h5>How to configure it</h5><p>We use RHEL/CentOS as example here.</p><p>On RHEL/CentOS, the main config is <strong>/etc/monit.conf</strong>, and all files under <strong>/etc/monit.d/</strong> will be included as config files too.</p><p>Monit is configured by default, we just need to add service monitors. You can save and place below files under /etc/monit.d/, and then start monit service.</p><p>Reference:<br /></p><ul><li><p><a href="http://mmonit.com/wiki/Monit/ConfigurationExamples">Configuration Examples</a></p></li><li><p><a href="http://mmonit.com/wiki/Monit/EnableSSLInMonit">Enable SSL in Monit</a></p></li></ul><div class="codebox"><pre><code># File: /etc/monit.d/buildinhttp
# Auth user with basic HTTP auth, use plain text as password here.
#
# ---- NOTE: Do NOT forget to open this port in your iptables rules ----
#
set httpd port 2812 and
    #SSL ENABLE         # &lt;- Enable SSL
    #PEMFILE   /var/certs/monit.pem
    allow username:password</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/amavisd
# amavis
check process amavisd with pidfile /var/amavis/amavisd.pid
   group services
   start program = &quot;/etc/init.d/amavisd start&quot;
   stop  program = &quot;/etc/init.d/amavisd stop&quot;
   if failed port 10024 then restart
   if 5 restarts within 5 cycles then timeout</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/httpd
 check process apache with pidfile /var/run/httpd.pid
   group www
   start program = &quot;/etc/init.d/httpd start&quot;
   stop  program = &quot;/etc/init.d/httpd stop&quot;
   if failed port 80 then restart
   if 5 restarts within 5 cycles then timeout
   depends on apache_bin
   depends on apache_rc

 check file apache_bin with path /usr/sbin/httpd
   group www
   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 apache_rc with path /etc/init.d/httpd
   group www
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/clamd
 check process clamd with pidfile /var/run/clamav/clamd.pid
   group virus
   start program = &quot;/etc/init.d/clamd start&quot;
   stop  program = &quot;/etc/init.d/clamd stop&quot;
   if 5 restarts within 5 cycles then timeout
   depends on clamavd_bin
   depends on clamavd_rc

 check file clamavd_bin with path /usr/sbin/clamd
   group virus
   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 clamavd_rc with path /etc/init.d/clamd
   group virus
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/crond
 check process cron with pidfile /var/run/crond.pid
   group system
   start program = &quot;/etc/init.d/crond start&quot;
   stop  program = &quot;/etc/init.d/crond stop&quot;
   if 5 restarts within 5 cycles then timeout
   depends on cron_rc

 check file cron_rc with path /etc/init.d/crond
   group system
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/dovecot
check process dovecot with pidfile /var/run/dovecot/master.pid
   start program = &quot;/etc/init.d/dovecot start&quot;
   stop program = &quot;/etc/init.d/dovecot stop&quot;
   group mail
   if failed host localhost port 993 type tcpssl sslauto protocol imap then restart
   if failed host localhost port 143 protocol imap  then restart
   if 5 restarts within 5 cycles then timeout
   depends dovecot_init
   depends dovecot_bin
check file dovecot_init with path /etc/init.d/dovecot
   group mail
check file dovecot_bin with path /usr/sbin/dovecot
   group mail</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/logging
# log to monit.log
set logfile /var/log/monit.log</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/mysqld
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = &quot;/etc/init.d/mysqld start&quot;
   stop program = &quot;/etc/init.d/mysqld stop&quot;
   if failed host 127.0.0.1 port 3306 protocol mysql then restart
   if 5 restarts within 5 cycles then timeout
   depends on mysql_bin
   depends on mysql_rc

 check file mysql_bin with path /usr/bin/mysqld_safe
   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_rc with path /etc/init.d/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</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/openldap
check process slapd with pidfile /var/run/openldap/slapd.pid
   group database
   start program = &quot;/etc/init.d/ldap start&quot;
   stop program = &quot;/etc/init.d/ldap stop&quot;
   if 5 restarts within 5 cycles then timeout
   depends on slapd_bin
   depends on slapd_rc

 check file slapd_bin with path /usr/sbin/slapd
   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 slapd_rc with path /etc/init.d/ldap
   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</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/policyd
check process policyd with pidfile /var/run/policyd.pid
   group mail
   start program = &quot;/etc/init.d/policyd start&quot;
   stop  program = &quot;/etc/init.d/policyd stop&quot;
   if failed port 10031 protocol postfix-policy then restart
   if 5 restarts within 5 cycles then timeout
   depends on postfix-policyd

 check file postfix-policyd with path /usr/sbin/policyd
   group mail
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid
   group mail
   start program = &quot;/etc/init.d/postfix start&quot;
   stop  program = &quot;/etc/init.d/postfix stop&quot;
   if failed port 25 protocol smtp then restart
   if 5 restarts within 5 cycles then timeout
   depends on postfix_rc

 check file postfix_rc with path /etc/init.d/postfix
   group mail
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/syslog
check process syslogd with pidfile /var/run/syslogd.pid
   start program = &quot;/etc/init.d/syslog start&quot;
   stop program = &quot;/etc/init.d/syslog stop&quot;
   if 5 restarts within 5 cycles then timeout</code></pre></div><div class="codebox"><pre><code># File: /etc/monit.d/sshd
 check process sshd with pidfile /var/run/sshd.pid
   start program  &quot;/etc/init.d/sshd start&quot;
   stop program  &quot;/etc/init.d/sshd stop&quot;
   if failed port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout</code></pre></div><p>Start monit service:<br /></p><div class="codebox"><pre><code># /etc/init.d/monit restart</code></pre></div><p>Access port 2812 of your server address (<a href="http://x.x.x.x:2812/">http://x.x.x.x:2812/</a>) to view the service status. Below are screenshots from monit web site:</p><p><span class="postimg"><img src="http://mmonit.com/monit/_Media/monit47_httpd-2.png" alt="http://mmonit.com/monit/_Media/monit47_httpd-2.png" /></span><br /><span class="postimg"><img src="http://mmonit.com/monit/_Media/monit_httpd2-2.png" alt="http://mmonit.com/monit/_Media/monit_httpd2-2.png" /></span><br /><span class="postimg"><img src="http://mmonit.com/monit/_Media/monit_httpd1-2.png" alt="http://mmonit.com/monit/_Media/monit_httpd1-2.png" /></span></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2010-01-20T02:56:05Z</updated>
			<id>http://www.iredmail.org/forum/post2397.html#p2397</id>
		</entry>
</feed>
