/[monit]/monit/web/monit.html
ViewVC logotype

Diff of /monit/web/monit.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by hauk, Thu Sep 19 09:17:37 2002 UTC revision 1.10 by martinp, Sun Nov 3 21:50:30 2002 UTC
# Line 1  Line 1 
1  <HTML>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2  <HEAD>  <html xmlns="http://www.w3.org/1999/xhtml">
3  <TITLE>monit - system for monitoring programs</TITLE>  <head>
4  <LINK REV="made" HREF="mailto:bhcompile@daffy.perf.redhat.com">  <title>monit - system for monitoring programs</title>
5  </HEAD>  <link rev="made" href="mailto:monit-general@nongnu.org" />
6    </head>
7    
8  <BODY>  <body style="background-color: white">
9    
10  <A NAME="__index__"></A>  <p><a name="__index__"></a></p>
11  <!-- INDEX BEGIN -->  <!-- INDEX BEGIN -->
12    
13  <UL>  <ul>
14    
15          <LI><A HREF="#name">NAME</A></LI>          <li><a href="#name">NAME</a></li>
16          <LI><A HREF="#synopsis">SYNOPSIS</A></LI>          <li><a href="#synopsis">SYNOPSIS</a></li>
17          <LI><A HREF="#description">DESCRIPTION</A></LI>          <li><a href="#description">DESCRIPTION</a></li>
18          <LI><A HREF="#general operation">GENERAL OPERATION</A></LI>          <li><a href="#general_operation">GENERAL OPERATION</a></li>
19          <UL>          <ul>
20    
21                  <LI><A HREF="#general options and arguments">General Options and Arguments</A></LI>                  <li><a href="#general_options_and_arguments">General Options and Arguments</a></li>
22          </UL>          </ul>
23    
24          <LI><A HREF="#logging">LOGGING</A></LI>          <li><a href="#logging">LOGGING</a></li>
25          <LI><A HREF="#daemon mode">DAEMON MODE</A></LI>          <li><a href="#daemon_mode">DAEMON MODE</a></li>
26          <LI><A HREF="#init support">INIT SUPPORT</A></LI>          <li><a href="#init_support">INIT SUPPORT</a></li>
27          <LI><A HREF="#group support">GROUP SUPPORT</A></LI>          <li><a href="#group_support">GROUP SUPPORT</a></li>
28          <LI><A HREF="#alert messages">ALERT MESSAGES</A></LI>          <li><a href="#monitoring_mode_selection">MONITORING MODE SELECTION</a></li>
29          <UL>          <li><a href="#alert_messages">ALERT MESSAGES</a></li>
30            <ul>
31                  <LI><A HREF="#setting a global mail format">Setting a global mail format</A></LI>  
32          </UL>                  <li><a href="#setting_a_global_mail_format">Setting a global mail format</a></li>
33            </ul>
34          <LI><A HREF="#program timeout">PROGRAM TIMEOUT</A></LI>  
35          <LI><A HREF="#resource testing">RESOURCE TESTING</A></LI>          <li><a href="#program_timeout">PROGRAM TIMEOUT</a></li>
36          <LI><A HREF="#connection testing">CONNECTION TESTING</A></LI>          <li><a href="#resource_testing">RESOURCE TESTING</a></li>
37          <LI><A HREF="#monit httpd">MONIT HTTPD</A></LI>          <li><a href="#connection_testing">CONNECTION TESTING</a></li>
38          <UL>          <li><a href="#dependency_checking">DEPENDENCY CHECKING</a></li>
39            <li><a href="#monit_httpd">MONIT HTTPD</a></li>
40                  <LI><A HREF="#monit httpd authentication">Monit HTTPD Authentication</A></LI>          <ul>
41          </UL>  
42                    <li><a href="#monit_httpd_authentication">Monit HTTPD Authentication</a></li>
43          <LI><A HREF="#md5 checksum">MD5 CHECKSUM</A></LI>          </ul>
44          <LI><A HREF="#the run control file">THE RUN CONTROL FILE</A></LI>  
45          <UL>          <li><a href="#md5_checksum">MD5 CHECKSUM</a></li>
46            <li><a href="#the_run_control_file">THE RUN CONTROL FILE</a></li>
47                  <LI><A HREF="#run control syntax">Run Control Syntax</A></LI>          <ul>
48                  <LI><A HREF="#configuration examples">CONFIGURATION EXAMPLES</A></LI>  
49          </UL>                  <li><a href="#run_control_syntax">Run Control Syntax</a></li>
50                    <li><a href="#configuration_examples">CONFIGURATION EXAMPLES</a></li>
51          <LI><A HREF="#files">FILES</A></LI>          </ul>
52          <LI><A HREF="#signals">SIGNALS</A></LI>  
53          <LI><A HREF="#notes">NOTES</A></LI>          <li><a href="#files">FILES</a></li>
54          <LI><A HREF="#authors">AUTHORS</A></LI>          <li><a href="#signals">SIGNALS</a></li>
55          <LI><A HREF="#copyright">COPYRIGHT</A></LI>          <li><a href="#notes">NOTES</a></li>
56          <LI><A HREF="#see also">SEE ALSO</A></LI>          <li><a href="#authors">AUTHORS</a></li>
57  </UL>          <li><a href="#copyright">COPYRIGHT</a></li>
58            <li><a href="#see_also">SEE ALSO</a></li>
59    </ul>
60  <!-- INDEX END -->  <!-- INDEX END -->
61    
62  <HR>  <hr />
63  <P>  <p>
64  <H1><A NAME="name">NAME</A></H1>  </p>
65  <P>monit - system for monitoring programs</P>  <h1><a name="name">NAME</a></h1>
66  <P>  <p>monit - system for monitoring programs</p>
67  <HR>  <p>
68  <H1><A NAME="synopsis">SYNOPSIS</A></H1>  </p>
69  <P><STRONG>monit</STRONG> [options] {arguments}</P>  <hr />
70  <P>  <h1><a name="synopsis">SYNOPSIS</a></h1>
71  <HR>  <p><strong>monit</strong> [options] {arguments}</p>
72  <H1><A NAME="description">DESCRIPTION</A></H1>  <p>
73  <P><STRONG>monit</STRONG> is a utility for monitoring and managing daemons or  </p>
74    <hr />
75    <h1><a name="description">DESCRIPTION</a></h1>
76    <p><strong>monit</strong> is a utility for monitoring and managing daemons or
77  similar programs running on a Unix system; monit will start  similar programs running on a Unix system; monit will start
78  specified programs if they are not running and restart programs  specified programs if they are not running and restart programs
79  not responding.</P>  not responding.</p>
80  <P>The monit utility can run in a daemon mode to repeatedly poll one  <p>The monit utility can run in a daemon mode to repeatedly poll one
81  or more programs at a specified interval.</P>  or more programs at a specified interval.</p>
82  <P>  <p>
83  <HR>  </p>
84  <H1><A NAME="general operation">GENERAL OPERATION</A></H1>  <hr />
85  <P>The behavior of monit is controlled by command-line options  <h1><a name="general_operation">GENERAL OPERATION</a></h1>
86  <EM>and</EM> a run control file, <EM>~/.monitrc</EM>, the syntax of which we  <p>The behavior of monit is controlled by command-line options
87    <em>and</em> a run control file, <em>~/.monitrc</em>, the syntax of which we
88  describe in a later section. Command-line options override  describe in a later section. Command-line options override
89  <EM>.monitrc</EM> declarations.</P>  <em>.monitrc</em> declarations.</p>
90  <P>The following options are recognized by monit. It's recommended  <p>The following options are recognized by monit. It's recommended
91  that you set the log and daemon options in the control  that you set the log and daemon options in the control
92  <EM>.monitrc</EM> file.</P>  <em>.monitrc</em> file.</p>
93  <P>  <p>
94  <H2><A NAME="general options and arguments">General Options and Arguments</A></H2>  </p>
95  <P><STRONG>-c</STRONG> <EM>file</EM>  <h2><a name="general_options_and_arguments">General Options and Arguments</a></h2>
96     Use this control file</P>  <p><strong>-c</strong> <em>file</em>
97  <P><STRONG>-l</STRONG> <EM>logfile</EM>     Use this control file</p>
98     Print log information to this file.</P>  <p><strong>-l</strong> <em>logfile</em>
99  <P><STRONG>-d</STRONG> <EM>n</EM>     Print log information to this file.</p>
100     Run as a daemon once per <EM>n</EM> seconds</P>  <p><strong>-d</strong> <em>n</em>
101  <P><STRONG>-I</STRONG>     Run as a daemon once per <em>n</em> seconds</p>
102     Run from init (do not run in background)</P>  <p><strong>-I</strong>
103  <P><STRONG>-g</STRONG>     Run from init (do not run in background)</p>
104     Set group name for start, stop, restart and status</P>  <p><strong>-g</strong>
105  <P><STRONG>-v</STRONG>     Set group name for start, stop, restart and status</p>
106     Verbose mode, work noisy (diagnostic output)</P>  <p><strong>-v</strong>
107  <P><STRONG>-V</STRONG>     Verbose mode, work noisy (diagnostic output)</p>
108     Print version number and patchlevel</P>  <p><strong>-V</strong>
109  <P><STRONG>-h</STRONG>     Print version number and patchlevel</p>
110     Print a help text</P>  <p><strong>-h</strong>
111  <P>In addition to the options above, monit can be started with one     Print a help text</p>
112    <p>In addition to the options above, monit can be started with one
113  of the following action arguments; monit will then execute the  of the following action arguments; monit will then execute the
114  action and exit without transforming itself to a deamon.</P>  action and exit without transforming itself to a deamon.</p>
115  <P><STRONG>start</STRONG>  <p><strong>start</strong>
116      Start all programs listed in the control file. If      Start all programs listed in the control file. If
117      the group option is set, only start the programs in      the group option is set, only start the programs in
118      the named group.</P>      the named group.</p>
119  <P><STRONG>start name</STRONG>  <p><strong>start name</strong>
120      Start the named program. The name must exist in the      Start the named program. The name must exist in the
121      monitrc file, after a <EM>check</EM> keyword. See also      monitrc file, after a <em>check</em> keyword. See also
122      the MONIT HTTPD section below.</P>      the MONIT HTTPD section below.</p>
123  <P><STRONG>stop</STRONG>      <p><strong>stop</strong>    
124      Stop all programs listed in the control file. If      Stop all programs listed in the control file. If
125      the group option is set, only stop the programs in      the group option is set, only stop the programs in
126      the named group.</P>      the named group.</p>
127  <P><STRONG>stop name</STRONG>  <p><strong>stop name</strong>
128      Stop the named program. The name must exist in the      Stop the named program. The name must exist in the
129      monitrc file, after a <EM>check</EM> keyword. See also      monitrc file, after a <em>check</em> keyword. See also
130      the MONIT HTTPD section below.</P>      the MONIT HTTPD section below.</p>
131  <P><STRONG>restart</STRONG>  <p><strong>restart</strong>
132      Stop and start all programs. If the group option is      Stop and start all programs. If the group option is
133      set, only restart the programs in the named group.</P>      set, only restart the programs in the named group.</p>
134  <P><STRONG>restart name</STRONG>  <p><strong>restart name</strong>
135      Restart the named program. The name must exist in      Restart the named program. The name must exist in
136      the monitrc file, after a <EM>check</EM> keyword. also      the monitrc file, after a <em>check</em> keyword. also
137      the MONIT HTTPD section below.</P>      the MONIT HTTPD section below.</p>
138  <P><STRONG>status</STRONG>  <p><strong>status</strong>
139      Print status information for each program. If the      Print status information for each program. If the
140      group option is set, only print the status for the      group option is set, only print the status for the
141      named group.</P>      named group.</p>
142  <P><STRONG>quit</STRONG>  <p><strong>quit</strong>
143      Kill monit daemon process</P>      Kill monit daemon process</p>
144  <P><STRONG>validate</STRONG>  <p><strong>validate</strong>
145      Check all programs and start the ones not running.      Check all programs and start the ones not running.
146      Also if a program indicates (in the control file)      Also if a program indicates (in the control file)
147      that it's listening on a port number, although      that it's listening on a port number, although
148      monit cannot connect to the port, then restart the      monit cannot connect to the port, then restart the
149      program. This action is also the default      program. This action is also the default
150      behavior when monit runs in daemon mode.</P>      behavior when monit runs in daemon mode.</p>
151  <P>  <p>
152  <HR>  </p>
153  <H1><A NAME="logging">LOGGING</A></H1>  <hr />
154  <P>monit will log status and error messages to a log file. If  <h1><a name="logging">LOGGING</a></h1>
155  <STRONG>syslog</STRONG> is given as a value for the <EM>-l</EM> option (or the  <p>monit will log status and error messages to a log file. If
156  keyword <EM>set logfile syslog</EM> is found in the control file) monit  <strong>syslog</strong> is given as a value for the <em>-l</em> option (or the
157  will use the <STRONG>syslog</STRONG> system daemon for logging messages. To  keyword <em>set logfile syslog</em> is found in the control file) monit
158    will use the <strong>syslog</strong> system daemon for logging messages. To
159  turn off logging, simply do not set the logfile in the control  turn off logging, simply do not set the logfile in the control
160  file (and of course, do not use the -l switch)</P>  file (and of course, do not use the -l switch)</p>
161  <P>  <p>
162  <HR>  </p>
163  <H1><A NAME="daemon mode">DAEMON MODE</A></H1>  <hr />
164  <P>The <EM>-d interval</EM> option runs monit in daemon mode. You must  <h1><a name="daemon_mode">DAEMON MODE</a></h1>
165    <p>The <em>-d interval</em> option runs monit in daemon mode. You must
166  specify a numeric argument which is a polling interval in  specify a numeric argument which is a polling interval in
167  seconds.</P>  seconds.</p>
168  <P>In daemon mode, monit puts itself in the background and runs  <p>In daemon mode, monit puts itself in the background and runs
169  continously, monitoring each specified program and then sleeping  continously, monitoring each specified program and then sleeping
170  for the given polling interval.</P>  for the given polling interval.</p>
171  <PRE>  <pre>
172         Simply invoking</PRE>         Simply invoking</pre>
173  <PRE>  <pre>
174                monit -d 300</PRE>                monit -d 300</pre>
175  <P>will poll all programs described in your <EM>~/.monitrc</EM> file every  <p>will poll all programs described in your <em>~/.monitrc</em> file every
176  5 minutes.</P>  5 minutes.</p>
177  <P>It is possible to set a polling interval in your ~/.monitrc file  <p>It is possible to set a polling interval in your ~/.monitrc file
178  by saying 'set daemon <STRONG>n</STRONG>', where <STRONG>n</STRONG> is an integer number of  by saying 'set daemon <strong>n</strong>', where <strong>n</strong> is an integer number of
179  seconds.  If you do this, monit will always start in daemon mode  seconds.  If you do this, monit will always start in daemon mode
180  (as long as no action arguments are given).</P>  (as long as no action arguments are given).</p>
181  <P>Only one daemon process is permitted per user; in daemon mode,  <p>Only one daemon process is permitted per user; in daemon mode,
182  monit makes a per-user lockfile to guarantee this.</P>  monit makes a per-user lockfile to guarantee this.</p>
183  <P>Calling monit with a daemon in the background sends a wakeup  <p>Calling monit with a daemon in the background sends a wakeup
184  signal to the daemon, forcing it to check programs immediately.</P>  signal to the daemon, forcing it to check programs immediately.</p>
185  <P>The <EM>quit</EM> argument will kill a running daemon process instead  <p>The <em>quit</em> argument will kill a running daemon process instead
186  of waking it up.</P>  of waking it up.</p>
187  <P>If you touch or change the <EM>.monitrc</EM> file while monit is  <p>If you touch or change the <em>.monitrc</em> file while monit is
188  running in daemon mode, this will be detected at the beginning of  running in daemon mode, this will be detected at the beginning of
189  the next poll cycle. When a changed <EM>.monitrc</EM> is detected,  the next poll cycle. When a changed <em>.monitrc</em> is detected,
190  monit rereads it and reinitialize itself. Note also that if you  monit rereads it and reinitialize itself. Note also that if you
191  break the <EM>.monitrc</EM> file's syntax, the monit daemon will exit  break the <em>.monitrc</em> file's syntax, the monit daemon will exit
192  after logging the appropriate error message.</P>  after logging the appropriate error message.</p>
193  <P>  <p>
194  <HR>  </p>
195  <H1><A NAME="init support">INIT SUPPORT</A></H1>  <hr />
196  <P>Monit can be run and controlled from <EM>init</EM>. In the (unlikely)  <h1><a name="init_support">INIT SUPPORT</a></h1>
197  case of a monit crash init will respawn a new monit process.</P>  <p>Monit can be run and controlled from <em>init</em>. In the (unlikely)
198  <P>You can use either the 'set init' statement in monit's  case of a monit crash init will respawn a new monit process.</p>
199    <p>You can use either the 'set init' statement in monit's
200  configuration file or use the -I option from the command line.  configuration file or use the -I option from the command line.
201  Here's a sample /etc/inittab entry for monit:</P>  Here's a sample /etc/inittab entry for monit:</p>
202  <PRE>  <pre>
203    # Run monit in standard runlevels    # Run monit in standard runlevels
204    mo:2345:respawn:/usr/local/sbin/monit -Ic /etc/monitrc</PRE>    mo:2345:respawn:/usr/local/sbin/monit -Ic /etc/monitrc</pre>
205  <P>After you have modified init's configuration file, you can run  <p>After you have modified init's configuration file, you can run
206  the following command to re-examine /etc/inittab and start monit:</P>  the following command to re-examine /etc/inittab and start monit:</p>
207  <PRE>  <pre>
208    telinit q    telinit q
209  </PRE>    
210  <PRE>  For systems without telinit:</pre>
211    <pre>
212  For systems without telinit:</PRE>    kill -1 1</pre>
213  <PRE>  <p>Make sure that if you run monit from init, that you do not start
214    kill -1 1</PRE>  monit in your startup scripts as well.</p>
215  <P>Make sure that if you run monit from init, that you do not start  <p>
216  monit in your startup scripts as well.</P>  </p>
217  <P>  <hr />
218  <HR>  <h1><a name="group_support">GROUP SUPPORT</a></h1>
219  <H1><A NAME="group support">GROUP SUPPORT</A></H1>  <p>Program entries in the control file, <em>monitrc</em>, can be grouped
220  <P>Program entries in the control file, <EM>monitrc</EM>, can be grouped  together by the <em>group</em> statement. The syntax is simply (keyword
221  together by the <EM>group</EM> statement. The syntax is simply (keyword  in capital):</p>
222  in capital):</P>  <pre>
223  <PRE>    GROUP groupname</pre>
224    GROUP groupname</PRE>  <p>With this statement it is possible to group similar program
 <P>With this statement it is possible to group similar program  
225  entries together and manage them as a whole. Monit provides  entries together and manage them as a whole. Monit provides
226  functions to start, stop and restart a group of programs, like  functions to start, stop and restart a group of programs, like
227  so:</P>  so:</p>
228  <P>To start a group of programs:</P>  <p>To start a group of programs:</p>
229  <PRE>  <pre>
230    monit -g &lt;groupname&gt; start</PRE>    monit -g &lt;groupname&gt; start</pre>
231  <P>To stop a group of programs:</P>  <p>To stop a group of programs:</p>
232  <PRE>  <pre>
233    monit -g &lt;groupname&gt; stop</PRE>    monit -g &lt;groupname&gt; stop</pre>
234  <P>To restart a group of programs:</P>  <p>To restart a group of programs:</p>
235  <PRE>  <pre>
236    monit -g &lt;groupname&gt; restart</PRE>    monit -g &lt;groupname&gt; restart</pre>
237  <P>Show the status of a program group:</P>  <p>Show the status of a program group:</p>
238  <PRE>  <pre>
239    monit -g &lt;groupname&gt; status</PRE>    monit -g &lt;groupname&gt; status</pre>
240  <P>  <p>
241  <HR>  </p>
242  <H1><A NAME="alert messages">ALERT MESSAGES</A></H1>  <hr />
243  <P>monit will send an email alert if a program timed out, if monit  <h1><a name="monitoring_mode_selection">MONITORING MODE SELECTION</a></h1>
244    <p>Monit supports three monitoring modes: active, passive and
245    manual.</p>
246    <p>In <em>active</em> mode, monit will monitor the program - in the
247    case that the program is not running it will start/restart
248    it (this is the default behaviour).</p>
249    <p>In <em>passive</em> mode, monit will only monitor the service.
250    Resource related restart and stop options are ignored in
251    this mode as well and will only send alert.</p>
252    <p>For clustered environments there is <em>manual</em> option. If it
253    is defined, monit will enter <em>active</em> mode only if the
254    service was started under monit's control, for example by:</p>
255    <pre>
256      monit start sybase</pre>
257    <p>or</p>
258    <pre>
259      monit -g database start (for service group)</pre>
260    <p>If the service wasn't started by monit or was stopped for
261    example by:</p>
262    <pre>
263      monit stop sybase</pre>
264    <p>or</p>
265    <pre>
266      monit -g database stop (for service group)</pre>
267    <p>it woun't monitor the service at all. It allows to have
268    service configured in monitrc and start it along with its
269    process monitor only if it should run. It could be used for
270    building simple cluster. You can use for example heartbeat
271    to watch health of nodes and in the case of one machine
272    failure start the service on secondary node.</p>
273    <p>Appropriate scripts that can call monit to start/stop
274    specific service are needed on both nodes - typical usage:</p>
275    <pre>
276      FILE                    DESCRIPTION
277      -----------------------------------
278      /etc/inittab            starts monit
279      /etc/rcS.d/S41heartbeat execute &quot;monit start heartbeat&quot;
280      /etc/init.d/monit-node1 execute &quot;monit -g node1 start&quot;
281      /etc/init.d/monit-node2 execute &quot;monit -g node2 start&quot;</pre>
282    <p>so hearbeat can control easy the cluster state and if one
283    node fails, hearbeat starts monit-xxxxx of the failing
284    node =&gt; monit is instructed to start the services of the
285    failing node and monitor them...</p>
286    <p>
287    </p>
288    <hr />
289    <h1><a name="alert_messages">ALERT MESSAGES</a></h1>
290    <p>monit will send an email alert if a program timed out, if monit
291  restarted or stopped a program, a resource statement matches  restarted or stopped a program, a resource statement matches
292  (see also the section RESOURCE TESTING below) or if a checksum  (see also the section RESOURCE TESTING below) or if a checksum
293  error occurred (see also the section MD5 CHECKSUM below). More  error occurred (see also the section MD5 CHECKSUM below). More
294  than one alert statement can be used in a process entry. This  than one alert statement can be used in a process entry. This
295  means that you can send different emails to different addresses.  means that you can send different emails to different addresses.
296  The full syntax for the alert statement is as follows:  The full syntax for the alert statement is as follows:
297  (keywords are in capital)</P>  (keywords are in capital)</p>
298  <PRE>  <pre>
299   ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</PRE>   ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</pre>
300  <P>Simply using:</P>  <p>Simply using:</p>
301  <PRE>  <pre>
302   alert foo@bar</PRE>   alert foo@bar</pre>
303  <P>will send a default email alert to the address foo@bar whenever a  <p>will send a default email alert to the address foo@bar whenever a
304  timeout, restart, checksum, stop or resource error occurs.</P>  timeout, restart, checksum, stop or resource error occurs.</p>
305  <P>If you only want an alert message sent when a certain event  <p>If you only want an alert message sent when a certain event
306  occurs for example a timeout or when a program is restarted;  occurs for example a timeout or when a program is restarted;
307  postfix the alert-statement respectively</P>  postfix the alert-statement respectively</p>
308  <PRE>  <pre>
309   alert foo@bar only on { timeout } or   alert foo@bar only on { timeout } or
310   alert foo@bar { timeout }</PRE>   alert foo@bar { timeout }</pre>
311  <P>(<EM>only</EM> and <EM>on</EM> are noise keywords, ignored by monit)</P>  <p>(<em>only</em> and <em>on</em> are noise keywords, ignored by monit)</p>
312  <P>or</P>  <p>or</p>
313  <PRE>  <pre>
314   alert foo@bar { restart }</PRE>   alert foo@bar { restart }</pre>
315  <P>The same applies for a checksum error</P>  <p>The same applies for a checksum error</p>
316  <PRE>  <pre>
317   alert foo@bar { checksum }</PRE>   alert foo@bar { checksum }</pre>
318  <P>It is also possible to combine events and send mail to different  <p>It is also possible to combine events and send mail to different
319  email addresses like:</P>  email addresses like:</p>
320  <PRE>  <pre>
321   alert foo@bar { restart, timeout, resource }   alert foo@bar { restart, timeout, resource }
322   alert security@bar on { checksum, stop }   alert security@bar on { checksum, stop }
323   alert manager@bar</PRE>   alert manager@bar</pre>
324  <P>This will send an alert message to foo@bar when a timeout or  <p>This will send an alert message to foo@bar when a timeout or
325  restart occurs and a message to security@bar if a checksum error  restart occurs and a message to security@bar if a checksum error
326  occurs. And finally, a message to manager@bar whenever any error  occurs. And finally, a message to manager@bar whenever any error
327  event occurs.  event occurs.
328  </P>  </p>
329  <PRE>  <pre>
330    
331  The following alert-statement:</PRE>  The following alert-statement:</pre>
332  <PRE>  <pre>
333    
334   alert foo@bar { timeout, restart, checksum, resource, stop }</PRE>   alert foo@bar { timeout, restart, checksum, resource, stop }</pre>
335  <P>is equivalent to:</P>  <p>is equivalent to:</p>
336  <PRE>  <pre>
337   alert foo@bar</PRE>   alert foo@bar</pre>
338  <P>which as stated above, will send a message when a timeout, a  <p>which as stated above, will send a message when a timeout, a
339  restart or a checksum error occurs. (If the post fix variant is  restart or a checksum error occurs. (If the post fix variant is
340  used, then note that the parenthesis are <EM>mandatory</EM>).</P>  used, then note that the parenthesis are <em>mandatory</em>).</p>
341  <P>A restart alert is also sent <EM>if monit fails to execute</EM> the  <p>A restart alert is also sent <em>if monit fails to execute</em> the
342  start or the stop program for an entry. <STRONG>It is therefor strongly  start or the stop program for an entry. <strong>It is therefor strongly
343  advised</STRONG> that at least one alert statement register interest for  advised</strong> that at least one alert statement register interest for
344  restart alerts.</P>  restart alerts.</p>
345  <P>monit will provide a default mail message layout that is short  <p>monit will provide a default mail message layout that is short
346  and to the point. Here's an example of a standard alert mail sent  and to the point. Here's an example of a standard alert mail sent
347  by monit:</P>  by monit:</p>
348  <PRE>  <pre>
349   From: monit@tildeslash.com   From: monit@tildeslash.com
350   Subject: monit alert -- apache restarted   Subject: monit alert -- apache restarted
351   To: hauk@tildeslash.com   To: hauk@tildeslash.com
352   Date: Tue, 28 May 2002 20:42:30 +0200</PRE>   Date: Tue, 28 May 2002 20:42:30 +0200</pre>
353  <PRE>  <pre>
354   Program apache restarted</PRE>   Program apache restarted</pre>
355  <PRE>  <pre>
356          Date: Tue May 28 20:42:30 2002          Date: Tue May 28 20:42:30 2002
357          Host: www.tildeslash.com</PRE>          Host: www.tildeslash.com</pre>
358  <PRE>  <pre>
359   Your faithful employee,   Your faithful employee,
360   monit</PRE>   monit</pre>
361  <P>If you want to, you can change the format of this message with  <p>If you want to, you can change the format of this message with
362  the optional <EM>mail-format</EM> statement. The syntax for this  the optional <em>mail-format</em> statement. The syntax for this
363  statement is as follows:</P>  statement is as follows:</p>
364  <PRE>  <pre>
365   mail-format {   mail-format {
366        from: monit@localhost        from: monit@localhost
367     subject: apache $EVENT at $DATE     subject: apache $EVENT at $DATE
# Line 321  statement is as follows:</P> Line 378  statement is as follows:</P>
378          * Where's the DIR command?          * Where's the DIR command?
379          * Why is my &quot;rm&quot; taking so long?          * Why is my &quot;rm&quot; taking so long?
380          * System coming down in 0 min ...          * System coming down in 0 min ...
381   }</PRE>   }</pre>
382  <P>Where the keyword <EM>from:</EM> is the email address monit should  <p>Where the keyword <em>from:</em> is the email address monit should
383  pretend it is sending from. It does not have to be a real mail  pretend it is sending from. It does not have to be a real mail
384  address, but must be a proper formated mail address, on the form;  address, but must be a proper formated mail address, on the form;
385  name@domain. The keyword <EM>subject:</EM> is for the email subject  name@domain. The keyword <em>subject:</em> is for the email subject
386  line. The subject must be on only <EM>one</EM> line. The <EM>message:</EM>  line. The subject must be on only <em>one</em> line. The <em>message:</em>
387  keyword denotes the mail body. If used, this keyword should  keyword denotes the mail body. If used, this keyword should
388  always be the last in a mail-format statement.  The mail body can  always be the last in a mail-format statement.  The mail body can
389  be as long as you want and must <STRONG>not</STRONG> contain the '}' character.</P>  be as long as you want and must <strong>not</strong> contain the '}' character.</p>
390  <P>All of these format keywords are optional but you must provide at  <p>All of these format keywords are optional but you must provide at
391  least one. Thus if you only want to change the from address monit  least one. Thus if you only want to change the from address monit
392  is using you can do:</P>  is using you can do:</p>
393  <PRE>  <pre>
394   alert foo@bar with mail-format { from: bofh@xyzzy.no }</PRE>   alert foo@bar with mail-format { from: bofh@xyzzy.no }</pre>
395  <P>From the previous example you will notice that 4 special  <p>From the previous example you will notice that 4 special
396  variables was used. If used they will be substituted into the  variables was used. If used they will be substituted into the
397  text with a special value:</P>  text with a special value:</p>
398  <P><EM>$EVENT</EM> A string describing the event that occured. The values  <p><em>$EVENT</em> A string describing the event that occured. The values
399  are fixed and are, ``restarted'', ``timed out'', ``stopped and  are fixed and are, ``restarted'', ``timed out'', ``stopped and
400  ''checksum error``</P>  ''checksum error``</p>
401  <P><EM>$PROGRAM</EM> The program entry name in monitrc</P>  <p><em>$PROGRAM</em> The program entry name in monitrc</p>
402  <P><EM>$DATE</EM> The current time and date (C time style).</P>  <p><em>$DATE</em> The current time and date (C time style).</p>
403  <P><EM>$HOST</EM> The name of the host monit is running on</P>  <p><em>$HOST</em> The name of the host monit is running on</p>
404  <P>  <p>
405  <H2><A NAME="setting a global mail format">Setting a global mail format</A></H2>  </p>
406  <P>Finally, it is possible to set a standard mail format with the  <h2><a name="setting_a_global_mail_format">Setting a global mail format</a></h2>
407    <p>Finally, it is possible to set a standard mail format with the
408  following global set-statement (keywords are in capital):  following global set-statement (keywords are in capital):
409  </P>  </p>
410  <PRE>  <pre>
411    
412   SET MAIL-FORMAT {mail-format}</PRE>   SET MAIL-FORMAT {mail-format}</pre>
413  <P>Format set with this statement will apply to every alert  <p>Format set with this statement will apply to every alert
414  statement that does <EM>not</EM> have its own specified mail-format.  statement that does <em>not</em> have its own specified mail-format.
415  This statement is most usefull for setting a default from address  This statement is most usefull for setting a default from address
416  for messages sent by monit, like so:</P>  for messages sent by monit, like so:</p>
417  <PRE>  <pre>
418   set mail-format { from: monit@foo.bar.no }</PRE>   set mail-format { from: monit@foo.bar.no }</pre>
419  <P>  <p>
420  <HR>  </p>
421  <H1><A NAME="program timeout">PROGRAM TIMEOUT</A></H1>  <hr />
422  <P><STRONG>monit</STRONG> provides a program timeout mechanism for situations  <h1><a name="program_timeout">PROGRAM TIMEOUT</a></h1>
423    <p><strong>monit</strong> provides a program timeout mechanism for situations
424  where a program simply refuses to start or respond over a longer  where a program simply refuses to start or respond over a longer
425  period. In cases like this, and particularly if monits poll-cycle  period. In cases like this, and particularly if monits poll-cycle
426  is low, monit will simply increase the machine load by trying to  is low, monit will simply increase the machine load by trying to
427  restart the program.</P>  restart the program.</p>
428  <P>The timeout mechanism monit provides is based on two variables,  <p>The timeout mechanism monit provides is based on two variables,
429  i.e. the number the program has been started and the number of  i.e. the number the program has been started and the number of
430  poll-cycles. For example, if a program had <EM>x</EM> restarts within  poll-cycles. For example, if a program had <em>x</em> restarts within
431  <EM>y</EM> poll-cycles (where <EM>x</EM> &lt;= <EM>y</EM>) then monit will timeout and  <em>y</em> poll-cycles (where <em>x</em> &lt;= <em>y</em>) then monit will timeout and
432  not (re)start the program on the next cycle. It's a good idea to  not (re)start the program on the next cycle. It's a good idea to
433  use the alert statement in conjunction with timeout, so if a  use the alert statement in conjunction with timeout, so if a
434  timeout occurs monit will send an alert notification. A legal  timeout occurs monit will send an alert notification. A legal
435  (but verbose) way to write a timeout statement for a program  (but verbose) way to write a timeout statement for a program
436  entry in the control file is:</P>  entry in the control file is:</p>
437  <PRE>  <pre>
438   timeout if 3 restarts within 3 cycles</PRE>   timeout if 3 restarts within 3 cycles</pre>
439  <P>The shorthand version is:</P>  <p>The shorthand version is:</p>
440  <PRE>  <pre>
441   timeout(3,3)</PRE>   timeout(3,3)</pre>
442  <P>Where the first digit is the number of program restarts, the  <p>Where the first digit is the number of program restarts, the
443  second is the number of poll-cycles. If the number of cycles was  second is the number of poll-cycles. If the number of cycles was
444  reached without a timeout, the program start-counter is reset to  reached without a timeout, the program start-counter is reset to
445  zero. This provides some granularity to catch expectional cases  zero. This provides some granularity to catch expectional cases
446  and do a program timeout, but to let occasional program restarts  and do a program timeout, but to let occasional program restarts
447  happen without having an accumulated timeout.</P>  happen without having an accumulated timeout.</p>
448  <P>If you use timeout (it's optional), then be sure to add an alert  <p>If you use timeout (it's optional), then be sure to add an alert
449  statement to notify the responsible administrator. Such as:  statement to notify the responsible administrator. Such as:
450  </P>  </p>
451  <PRE>  <pre>
452    
453   timeout(3, 5) and alert bofh@foo.bar on { timeout }</PRE>   timeout(3, 5) and alert bofh@foo.bar on { timeout }</pre>
454  <P>To have monit check the program again after a timeout, run 'monit  <p>To have monit check the program again after a timeout, run 'monit
455  start program' from the command line. This will remove the  start program' from the command line. This will remove the
456  timeout lock in the daemon and make the daemon start and check  timeout lock in the daemon and make the daemon start and check
457  the program again.</P>  the program again.</p>
458  <P>  <p>
459  <HR>  </p>
460  <H1><A NAME="resource testing">RESOURCE TESTING</A></H1>  <hr />
461  <P>Monit can examine how much system resources a service or the  <h1><a name="resource_testing">RESOURCE TESTING</a></h1>
462  system is using.</P>  <p>Monit can examine how much system resources a service or the
463  <P>Depending on this indicators services can be stopped or restarted  system is using.</p>
464    <p>Depending on this indicators services can be stopped or restarted
465  and alerts can be generated.  Thus it is possible to utilize  and alerts can be generated.  Thus it is possible to utilize
466  systems which are idle and to spare system under high load.</P>  systems which are idle and to spare system under high load.</p>
467  <P>The full syntax for the resource-statements used for resource  <p>The full syntax for the resource-statements used for resource
468  testing is as follows (keywords are in capital and optional  testing is as follows (keywords are in capital and optional
469  statements in [brackets]),</P>  statements in [brackets]),</p>
470  <PRE>  <pre>
471   resource operator value [cycles] action</PRE>   resource operator value [cycles] action</pre>
472  <P><EM>resource</EM> is a choice of ``CPUUSAGE'', ``MEMUSAGE'', ``MEMKBYTE'',  <p><em>resource</em> is a choice of ``CPUUSAGE'', ``MEMUSAGE'', ``MEMKBYTE'',
473  ``LOADAVG([1min|5min|15min])'':</P>  ``LOADAVG([1min|5min|15min])'':</p>
474  <P>CPUUSAGE is the CPU usage of the process and it's children in  <p>CPUUSAGE is the CPU usage of the process and it's children in
475  parts of hundred (percent). This resource <EM>value</EM> is a floating  parts of hundred (percent). This resource <em>value</em> is a floating
476  point number. For instance, 60.0.</P>  point number. For instance, 60.0.</p>
477  <P>In case the system has more then one CPU and the process has  <p>MEMUSAGE is the memory usage of the process in parts of hundred
478  child processes the CPU usage can raise above 100%.</P>  (percent). This resource <em>value</em> is also a floating point
479  <P>MEMUSAGE is the memory usage of the process in parts of hundred  number.</p>
480  (percent). This resource <EM>value</EM> is also a floating point  <p>MEMKBYTE is the memory amount of the process in KiB (1024
481  number.</P>  byte). This resource <em>value</em> is an integer number.</p>
482  <P>MEMKBYTE is the memory amount of the process in KiB (1024  <p><code>LOADAVG([1min|5min|15min])</code> refers to the system's load average.
 byte). This resource <EM>value</EM> is an integer number.</P>  
 <P><CODE>LOADAVG([1min|5min|15min])</CODE> refers to the system's load average.  
483  The load average is the number of processes in the system run  The load average is the number of processes in the system run
484  queue averaged over the specified time period. This resource  queue averaged over the specified time period. This resource
485  <EM>value</EM> is again a floating point number.</P>  <em>value</em> is again a floating point number.</p>
486  <P><EM>operator</EM> is a choice of ``&lt;'',``&gt;'',``!='',``=='' in c notation, ``gt'',  <p><em>operator</em> is a choice of ``&lt;'',``&gt;'',``!='',``=='' in c notation, ``gt'',
487  ``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'',  ``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'',
488  ``equal'', ``notequal'' in human readable form.</P>  ``equal'', ``notequal'' in human readable form.</p>
489  <P><EM>cycles</EM> is the maximum number of cycles the expression above  <p><em>cycles</em> is the maximum number of cycles the expression above
490  has to be true in order to start an action.  If <EM>cylces</EM> is  has to be true in order to start an action.  If <em>cylces</em> is
491  omitted then it is set to one.</P>  omitted then it is set to one.</p>
492  <P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP''.</P>  <p><em>action</em> is a choice of ``ALERT'', ``RESTART'', ``STOP''.</p>
493  <P>ALERT sends the user a resource alert in case the maximum number  <p>ALERT sends the user a resource alert in case the maximum number
494  of cycles has been reached.</P>  of cycles has been reached.</p>
495  <P>RESTART restarts the service in case the maximum number of cycles  <p>RESTART restarts the service in case the maximum number of cycles
496  has been reached.</P>  has been reached.</p>
497  <P>STOP stops the service in case the maximum number of cycles has  <p>STOP stops the service in case the maximum number of cycles has
498  been reached. If monit stops a service it will not be checked by  been reached. If monit stops a service it will not be checked by
499  monit anymore nor restarted again later. You must explicit start  monit anymore nor restarted again later. You must explicit start
500  it again from the web interface or from the console, like: 'monit  it again from the web interface or from the console, like: 'monit
501  start apache' if you want the monit daemon to monitor the service  start apache' if you want the monit daemon to monitor the service
502  again.</P>  again.</p>
503  <P>To calculate the cycles a counter is raised whenever the  <p>To calculate the cycles a counter is raised whenever the
504  expression above is true and it is lowered whenever it is false  expression above is true and it is lowered whenever it is false
505  (but not below 0).  All counters are reseted in case of a  (but not below 0).  All counters are reseted in case of a
506  restart.</P>  restart.</p>
507  <P>In order to check that the CPU usage of a service is not going  <p>In order to check that the CPU usage of a service is not going
508  beyond 50% for five cycles before restarting it, the following  beyond 50% for five cycles before restarting it, the following
509  expression could be used:</P>  expression could be used:</p>
510  <PRE>  <pre>
511   if cpuusage is greater than 50.0 for 5 cylces then restart</PRE>   if cpuusage is greater than 50.0 for 5 cylces then restart</pre>
512  <P>Or the short version without noise keywords:</P>  <p>Or the short version without noise keywords:</p>
513  <PRE>  <pre>
514   cpuusage &gt; 50.0 5 restart</PRE>   cpuusage &gt; 50.0 5 restart</pre>
515  <P>See also the example section below.</P>  <p>See also the example section below.</p>
516  <P>  <p>
517  <HR>  </p>
518  <H1><A NAME="connection testing">CONNECTION TESTING</A></H1>  <hr />
519  <P>Monit is able to perfom connection testing via networked ports  <h1><a name="connection_testing">CONNECTION TESTING</a></h1>
520  and via unix sockets.</P>  <p>Monit is able to perfom connection testing via networked ports
521  <P>If a program listens on one or more sockets, monit can connect to  and via unix sockets.</p>
522    <p>If a program listens on one or more sockets, monit can connect to
523  the port (using either tcp or udp) and verify that the program  the port (using either tcp or udp) and verify that the program
524  will accept a connection and that it is possible to read and  will accept a connection and that it is possible to read and
525  write to the socket. If a connection is not accepted or if there  write to the socket. If a connection is not accepted or if there
526  is a problem with the socket i|o, monit will assume that  is a problem with the socket i|o, monit will assume that
527  something is wrong and restart the program. The full syntax for  something is wrong and restart the program.  Additionally, if
528  the port-statement used for connection testing is as follows  monit is compiled with openssl support ssl forged network
529  (keywords are in capital and optional statements in [brackets])  services can be tested, too.</p>
530  for networked ports,</P>  <p>The full syntax for the port-statement used for connection
531  <PRE>  testing is as follows (keywords are in capital and optional
532   [HOST hostname] PORT number [TYPE {TCP|UDP}] [PROTO(COL) {name}  statements in [brackets]) for networked ports,</p>
533    [REQUEST {&quot;/path&quot;}]]</PRE>  <pre>
534  <P>or for unix sockets,</P>   [HOST hostname] PORT number
535  <PRE>           [TYPE {TCP|UDP|TCPSSL [CERTMD5 md5sum]}]
536             [PROTO(COL) {name} [REQUEST {&quot;/path&quot;}]]</pre>
537    <p>or for unix sockets,</p>
538    <pre>
539   UNIX(SOCKET) path [TYPE {TCP|UDP}] [PROTO(COL) {name}   UNIX(SOCKET) path [TYPE {TCP|UDP}] [PROTO(COL) {name}
540    [REQUEST {&quot;/path&quot;}]]</PRE>    [REQUEST {&quot;/path&quot;}]]</pre>
541  <P>To have monit check a port connection use the following statement:</P>  <p>To have monit check a port connection use the following statement:</p>
542  <PRE>  <pre>
543    port 80</PRE>    port 80</pre>
544  <P>In this case the machine in question is assumed to be  <p>In this case the machine in question is assumed to be
545  <EM>localhost</EM> and monit will issue a tcp connection to localhost  <em>localhost</em> and monit will issue a tcp connection to localhost
546  at port 80. Monit will use tcp by default, if you want to connect  at port 80. Monit will use tcp by default, if you want to connect
547  with udp, you can specify this after the port-statement;</P>  with udp, you can specify this after the port-statement;</p>
548  <PRE>  <pre>
549   port 53 use type udp ('use' is a noise keyword)</PRE>   port 53 use type udp ('use' is a noise keyword)</pre>
550  <P>In case a server is listening to a unix socket called  <p>The <em>TCPSSL</em> statement accepts optionally the md5 sum of the
551  /var/run/mysocket, the following statement can be used:</P>  server's certificate.  The md5 sum is matched against the one
552  <PRE>  delivered by the server.  In case they do not match the
553   unix /var/run/mysocket</PRE>  connection test fails.</p>
554  <P>If your machine answers for several virtual hosts you can prefix  <p>In case a server is listening to a unix socket called
555  the port statement with a host-statement like so:</P>  /var/run/mysocket, the following statement can be used:</p>
556  <PRE>  <pre>
557     unix /var/run/mysocket</pre>
558    <p>If your machine answers for several virtual hosts you can prefix
559    the port statement with a host-statement like so:</p>
560    <pre>
561   host www.sol.no     port 80   host www.sol.no     port 80
562   host shop.sol.no    port 443   host shop.sol.no    port 443
563   host kvasir.sol.no  port 80   host kvasir.sol.no  port 80
564   host 10.2.3.4       port 80</PRE>   host 10.2.3.4       port 80</pre>
565  <P>And as mentioned above, if you do not specify a host-statement,  <p>And as mentioned above, if you do not specify a host-statement,
566  <EM>localhost</EM> is assumed.</P>  <em>localhost</em> is assumed.</p>
567  <P>Finally, monit also knows how to speak some of the more popular  <p>Finally, monit also knows how to speak some of the more popular
568  Internet protocols. So, besides testing for connections, monit  Internet protocols. So, besides testing for connections, monit
569  can also speak with the server in question to verify that the  can also speak with the server in question to verify that the
570  server works. For example, the following is used to test a http  server works. For example, the following is used to test a http
571  server:  server:
572  </P>  </p>
573  <PRE>  <pre>
574    
575   host www.tildeslash.com port 80 protocol http</PRE>   host www.tildeslash.com port 80 protocol http</pre>
576  <P>At the moment monit knows how to speak <EM>HTTP</EM>, <EM>SMPT</EM>, <EM>FTP</EM>,  <p>At the moment monit knows how to speak <em>HTTP</em>, <em>SMTP</em>, <em>FTP</em>,
577  <EM>POP</EM>, <EM>IMAP</EM> and <EM>NNTP</EM>.</P>  <em>POP</em>, <em>IMAP</em> and <em>NNTP</em>. If you have compiled monit with ssl
578  <P>Some protocols also support a request statement. This statement  support, monit can also speak <em>HTTPS</em>, <em>FTPS</em>, <em>POPS</em> and
579  can be used to ask the server for a special document entity.</P>  <em>IMAPS</em>.</p>
580  <P>Currently <STRONG>only</STRONG> the <EM>HTTP</EM> protocol module supports the  <p>Some protocols also support a request statement. This statement
581  request statement, such as:</P>  can be used to ask the server for a special document entity.</p>
582  <PRE>  <p>Currently <strong>only</strong> the <em>HTTP</em> protocol module supports the
583    request statement, such as:</p>
584    <pre>
585   host www.myhost.com port 80 protocol http   host www.myhost.com port 80 protocol http
586     request &quot;/data/show.php?a=b&amp;c=d&quot;</PRE>     request &quot;/data/show.php?a=b&amp;c=d&quot;</pre>
587  <P>The request should contain an URI string specifying a document  <p>The request should contain an URI string specifying a document
588  from the http server. The string will be url encoded by monit  from the http server. The string will be url encoded by monit
589  before it sends the request to the http server, so it's okay to  before it sends the request to the http server, so it's okay to
590  use url unsafe characters in the request.</P>  use url unsafe characters in the request.</p>
591  <P>If the request statement isn't specified, the default web server  <p>If the request statement isn't specified, the default web server
592  page will be requested.</P>  page will be requested.</p>
593  <P>It is of course possible to mix networked ports and unix sockets  <p>It is of course possible to mix networked ports and unix sockets
594  checks for a service.</P>  checks for a service.</p>
595  <P>See also the example section below.</P>  <p>See also the example section below.</p>
596  <P>  <p>
597  <HR>  </p>
598  <H1><A NAME="monit httpd">MONIT HTTPD</A></H1>  <hr />
599  <P>If specified in the control file, monit will start a monit daemon  <h1><a name="dependency_checking">DEPENDENCY CHECKING</a></h1>
600    <p>If specified in the control file, monit can do dependency
601    checking before starting or stopping processes. The syntax for
602    the depend statement is simply:</p>
603    <pre>
604     DEPEND [process]+</pre>
605    <p>Where <strong>process</strong> is a process entry name, for instance <strong>apache</strong>.
606    You may add more than one process name in a depend statement.
607    See also the example section below.</p>
608    <p>Processes specified in a <em>depend</em> statement will be checked
609    during stop/start operations. When a process is stopped it will
610    first stop the dependant processes. Likewise, if a process is
611    started, it will first stop the dependant processes, start the
612    process, and then start the dependant processes.</p>
613    <p>
614    </p>
615    <hr />
616    <h1><a name="monit_httpd">MONIT HTTPD</a></h1>
617    <p>If specified in the control file, monit will start a monit daemon
618  with http support. From a Browser you can then start and stop  with http support. From a Browser you can then start and stop
619  programs as well as view the status of each program. Also, if  programs as well as view the status of each program. Also, if
620  monit logs to its own file, you can view the content of this  monit logs to its own file, you can view the content of this
621  logfile from a Browser.</P>  logfile in a Browser.</p>
622  <P>The control file statement for starting a monit daemon with http  <p>The control file statement for starting a monit daemon with http
623  support is a global set-statement:</P>  support is a global set-statement:</p>
624  <PRE>  <pre>
625    set httpd port 2812</PRE>    set httpd port 2812</pre>
626  <P>And you can use this URL, <EM><A HREF="http://localhost:2812/">http://localhost:2812/</A></EM>, to access  <p>And you can use this URL, <em><a href="http://localhost:2812/">http://localhost:2812/</a></em>, to access
627  the daemon from a browser.</P>  the daemon from a browser.</p>
628  <P>The port number, in this case 2812, can be any number that you  <p>The port number, in this case 2812, can be any number that you
629  are allowed to bind to.</P>  are allowed to bind to.</p>
630  <P>If you only want the http server to accept connect requests to  <p>If you have compiled monit with openssl support, you can also
631    start the httpd server with ssl support, using the following
632    expression:</p>
633    <pre>
634      set httpd port 2812
635            ssl enable
636            pemfile /etc/certs/monit.pem</pre>
637    <p>And you can use this URL, <em><a href="https://localhost:2812/">https://localhost:2812/</a></em>, to access
638    the monit web server over an ssl encrypted connection.</p>
639    <p>The pemfile, in the example above, holds the private key and the
640    certificate. This file should be stored on a safe place on the
641    filesystem and should have strict permissions, that is, no more
642    than 0700. For more information on how to generate this file,
643    please consult README.ssl</p>
644    <p>In addition, if you want to check for client certificates you can
645    use the CLIENTPEMFILE statement.  In that case a connecting
646    client has to have a sufficient key and certificate in order to
647    connect.  This file also needs to have a necessary CA
648    certificates. A configuration could look like:
649    </p>
650    <pre>
651    
652      set httpd port 2812
653            ssl enable
654            pemfile /etc/certs/monit.pem
655            clientpemfile /etc/certs/monit-client.pem</pre>
656    <p>If you only want the http server to accept connect requests to
657  one host addresses you can specify the bind address either as an  one host addresses you can specify the bind address either as an
658  IP number string or as a hostname. In this example we bind the  IP number string or as a hostname. In the following example we
659  http server to the loopback device. This means that the http  bind the http server to the loopback device. In other words the
660  server will only be reachable from localhost:</P>  http server will only be reachable from localhost:</p>
661  <PRE>  <pre>
662    set httpd port 2812 and use the address 127.0.0.1</PRE>    set httpd port 2812 and use the address 127.0.0.1</pre>
663  <P>or</P>  <p>or</p>
664  <PRE>  <pre>
665    set httpd port 2812 and use the address localhost</PRE>    set httpd port 2812 and use the address localhost</pre>
666  <P>If you do not use the ADDRESS statement the http server will  <p>or with ssl</p>
667  accept connections on any/all local addresses.</P>  <pre>
668  <P>If you remove the httpd statement from the config file, monit will    set httpd port 2812
669          ssl enable
670          address localhost
671          pemfile /var/certs/monit.pem</pre>
672    <p>If you do not use the ADDRESS statement the http server will
673    accept connections on any/all local addresses.</p>
674    <p>If you remove the httpd statement from the config file, monit will
675  stop the httpd server on its next cycle. Likewise if you change  stop the httpd server on its next cycle. Likewise if you change
676  the port number, monit will restart the http server using the new  the port number, monit will restart the http server using the new
677  specified port number.</P>  specified port number.</p>
678  <P>The status page displayed by monit is automatically refreshed  <p>The status page displayed by the monit web server is
679  with the same poll time set for the monit daemon.</P>  automatically refreshed with the same poll time set for the monit
680  <P><STRONG>Note:</STRONG></P>  daemon.</p>
681  <P>You <EM>must</EM> start a monit daemon with http support if you want to  <p><strong>Note:</strong></p>
682  be able to use the following console commands.</P>  <p>You <em>must</em> start a monit daemon with http support if you want to
683  <PRE>  be able to use the following console commands.</p>
684    <pre>
685   'monit stop'   'monit stop'
686   'monit start program'   'monit start program'
687   'monit stop program'   'monit stop program'
688   'monit restart program'   'monit restart program'
689   'monit -g groupname start'   'monit -g groupname start'
690   'monit -g groupname stop'   'monit -g groupname stop'
691   'monit -g groupname restart'</PRE>   'monit -g groupname restart'</pre>
692  <P>If a monit daemon is running in the background we will ask the  <p>If a monit daemon is running in the background we will ask the
693  deamon (via the HTTP protocol) to execute the above commands.  deamon (via the HTTP protocol) to execute the above commands.
694  That is, the daemon is requested to start and stop the programs.  That is, the daemon is requested to start and stop the programs.
695  This ensures that a daemon will not restart a program that you  This ensures that a daemon will not restart a program that you
696  requested to stop and that (any) timeout lock will be removed  requested to stop and that (any) timeout lock will be removed
697  from a program when you start it.</P>  from a program when you start it.</p>
698  <P>  <p>
699  <H2><A NAME="monit httpd authentication">Monit HTTPD Authentication</A></H2>  </p>
700  <P>monit supports two types of autenthication schemas for connecting  <h2><a name="monit_httpd_authentication">Monit HTTPD Authentication</a></h2>
701    <p>monit supports two types of autenthication schemas for connecting
702  to the httpd server. Both schemas can be used together or by  to the httpd server. Both schemas can be used together or by
703  itself.  You <STRONG>must</STRONG> choose at least one.</P>  itself.  You <strong>must</strong> choose at least one.</p>
704  <P><STRONG>Host allow list</STRONG></P>  <p><strong>Host allow list</strong></p>
705  <P>The http server maintains an access-control list of hosts allowed  <p>The http server maintains an access-control list of hosts allowed
706  to connect to the server. You can add as many hosts as you want  to connect to the server. You can add as many hosts as you want
707  to, but only hosts with a valid domain name or its IP address are  to, but only hosts with a valid domain name or its IP address are
708  allowed. If you specify a host that does not resolve, monit will  allowed. If you specify a host that does not resolve, monit will
709  write an error message in the console and not start.</P>  write an error message in the console and not start.</p>
710  <P>The http server will query a nameserver to check any hosts  <p>The http server will query a nameserver to check any hosts
711  connecting to the server. If a host (client) is trying to connect  connecting to the server. If a host (client) is trying to connect
712  to the server, but cannot be found in the access list or cannot  to the server, but cannot be found in the access list or cannot
713  be resolved, the server will shutdown the connection to the  be resolved, the server will shutdown the connection to the
714  client promptly.</P>  client promptly.</p>
715  <P>Control file example:</P>  <p>Control file example:</p>
716  <PRE>  <pre>
717    set httpd port 2812    set httpd port 2812
718        allow localhost        allow localhost
719        allow my.other.work.machine.com        allow my.other.work.machine.com
720        allow 10.1.1.1</PRE>        allow 10.1.1.1</pre>
721  <P><STRONG>Basic Authentication</STRONG></P>  <p><strong>Basic Authentication</strong></p>
722  <P>This authentication schema is HTTP specific and described in more  <p>This authentication schema is HTTP specific and described in more
723  detail in RFC 2617.</P>  detail in RFC 2617.</p>
724  <P>In short; a server challenge a client (e.g. a Browser) to send  <p>In short; a server challenge a client (e.g. a Browser) to send
725  authentication information (username and password) and if  authentication information (username and password) and if
726  accepted, the server will allow the client access to the  accepted, the server will allow the client access to the
727  requested document.</P>  requested document.</p>
728  <P>The biggest weakness with Basic Authentication is that the  <p>The biggest weakness with Basic Authentication is that the
729  username and password is sent in clear-text (i.e. base64 encoded)  username and password is sent in clear-text (i.e. base64 encoded)
730  over the network. It is therefor recommended that you do not use  over the network. It is therefor recommended that you do not use
731  this authentication method unless you are behind a firewall.</P>  this authentication method unless you run the monit http server
732  <P>monit will use Basic Authentication if an allow statement contains  with <em>ssl</em> support. <strong>If</strong> you are using monit with ssl support
733    then it is completely safe to use Basic Authentication since
734    <strong>all</strong> http data, including Basic Authentication headers will be
735    encrypted.</p>
736    <p>monit will use Basic Authentication if an allow statement contains
737  a username and password separated with a single ':' character,  a username and password separated with a single ':' character,
738  like so; <EM>allow username:password</EM>. The username and password  like so; <em>allow username:password</em>. The username and password
739  must be written in clear-text. Only one username and password  must be written in clear-text. Only one username and password
740  pair is supported.</P>  pair is supported.</p>
741  <P>If you use this method together with a host list, then only  <p>If you use this method together with a host list, then only
742  clients from the listed hosts will be allowed to connect to the  clients from the listed hosts will be allowed to connect to the
743  monit http server and each client will be asked to provide a  monit http server and each client will be asked to provide a
744  username and password.</P>  username and password.</p>
745  <P>Example:</P>  <p>Example:</p>
746  <PRE>  <pre>
747    set httpd port 2812    set httpd port 2812
748        allow localhost        allow localhost
749        allow my.other.work.machine.com        allow my.other.work.machine.com
750        allow 10.1.1.1        allow 10.1.1.1
751        allow hauk:monit</PRE>        allow hauk:monit</pre>
752  <P>If you only want to use Basic Authentication, then just provide  <p>If you only want to use Basic Authentication, then just provide
753  the one line with username and password, like:</P>  the one line with username and password, like:</p>
754  <PRE>  <pre>
755    set httpd port 2812    set httpd port 2812
756        allow hauk:monit</PRE>        allow hauk:monit</pre>
757  <P>If you use Basic Authentication it is a good idea to set the  <p>If you use Basic Authentication it is a good idea to set the
758  access permission for the control file (~/.monitrc) to only  access permission for the control file (~/.monitrc) to only
759  readable and writeable for the user running monit, because the  readable and writeable for the user running monit, because the
760  password is written in clear-text. (Use this command, /bin/chmod  password is written in clear-text. (Use this command, /bin/chmod
761  600 ~/.monitrc). This is actually a good idea anyway.</P>  600 ~/.monitrc). In fact, since monit <strong>version 3.0</strong>, monit will
762  <P>  complain and exit if the control file is readable by others.</p>
763  <HR>  <p>
764  <H1><A NAME="md5 checksum">MD5 CHECKSUM</A></H1>  </p>
765  <P>If specified in the control file, monit will compute a md5  <hr />
766    <h1><a name="md5_checksum">MD5 CHECKSUM</a></h1>
767    <p>If specified in the control file, monit will compute a md5
768  checksum for programs. The checksum is used to verify that a  checksum for programs. The checksum is used to verify that a
769  program does not change. If a program was changed, monit will  program does not change. If a program was changed, monit will
770  send an (optional) alert notification, log an alert message and  send an (optional) alert notification, log an alert message and
771  not check the process anymore. The web interface will also show a  not check the process anymore. The web interface will also show a
772  checksum warning.</P>  checksum warning.</p>
773  <P>The rationale for this feature is security and that monit does  <p>The rationale for this feature is security and that monit does
774  not start a possible cracked program or script.</P>  not start a possible cracked program or script.</p>
775  <P>The full syntax for the checksum-statement is as follows:  <p>The full syntax for the checksum-statement is as follows:
776  (keywords are in capital)</P>  (keywords are in capital)</p>
777  <PRE>  <pre>
778   CHECKSUM [file [EXPECT checksum] ]+</PRE>   CHECKSUM [file [EXPECT checksum] ]+</pre>
779  <P>A legal (but verbose) way to write a checksum statement for a  <p>A legal (but verbose) way to write a checksum statement for a
780  process entry in the control file is:</P>  process entry in the control file is:</p>
781  <PRE>  <pre>
782   checksum the /usr/bin/httpd program</PRE>   checksum the /usr/bin/httpd program</pre>
783  <P>The shorthand version is just:</P>  <p>The shorthand version is just:</p>
784  <PRE>  <pre>
785   checksum /usr/bin/httpd</PRE>   checksum /usr/bin/httpd</pre>
786  <P>Several files can be used in a checksum statement:</P>  <p>Several files can be used in a checksum statement:</p>
787  <PRE>  <pre>
788   checksum /usr/apache/bin/httpd /usr/apache-ssl/bin/httpsd</PRE>   checksum /usr/apache/bin/httpd /usr/apache-ssl/bin/httpsd</pre>
789  <P>or on a line by itself:</P>  <p>or on a line by itself:</p>
790  <PRE>  <pre>
791   checksum /usr/apache/bin/httpd   checksum /usr/apache/bin/httpd
792   checksum /usr/apache-ssl/bin/httpsd</PRE>   checksum /usr/apache-ssl/bin/httpsd</pre>
793  <P>You can add as many 'checksum file' statements as you want. Like  <p>You can add as many 'checksum file' statements as you want. Like
794  described above, if the checksum for a file changes, monit will  described above, if the checksum for a file changes, monit will
795  log a warning, issue an alert message and not check the  log a warning, issue an alert message and not check the
796  associated process anymore.</P>  associated process anymore.</p>
797  <P>The <EM>expect</EM> statement is optional and used to specify a md5  <p>The <em>expect</em> statement is optional and used to specify a md5
798  string monit should expect when testing a file's checksum. If  string monit should expect when testing a file's checksum. If
799  this statement is used monit will not compute an initial checksum  this statement is used monit will not compute an initial checksum
800  for the file, as in the examples above, but instead use the  for the file, as in the examples above, but instead use the
801  string you submit. For example:</P>  string you submit. For example:</p>
802  <PRE>  <pre>
803   checksum /usr/bin/httpd expect 8f7f419955cefa0b33a2ba316cba3659</PRE>   checksum /usr/bin/httpd expect 8f7f419955cefa0b33a2ba316cba3659</pre>
804  <P>or verbose style;</P>  <p>or verbose style;</p>
805  <PRE>  <pre>
806   checksum /usr/bin/httpd and   checksum /usr/bin/httpd and
807     expect the sum 4e5309d1956f003bcdff168748bea647</PRE>     expect the sum 4e5309d1956f003bcdff168748bea647</pre>
808  <P>You can, for example, use the GNU utility <EM>md5sum</EM> to create a  <p>You can, for example, use the GNU utility <em>md5sum</em> to create a
809  checksum string for a file and then use this string in the  checksum string for a file and then use this string in the
810  expect-statement.</P>  expect-statement.</p>
811  <P>  <p>
812  <HR>  </p>
813  <H1><A NAME="the run control file">THE RUN CONTROL FILE</A></H1>  <hr />
814  <P>The preferred way to set up monit is to write a <EM>.monitrc</EM> file  <h1><a name="the_run_control_file">THE RUN CONTROL FILE</a></h1>
815    <p>The preferred way to set up monit is to write a <em>.monitrc</em> file
816  in your home directory.  When there is a conflict between the  in your home directory.  When there is a conflict between the
817  command-line arguments and the arguments in this file, the  command-line arguments and the arguments in this file, the
818  command-line arguments take precedence. To protect the security  command-line arguments take precedence. To protect the security
819  of your control file and passwords the control file must have  of your control file and passwords the control file must have
820  permissions <EM>no more than 0700</EM> (u=xrw,g=,o=); monit will  permissions <em>no more than 0700</em> (u=xrw,g=,o=); monit will
821  complain and exit otherwise.</P>  complain and exit otherwise.</p>
822  <P>  <p>
823  <H2><A NAME="run control syntax">Run Control Syntax</A></H2>  </p>
824  <P>Comments begin with a '#' and extend through the end of the line.  <h2><a name="run_control_syntax">Run Control Syntax</a></h2>
825    <p>Comments begin with a '#' and extend through the end of the line.
826  Otherwise the file consists of a series of program entries or  Otherwise the file consists of a series of program entries or
827  global option statements in a free-format, token-oriented syntax.</P>  global option statements in a free-format, token-oriented syntax.</p>
828  <P>There are three kinds of tokens: grammar keywords, numbers (i.e.  <p>There are three kinds of tokens: grammar keywords, numbers (i.e.
829  decimal digit sequences) and strings. Strings can be either  decimal digit sequences) and strings. Strings can be either
830  quoted or unquoted. A quoted string is bounded by double quotes  quoted or unquoted. A quoted string is bounded by double quotes
831  and may contain whitespace (and quoted digits are treated as a  and may contain whitespace (and quoted digits are treated as a
832  string).  An unquoted string is any whitespace-delimited token,  string).  An unquoted string is any whitespace-delimited token,
833  containing characters and/or numbers.</P>  containing characters and/or numbers.</p>
834  <P>Each program entry consists of the keywords `check', followed by  <p>Each program entry consists of the keywords `check', followed by
835  a unique descriptive name for the program, which is again  a unique descriptive name for the program, which is again
836  followed by a path to the program's pidfile. A check entry can  followed by a path to the program's pidfile. A check entry can
837  have a number of optional statements. These statements are  have a number of optional statements. These statements are
838  described below and in the example section.</P>  described below and in the example section.</p>
839  <P>You can use noise keywords like 'if', `and', `with(in)', `has',  <p>You can use noise keywords like 'if', `and', `with(in)', `has',
840  `using', 'use', 'on(ly)' and `program' anywhere in an entry to  `using', 'use', 'on(ly)' and `program' anywhere in an entry to
841  make it resemble English. They're ignored, but can make entries  make it resemble English. They're ignored, but can make entries
842  much easier to read at a glance. The punctuation characters ';'  much easier to read at a glance. The punctuation characters ';'
843  ',' and '=' are also ignored. Keywords are case insensitive.</P>  ',' and '=' are also ignored. Keywords are case insensitive.</p>
844  <PRE>  <pre>
845   Here are the legal global keywords:</PRE>   Here are the legal global keywords:</pre>
846  <PRE>  <pre>
847   Keyword         Function   Keyword         Function
848   -----------------------------------------------------------   -----------------------------------------------------------
849   set daemon      Set a background poll interval in seconds   set daemon      Set a background poll interval in seconds
# Line 732  much easier to read at a glance. The pun Line 860  much easier to read at a glance. The pun
860                   messages emitted by monit.                   messages emitted by monit.
861   set httpd port  Activates monit http server at the given   set httpd port  Activates monit http server at the given
862                   portnumber.                   portnumber.
863     ssl enable      Enables ssl support for the httpd server.
864                     It requires the use of the pemfile statement.
865     ssl disable     Disables ssl support for the httpd server.
866                     It is equal to omitting any ssl statement.
867     pemfile         Set the pemfile to be used with ssl.
868     clientpemfile   Set the pemfile to be used when client's
869                     certificates should be checked too.
870   address         If specified, the http server will only   address         If specified, the http server will only
871                   accept connect requests to this addresses                   accept connect requests to this addresses
872                   This statement is an optional part of the                   This statement is an optional part of the
# Line 741  much easier to read at a glance. The pun Line 876  much easier to read at a glance. The pun
876                   a username and password allowed to connect                   a username and password allowed to connect
877                   to the server. More than one allow statement                   to the server. More than one allow statement
878                   are allowed. This statement is also an                   are allowed. This statement is also an
879                   optional part of the set httpd statement.</PRE>                   optional part of the set httpd statement.</pre>
880  <PRE>  <pre>
881   Here are the legal program entry keywords:</PRE>   Here are the legal program entry keywords:</pre>
882  <PRE>  <pre>
883   Keyword         Function   Keyword         Function
884   ------------------------------------------------------------   ------------------------------------------------------------
885   check           Starts an entry and must be followed by a   check           Starts an entry and must be followed by a
# Line 774  much easier to read at a glance. The pun Line 909  much easier to read at a glance. The pun
909                   either tcp or udp.                   either tcp or udp.
910   tcp             Specifies that monit should use a TCP   tcp             Specifies that monit should use a TCP
911                   socket type (stream) when testing the port.                   socket type (stream) when testing the port.
912     tcpssl          Specifies that monit should use a TCP
913                     socket type (stream) which is embeds a ssl
914                     connection when testing the port.
915   udp             Specifies that monit should use a UDP socket   udp             Specifies that monit should use a UDP socket
916                   type (datagram) when testing the port.                   type (datagram) when testing the port.
917     certmd5         The md5 sum of a certificate a ssl forged
918                     server has to deliver.
919   proto(col)      This keyword specifies the type of service   proto(col)      This keyword specifies the type of service
920                   found at the port. monit knows at the moment                   found at the port. monit knows at the moment
921                   how to speak HTTP, SMPT, FTP, POP and IMAP.                   how to speak HTTP, SMPT, FTP, POP and IMAP.
# Line 817  much easier to read at a glance. The pun Line 957  much easier to read at a glance. The pun
957                   cycle. Usefull in daemon mode when the                   cycle. Usefull in daemon mode when the
958                   poll-cycle is short and the program takes                   poll-cycle is short and the program takes
959                   some time to start.                   some time to start.
960   autostart       Must be followed by the keywords yes or no.   mode            Must be followed either by the keyword active,
961                   If yes, monit will restart the program if                   passive or manual. If active, monit will restart
962                   it is not running (the default behaviour).                   the program if it is not running (this is the
963                     default behaviour). If passive, monit will not
964                     (re)start the program if it is not running - it
965                     will only monitor and send alerts (resource
966                     related restart and stop options are ignored
967                     in this mode also). If manual, monit will enter
968                     active mode only if service was started under
969                     monit's control otherwise the service isn't
970                     monitored.
971   cpuusage        Must be followed by a compare operator, a   cpuusage        Must be followed by a compare operator, a
972                   floating point number, optionally a maximum                   floating point number, optionally a maximum
973                   number of cycles and an action. This statement                   number of cycles and an action. This statement
# Line 838  much easier to read at a glance. The pun Line 986  much easier to read at a glance. The pun
986                   action.  This statement is used to check the                   action.  This statement is used to check the
987                   system load average over a number of cylces. If                   system load average over a number of cylces. If
988                   the compare expression matches then the action                   the compare expression matches then the action
989                   start, alert or stop is avtivated.</PRE>                   start, alert or stop is avtivated.
990  <P>Here's the complete list of reserved <STRONG>keywords</STRONG> used by monit:</P>   depend          Must be followed by the name of a process that depends
991  <P><EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, <EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>,                   on the process given in the check field. This process
992  <EM>allow</EM>, <EM>check</EM>, <EM>init</EM>, <EM>pidfile</EM>, <EM>group</EM>, <EM>start</EM>,                   will be stopped/started before/after the current
993  <EM>stop</EM>, <EM>port(number)</EM>, <EM>unix(socket)</EM>, <EM>type</EM>,                   process.</pre>
994  <EM>proto(col)</EM>, <EM>tcp</EM>, <EM>udp</EM>, <EM>alert</EM>, <EM>mail-format</EM>,  <p>Here's the complete list of reserved <strong>keywords</strong> used by monit:</p>
995  <EM>restart</EM>, <EM>timeout</EM>, <EM>checksum</EM>, <EM>resource</EM>, <EM>expect</EM>,  <p><em>set</em>, <em>daemon</em>, <em>logfile</em>, <em>syslog</em>, <em>address</em>, <em>httpd</em>,
996  <EM>mailserver</EM>, <EM>every</EM>, <EM>autostart</EM>, <EM>yes</EM>, <EM>no</EM>, <EM>host</EM>,  <em>ssl</em>, <em>enable</em>, <em>disable</em>, <em>pemfile</em>, <em>allow</em>, <em>check</em>,
997  <EM>default</EM>, <EM>http</EM>, <EM>ftp</EM>, <EM>smtp</EM>, <EM>pop</EM>, <EM>nntp</EM>, <EM>imap</EM>,  <em>init</em>, <em>pidfile</em>, <em>group</em>, <em>start</em>, <em>stop</em>,
998  <EM>request</EM>, <EM>cpuusage</EM>, <EM>memusage</EM>, <EM>memkbyte</EM> and <EM>loadavg</EM>.</P>  <em>port(number)</em>, <em>unix(socket)</em>, <em>type</em>, <em>proto(col)</em>, <em>tcp</em>,
999  <P>And here is a complete list of <STRONG>noise keywords</STRONG> ignored by  <em>tcpssl</em>, <em>udp</em>, <em>alert</em>, <em>mail-format</em>, <em>restart</em>,
1000  monit:</P>  <em>timeout</em>, <em>checksum</em>, <em>resource</em>, <em>expect</em>, <em>mailserver</em>,
1001  <P><EM>if</EM>, <EM>is</EM>, <EM>are</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>,  <em>every</em>, <em>mode</em>, <em>active</em>, <em>passive</em>, <em>manual</em>, <em>host</em>,
1002  <EM>using</EM>, <EM>use</EM>, <EM>the</EM>, <EM>sum</EM>, <EM>restarts</EM>, <EM>program(s)</EM>,  <em>default</em>, <em>http</em>, <em>ftp</em>, <em>smtp</em>, <em>pop</em>, <em>nntp</em>, <em>imap</em>,
1003  <EM>cycle(s)</EM>, <EM>than</EM>, <EM>then</EM>, <EM>for</EM>.</P>  <em>request</em>, <em>cpuusage</em>, <em>memusage</em>, <em>memkbyte</em> and <em>loadavg</em>.</p>
1004  <P><STRONG>Note:</STRONG> If the <EM>start</EM> or <EM>stop</EM> programs are shell scripts,  <p>And here is a complete list of <strong>noise keywords</strong> ignored by
1005  then the script must begin with <CODE>#!</CODE> and the remainder of the  monit:</p>
1006    <p><em>if</em>, <em>is</em>, <em>are</em>, <em>on(ly)</em>, <em>with(in)</em>, <em>and</em>, <em>has</em>,
1007    <em>using</em>, <em>use</em>, <em>the</em>, <em>sum</em>, <em>restarts</em>, <em>program(s)</em>,
1008    <em>cycle(s)</em>, <em>than</em>, <em>then</em>, <em>for</em>.</p>
1009    <p><strong>Note:</strong> If the <em>start</em> or <em>stop</em> programs are shell scripts,
1010    then the script must begin with <code>#!</code> and the remainder of the
1011  first line must specify an interpreter for the  first line must specify an interpreter for the
1012  program. E.g. <CODE>#!/bin/sh</CODE></P>  program. E.g. <code>#!/bin/sh</code></p>
1013  <P>It's possible to write scripts directly into the <EM>start</EM> and  <p>It's possible to write scripts directly into the <em>start</em> and
1014  <EM>stop</EM> entries by using a string of shell-commands. Like:</P>  <em>stop</em> entries by using a string of shell-commands. Like:</p>
1015  <PRE>  <pre>
1016   start: &quot;/bin/sh -c { echo $$ &gt; pidfile; exec program }&quot;   start: &quot;/bin/sh -c { echo $$ &gt; pidfile; exec program }&quot;
1017   stop:  &quot;/bin/sh -c { kill -s SIGTERM `cat pidfile` }&quot;</PRE>   stop:  &quot;/bin/sh -c { kill -s SIGTERM `cat pidfile` }&quot;</pre>
1018  <P>  <p>
1019  <H2><A NAME="configuration examples">CONFIGURATION EXAMPLES</A></H2>  </p>
1020  <P>The simplest form is just the check statement. In this example we  <h2><a name="configuration_examples">CONFIGURATION EXAMPLES</a></h2>
1021  check to see if the server is running and log a message if not:</P>  <p>The simplest form is just the check statement. In this example we
1022  <PRE>  check to see if the server is running and log a message if not:</p>
1023   check resin with pidfile /usr/local/resin/srun.pid</PRE>  <pre>
1024  <P>To have monit start the server if it's not running, add a start   check resin with pidfile /usr/local/resin/srun.pid</pre>
1025  statement:</P>  <p>To have monit start the server if it's not running, add a start
1026  <PRE>  statement:</p>
1027    <pre>
1028   check resin with pidfile /usr/local/resin/srun.pid   check resin with pidfile /usr/local/resin/srun.pid
1029     start program = &quot;/usr/local/resin/bin/srun.sh start&quot;</PRE>     start program = &quot;/usr/local/resin/bin/srun.sh start&quot;</pre>
1030  <P>Here's a more advanced example for monitoring an apache  <p>Here's a more advanced example for monitoring an apache
1031  web-server listening on the default portnumber for HTTP and  web-server listening on the default portnumber for HTTP and
1032  HTTPS. In this example monit will restart apache if it's not  HTTPS. In this example monit will restart apache if it's not
1033  accepting connections at the portnumbers. The method monit use  accepting connections at the portnumbers. The method monit use
1034  for a process restart is to first execute the stop-program, wait  for a process restart is to first execute the stop-program, wait
1035  for 10 seconds (to give the program time to terminate) and then  for 10 seconds (to give the program time to terminate) and then
1036  execute the start-program.</P>  execute the start-program.</p>
1037  <PRE>  <pre>
1038   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1039     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
1040     stop program  = &quot;/etc/init.d/httpd stop&quot;     stop program  = &quot;/etc/init.d/httpd stop&quot;
1041     port 80       port 80  
1042     port 443</PRE>     port 443</pre>
1043  <P>In this example we use udp for connection testing to check if the  <p>In this example we use udp for connection testing to check if the
1044  'named' service is running and also use timeout and alert:</P>  'named' service is running and also use timeout and alert:</p>
1045  <PRE>  <pre>
1046   check named with pidfile /var/run/named.pid   check named with pidfile /var/run/named.pid
1047     start program = &quot;/etc/init.d/named start&quot;     start program = &quot;/etc/init.d/named start&quot;
1048     stop program  = &quot;/etc/init.d/named stop&quot;     stop program  = &quot;/etc/init.d/named stop&quot;
1049     port 53 use type udp     port 53 use type udp
1050     timeout (3,5)     timeout (3,5)
1051     alert bofh@norid.no</PRE>     alert bofh@norid.no</pre>
1052  <P>The following example illustrate how to check if the service  <p>The following example illustrate how to check if the service
1053  'sophie' is answering connections on its unix domain socket:</P>  'sophie' is answering connections on its unix domain socket:</p>
1054  <PRE>  <pre>
1055   check sophie with pidfile /var/run/sophie.pid   check sophie with pidfile /var/run/sophie.pid
1056     start program = &quot;/etc/init.d/sophie start&quot;     start program = &quot;/etc/init.d/sophie start&quot;
1057     stop  program = &quot;/etc/init.d/sophie stop&quot;     stop  program = &quot;/etc/init.d/sophie stop&quot;
1058     unix /var/run/sophie</PRE>     unix /var/run/sophie</pre>
1059  <P>In this example we check an apache web-server running on  <p>In this example we check an apache web-server running on
1060  localhost that answers for several IP-based virtual hosts or  localhost that answers for several IP-based virtual hosts or
1061  vhosts, hence the host statement before port:</P>  vhosts, hence the host statement before port:</p>
1062  <PRE>  <pre>
1063   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1064     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
1065     stop program  = &quot;/etc/init.d/httpd stop&quot;     stop program  = &quot;/etc/init.d/httpd stop&quot;
1066     host www.sol.no          port 80     host www.sol.no          port 80
1067     host shop.sol.no         port 443     host shop.sol.no         port 443
1068     host chat.sol.no         port 80     host chat.sol.no         port 80
1069     host www.tildeslash.com  port 80</PRE>     host www.tildeslash.com  port 80</pre>
1070  <P>In the following example we ask monit to compute and verify the  <p>In the following example we ask monit to compute and verify the
1071  checksum for the underlying apache binary used by the start and  checksum for the underlying apache binary used by the start and
1072  stop programs.</P>  stop programs.</p>
1073  <PRE>  <pre>
1074   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1075     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
1076     stop program  = &quot;/etc/init.d/httpd stop&quot;     stop program  = &quot;/etc/init.d/httpd stop&quot;
1077     host www.tildeslash.com  port 80     host www.tildeslash.com  port 80
1078     checksum /usr/local/apache/bin/httpd</PRE>     checksum /usr/local/apache/bin/httpd</pre>
1079  <P>Some servers are slow starters, like for example Java based  <p>Some servers are slow starters, like for example Java based
1080  Application Servers. So if we want to keep the poll-cycle low  Application Servers. So if we want to keep the poll-cycle low
1081  (i.e. &lt; 60 seconds) but allow some programs to take its time to  (i.e. &lt; 60 seconds) but allow some programs to take its time to
1082  start, the <STRONG>every</STRONG> statement is handy:</P>  start, the <strong>every</strong> statement is handy:</p>
1083  <PRE>  <pre>
1084   check dynamo with pidfile /etc/dynamo.pid   check dynamo with pidfile /etc/dynamo.pid
1085     start program = &quot;/etc/init.d/dynamo start&quot;     start program = &quot;/etc/init.d/dynamo start&quot;
1086     stop program  = &quot;/etc/init.d/dynamo stop&quot;     stop program  = &quot;/etc/init.d/dynamo stop&quot;
1087     port 8840     port 8840
1088     every 2 cycle</PRE>     every 2 cycle</pre>
1089  <P>Here is an example where we group together two database entries.  <p>Here is an example where we group together two database entries.
1090  The autostart statement is also illustrated in the first entry and  The mode statement is also illustrated in the first entry and
1091  have the effect that monit will not try to (re)start this program  have the effect that monit will not try to (re)start this program
1092  if it is not running:</P>  if it is not running:</p>
1093  <PRE>  <pre>
1094   check sybase with pidfile /var/run/sybase.pid   check sybase with pidfile /var/run/sybase.pid
1095     start program = &quot;/etc/init.d/sybase start&quot;     start program = &quot;/etc/init.d/sybase start&quot;
1096     stop program  = &quot;/etc/init.d/sybase stop&quot;     stop program  = &quot;/etc/init.d/sybase stop&quot;
1097     autostart no     mode passive
1098     group database</PRE>     group database</pre>
1099  <PRE>  <pre>
1100   check oracle with pidfile /var/run/oracle.pid   check oracle with pidfile /var/run/oracle.pid
1101     start program = &quot;/etc/init.d/oracle start&quot;     start program = &quot;/etc/init.d/oracle start&quot;
1102     stop program  = &quot;/etc/init.d/oracle stop&quot;     stop program  = &quot;/etc/init.d/oracle stop&quot;
1103     autostart yes # Not necessary really, since this is the default     mode active # Not necessary really, since this is the default
1104     port 9001     port 9001
1105     alert bofh@foo.bar     alert bofh@foo.bar
1106     group database</PRE>     group database</pre>
1107  <P>Here is an example to show the usage of the resource checks. It  <p>Here is an example to show the usage of the resource checks. It
1108  will send an alert when the CPU usage of the http daemon and it's  will send an alert when the CPU usage of the http daemon and it's
1109  child processes raises beyond 60% for over two cycles.  It is  child processes raises beyond 60% for over two cycles.  It is
1110  restarted when the CPU usage it over 80% for five cycles, the  restarted when the CPU usage it over 80% for five cycles, the
1111  memory usage over 100MiBfor five cycles or the load average is  memory usage over 100Mb for five cycles or the load average is
1112  beyond 10 for 8 cycles:</P>  beyond 10 for 8 cycles:</p>
1113  <PRE>  <pre>
1114   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1115     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
1116     stop program  = &quot;/etc/init.d/httpd stop&quot;     stop program  = &quot;/etc/init.d/httpd stop&quot;
1117     if cpuusage &gt; 60.0 for 2 cycles then alert     if cpuusage &gt; 60.0 for 2 cycles then alert
1118     if cpuusage &gt; 80.0 for 5 cycles then restart     if cpuusage &gt; 80.0 for 5 cycles then restart
1119     if memkbyte &gt; 100000 for 5 cycles then stop     if memkbyte &gt; 100000 for 5 cycles then stop
1120     if loadavg(5min) greater than 10.0 for 8 cycles then stop</PRE>     if loadavg(5min) greater than 10.0 for 8 cycles then stop</pre>
1121  <P>In this example we demonstrate usage of the extended alert  <p>In this example we demonstrate usage of the extended alert
1122  statement:</P>  statement:</p>
1123  <PRE>  <pre>
1124   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1125     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
1126     stop program  = &quot;/etc/init.d/httpd stop&quot;     stop program  = &quot;/etc/init.d/httpd stop&quot;
# Line 977  statement:</P> Line 1131  statement:</P>
1131       with mail-format {       with mail-format {
1132                from:     bofh@$HOST                from:     bofh@$HOST
1133                subject:  apache $EVENT                subject:  apache $EVENT
1134                message:  This event occurred on $HOST at $DATE.</PRE>                message:  This event occurred on $HOST at $DATE.</pre>
1135  <PRE>  <pre>
1136                Your faithful employee,                Your faithful employee,
1137                monit                monit
1138       }       }
1139     timeout (3, 5)     timeout (3, 5)
1140     group server</PRE>     group server</pre>
1141  <P>Finally an example with all statements:</P>  <p>In this example, we demonstrate usage of the depend
1142  <PRE>  statement. In this case, we want to start oracle and
1143    apache. However, we've set up apache to use oracle as
1144    a backend, and if oracle is restarted, apache must be
1145    restarted as well.</p>
1146    <pre>
1147     check oracle with pidfile /var/run/oracle.pid
1148       start program = &quot;/etc/init.d/oracle start&quot;
1149       stop program  = &quot;/etc/init.d/oracle stop&quot;
1150       port 9001
1151       depend apache</pre>
1152    <pre>
1153     check apache with pidfile /var/run/httpd.pid
1154       start program = &quot;/etc/init.d/httpd start&quot;
1155       stop  program = &quot;/etc/init.d/httpd stop&quot;</pre>
1156    <p>In the next example, we have a another program, webfoo, that
1157    has been added and requires that it be restarted should apache
1158    be restarted.</p>
1159    <pre>
1160     check oracle with pidfile /var/run/oracle.pid
1161       start program = &quot;/etc/init.d/oracle start&quot;
1162       stop program  = &quot;/etc/init.d/oracle stop&quot;
1163       port 9001
1164       depend apache</pre>
1165    <pre>
1166     check apache with pidfile /var/run/httpd.pid
1167       start program = &quot;/etc/init.d/httpd start&quot;
1168       stop  program = &quot;/etc/init.d/httpd stop&quot;
1169       depend webfoo</pre>
1170    <pre>
1171     check webfoo with pidfile /var/run/webfoo.pid
1172       start program = &quot;/etc/init.d/webfoo start&quot;
1173       stop  program = &quot;/etc/init.d/webfoo stop&quot;</pre>
1174    <p>Next, we have 2 programs oracle-import and oracle-export
1175    that need to be restarted if oracle is restarted, but are
1176    independent of each other.</p>
1177    <pre>
1178     check oracle with pidfile /var/run/oracle.pid
1179       start program = &quot;/etc/init.d/oracle start&quot;
1180       stop program  = &quot;/etc/init.d/oracle stop&quot;
1181       port 9001
1182       depend oracle-import
1183       depend oracle-export</pre>
1184    <pre>
1185     check oracle-import with pidfile /var/run/oracle-import.pid
1186       start program = &quot;/etc/init.d/oracle-import start&quot;
1187       stop  program = &quot;/etc/init.d/oracle-import stop&quot;</pre>
1188    <pre>
1189     check oracle-export with pidfile /var/run/oracle-export.pid
1190       start program = &quot;/etc/init.d/oracle-export start&quot;
1191       stop  program = &quot;/etc/init.d/oracle-export stop&quot;</pre>
1192    <p>Finally an example with all statements:</p>
1193    <pre>
1194   check apache with pidfile /var/run/httpd.pid   check apache with pidfile /var/run/httpd.pid
1195     group server     group server
1196     start program = &quot;/etc/init.d/httpd start&quot;     start program = &quot;/etc/init.d/httpd start&quot;
# Line 1004  statement:</P> Line 1209  statement:</P>
1209     alert bofh@bar on { restart, timeout } with     alert bofh@bar on { restart, timeout } with
1210       mail-format { from: monit@foo.bar.no }       mail-format { from: monit@foo.bar.no }
1211     every 2 cycles     every 2 cycles
1212     autostart yes</PRE>     mode active
1213  <P>Note; only the <STRONG>check-</STRONG> and <STRONG>pidfile statement</STRONG> are mandatory,     depend webfoo</pre>
1214    <p>Note; only the <strong>check-</strong> and <strong>pidfile statement</strong> are mandatory,
1215  the other statements are optional and the order of the optional  the other statements are optional and the order of the optional
1216  statements is not important.</P>  statements is not important.</p>
1217  <P>  <p>
1218  <HR>  </p>
1219  <H1><A NAME="files">FILES</A></H1>  <hr />
1220  <P><EM>~/.monitrc</EM>    <h1><a name="files">FILES</a></h1>
1221     Default run control file</P>  <p><em>~/.monitrc</em>  
1222  <P><EM>./monitrc</EM>       Default run control file</p>
1223    <p><em>./monitrc</em>  
1224     If the control file is not found in the default     If the control file is not found in the default
1225     location, and the current working directory     location, and the current working directory
1226     contains a <EM>monitrc</EM> file, this file is used     contains a <em>monitrc</em> file, this file is used
1227     instead.</P>     instead.</p>
1228  <P><EM>~/.monitrc.pid</EM>  <p><em>/etc/monitrc</em>
1229       If the control file is not found in either of the
1230       previous two locations, and /etc contains a
1231       <em>monitrc</em> file, this file will be used instead.</p>
1232    <p><em>~/.monitrc.pid</em>
1233     Lock file to help prevent concurrent runs (non-root     Lock file to help prevent concurrent runs (non-root
1234     mode).</P>     mode).</p>
1235  <P><EM>/var/run/monit.pid</EM>  <p><em>/var/run/monit.pid</em>
1236     Lock file to help prevent concurrent runs (root mode,     Lock file to help prevent concurrent runs (root mode,
1237     Linux systems).</P>     Linux systems).</p>
1238  <P><EM>/etc/monit.pid</EM>  <p><em>/etc/monit.pid</em>
1239     Lock file to help prevent concurrent runs (root mode,     Lock file to help prevent concurrent runs (root mode,
1240     systems without /var/run).</P>     systems without /var/run).</p>
1241  <P>  <p>
1242  <HR>  </p>
1243  <H1><A NAME="signals">SIGNALS</A></H1>  <hr />
1244  <P>If a monit daemon is running, SIGUSR1 wakes it up from its sleep  <h1><a name="signals">SIGNALS</a></h1>
1245    <p>If a monit daemon is running, SIGUSR1 wakes it up from its sleep
1246  phase and forces a poll of all processes. SIGTERM will gracefully  phase and forces a poll of all processes. SIGTERM will gracefully
1247  terminate a monit daemon. This signal is sent to a monit daemon  terminate a monit daemon. This signal is sent to a monit daemon
1248  if monit is started with the <EM>quit</EM> action argument.</P>  if monit is started with the <em>quit</em> action argument.</p>
1249  <P>Running monit in foreground while a background monit daemon is  <p>Running monit in foreground while a background monit daemon is
1250  running will wake up the daemon.</P>  running will wake up the daemon.</p>
1251  <P>  <p>
1252  <HR>  </p>
1253  <H1><A NAME="notes">NOTES</A></H1>  <hr />
1254  <P>This is a very silent program. Use the -v switch if you want to  <h1><a name="notes">NOTES</a></h1>
1255  see what monit is doing, and tail -f the logfile.</P>  <p>This is a very silent program. Use the -v switch if you want to
1256  <P>The syntax (and parser) of the control file is inspired by Eric  see what monit is doing, and tail -f the logfile.</p>
1257    <p>The syntax (and parser) of the control file is inspired by Eric
1258  S. Raymond et al. excellent fetchmail program. Some portions of  S. Raymond et al. excellent fetchmail program. Some portions of
1259  this man page does also receive inspiration from the same  this man page does also receive inspiration from the same
1260  authors.</P>  authors.</p>
1261  <P>  <p>
1262  <HR>  </p>
1263  <H1><A NAME="authors">AUTHORS</A></H1>  <hr />
1264  <P>Jan-Henrik Haukeland &lt;<A HREF="mailto:hauk@tildeslash.com">hauk@tildeslash.com</A>&gt;,  <h1><a name="authors">AUTHORS</a></h1>
1265  Martin Pala &lt;<A HREF="mailto:martin.pala@hq.iol.cz">martin.pala@hq.iol.cz</A>&gt;,  <p>Jan-Henrik Haukeland &lt;<a href="mailto:hauk@tildeslash.com">hauk@tildeslash.com</a>&gt;,
1266  Christian Hopp &lt;<A HREF="mailto:chopp@iei.tu-clausthal.de">chopp@iei.tu-clausthal.de</A>&gt;,  Martin Pala &lt;<a href="mailto:martin.pala@hq.iol.cz">martin.pala@hq.iol.cz</a>&gt;,
1267  Rory Toma &lt;<A HREF="mailto:rory@digeo.com">rory@digeo.com</A>&gt;,  Christian Hopp &lt;<a href="mailto:chopp@iei.tu-clausthal.de">chopp@iei.tu-clausthal.de</a>&gt;,
1268  Thomas Oppel &lt;<A HREF="mailto:oppel@kbis.de">oppel@kbis.de</A>&gt;</P>  Rory Toma &lt;<a href="mailto:rory@digeo.com">rory@digeo.com</a>&gt;,
1269  <P>See also <A HREF="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</A></P>  Thomas Oppel &lt;<a href="mailto:oppel@kbis.de">oppel@kbis.de</a>&gt;</p>
1270  <P>  <p>See also <a href="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</a>
1271  <HR>  
1272  <H1><A NAME="copyright">COPYRIGHT</A></H1>  </p>
1273  <P>Copyright (C) 2000-2002 by Contributors to the monit codebase. All  <p>
1274    </p>
1275    <hr />
1276    <h1><a name="copyright">COPYRIGHT</a></h1>
1277    <p>Copyright (C) 2000-2002 by Contributors to the monit codebase. All
1278  Rights Reserved. This product is distributed in the hope that it  Rights Reserved. This product is distributed in the hope that it
1279  will be useful, but WITHOUT any warranty; without even the  will be useful, but WITHOUT any warranty; without even the
1280  implied warranty of MERCHANTABILITY or FITNESS for a particular  implied warranty of MERCHANTABILITY or FITNESS for a particular
1281  purpose.</P>  purpose.
1282  <P>  
1283  <HR>  </p>
1284  <H1><A NAME="see also">SEE ALSO</A></H1>  <p>
1285  <P>GNU text utilities;  <CODE>md5sum(1)</CODE></P>  </p>
1286    <hr />
1287    <h1><a name="see_also">SEE ALSO</a></h1>
1288    <p>GNU text utilities;  <code>md5sum(1)</code>
1289    
1290    
1291    </p>
1292    
1293  </BODY>  </body>
1294    
1295  </HTML>  </html>

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26