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:root@localhost" /> |
6 |
|
</head> |
7 |
|
|
8 |
<BODY BGCOLOR="#FFFFFF"> |
<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 |
<UL> |
<ul> |
27 |
|
|
28 |
<LI><A HREF="#monit lock file">monit lock file</A></LI> |
<li><a href="#monit_lock_file">monit lock file</a></li> |
29 |
</UL> |
</ul> |
30 |
|
|
31 |
<LI><A HREF="#init support">INIT SUPPORT</A></LI> |
<li><a href="#init_support">INIT SUPPORT</a></li> |
32 |
<LI><A HREF="#group support">GROUP SUPPORT</A></LI> |
<li><a href="#group_support">GROUP SUPPORT</a></li> |
33 |
<LI><A HREF="#monitoring mode selection">MONITORING MODE SELECTION</A></LI> |
<li><a href="#monitoring_mode_selection">MONITORING MODE SELECTION</a></li> |
34 |
<LI><A HREF="#alert messages">ALERT MESSAGES</A></LI> |
<ul> |
35 |
<UL> |
|
36 |
|
<li><a href="#monit_with_heartbeat">Monit with Heartbeat</a></li> |
37 |
<LI><A HREF="#setting a global mail format">Setting a global mail format</A></LI> |
</ul> |
38 |
</UL> |
|
39 |
|
<li><a href="#alert_messages">ALERT MESSAGES</a></li> |
40 |
<LI><A HREF="#program timeout">PROGRAM TIMEOUT</A></LI> |
<ul> |
41 |
<LI><A HREF="#resource testing">RESOURCE TESTING</A></LI> |
|
42 |
<LI><A HREF="#timestamp testing">TIMESTAMP TESTING</A></LI> |
<li><a href="#setting_a_global_mail_format">Setting a global mail format</a></li> |
43 |
<LI><A HREF="#connection testing">CONNECTION TESTING</A></LI> |
</ul> |
44 |
<LI><A HREF="#monit httpd">MONIT HTTPD</A></LI> |
|
45 |
<UL> |
<li><a href="#program_timeout">PROGRAM TIMEOUT</a></li> |
46 |
|
<li><a href="#resource_testing">RESOURCE TESTING</a></li> |
47 |
<LI><A HREF="#monit httpd authentication">Monit HTTPD Authentication</A></LI> |
<li><a href="#timestamp_testing">TIMESTAMP TESTING</a></li> |
48 |
</UL> |
<li><a href="#connection_testing">CONNECTION TESTING</a></li> |
49 |
|
<li><a href="#monit_httpd">MONIT HTTPD</a></li> |
50 |
<LI><A HREF="#md5 checksum">MD5 CHECKSUM</A></LI> |
<ul> |
51 |
<LI><A HREF="#dependency checking">DEPENDENCY CHECKING</A></LI> |
|
52 |
<LI><A HREF="#the run control file">THE RUN CONTROL FILE</A></LI> |
<li><a href="#monit_httpd_authentication">Monit HTTPD Authentication</a></li> |
53 |
<UL> |
</ul> |
54 |
|
|
55 |
<LI><A HREF="#run control syntax">Run Control Syntax</A></LI> |
<li><a href="#md5_checksum">MD5 CHECKSUM</a></li> |
56 |
<LI><A HREF="#configuration examples">CONFIGURATION EXAMPLES</A></LI> |
<li><a href="#dependency_checking">DEPENDENCY CHECKING</a></li> |
57 |
</UL> |
<li><a href="#the_run_control_file">THE RUN CONTROL FILE</a></li> |
58 |
|
<ul> |
59 |
<LI><A HREF="#files">FILES</A></LI> |
|
60 |
<LI><A HREF="#signals">SIGNALS</A></LI> |
<li><a href="#run_control_syntax">Run Control Syntax</a></li> |
61 |
<LI><A HREF="#notes">NOTES</A></LI> |
<li><a href="#configuration_examples">CONFIGURATION EXAMPLES</a></li> |
62 |
<LI><A HREF="#authors">AUTHORS</A></LI> |
</ul> |
63 |
<LI><A HREF="#copyright">COPYRIGHT</A></LI> |
|
64 |
<LI><A HREF="#see also">SEE ALSO</A></LI> |
<li><a href="#files">FILES</a></li> |
65 |
</UL> |
<li><a href="#signals">SIGNALS</a></li> |
66 |
|
<li><a href="#notes">NOTES</a></li> |
67 |
|
<li><a href="#authors">AUTHORS</a></li> |
68 |
|
<li><a href="#copyright">COPYRIGHT</a></li> |
69 |
|
<li><a href="#see_also">SEE ALSO</a></li> |
70 |
|
</ul> |
71 |
<!-- INDEX END --> |
<!-- INDEX END --> |
72 |
|
|
73 |
<HR> |
<hr /> |
74 |
<P> |
<p> |
75 |
<H1><A NAME="name">NAME</A></H1> |
</p> |
76 |
<P>monit - system for monitoring programs</P> |
<h1><a name="name">NAME</a></h1> |
77 |
<P> |
<p>monit - system for monitoring programs</p> |
78 |
<HR> |
<p> |
79 |
<H1><A NAME="synopsis">SYNOPSIS</A></H1> |
</p> |
80 |
<P><STRONG>monit</STRONG> [options] {arguments}</P> |
<hr /> |
81 |
<P> |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
82 |
<HR> |
<p><strong>monit</strong> [options] {arguments}</p> |
83 |
<H1><A NAME="description">DESCRIPTION</A></H1> |
<p> |
84 |
<P><STRONG>monit</STRONG> is a utility for monitoring and managing daemons or |
</p> |
85 |
|
<hr /> |
86 |
|
<h1><a name="description">DESCRIPTION</a></h1> |
87 |
|
<p><strong>monit</strong> is a utility for monitoring and managing daemons or |
88 |
similar programs running on a Unix system; monit will start |
similar programs running on a Unix system; monit will start |
89 |
specified programs if they are not running and restart programs |
specified programs if they are not running and restart programs |
90 |
not responding.</P> |
not responding.</p> |
91 |
<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 |
92 |
or more programs at a specified interval.</P> |
or more programs at a specified interval.</p> |
93 |
<P> |
<p> |
94 |
<HR> |
</p> |
95 |
<H1><A NAME="general operation">GENERAL OPERATION</A></H1> |
<hr /> |
96 |
<P>The behavior of monit is controlled by command-line options |
<h1><a name="general_operation">GENERAL OPERATION</a></h1> |
97 |
<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 |
98 |
|
<em>and</em> a run control file, <em>~/.monitrc</em>, the syntax of which we |
99 |
describe in a later section. Command-line options override |
describe in a later section. Command-line options override |
100 |
<EM>.monitrc</EM> declarations.</P> |
<em>.monitrc</em> declarations.</p> |
101 |
<P>The following options are recognized by monit. It's recommended |
<p>The following options are recognized by monit. It's recommended |
102 |
that you set the log and daemon options in the control |
that you set the log and daemon options in the control |
103 |
<EM>.monitrc</EM> file.</P> |
<em>.monitrc</em> file.</p> |
104 |
<P> |
<p> |
105 |
<H2><A NAME="general options and arguments">General Options and Arguments</A></H2> |
</p> |
106 |
<P><STRONG>-c</STRONG> <EM>file</EM> |
<h2><a name="general_options_and_arguments">General Options and Arguments</a></h2> |
107 |
Use this control file</P> |
<p><strong>-c</strong> <em>file</em> |
108 |
<P><STRONG>-l</STRONG> <EM>logfile</EM> |
Use this control file</p> |
109 |
Print log information to this file.</P> |
<p><strong>-d</strong> <em>n</em> |
110 |
<P><STRONG>-p</STRONG> <EM>pidfile</EM> |
Run as a daemon once per <em>n</em> seconds</p> |
111 |
Use this lock file in daemon mode.</P> |
<p><strong>-g</strong> |
112 |
<P><STRONG>-d</STRONG> <EM>n</EM> |
Set group name for start, stop, restart and status</p> |
113 |
Run as a daemon once per <EM>n</EM> seconds</P> |
<p><strong>-l</strong> <em>logfile</em> |
114 |
<P><STRONG>-I</STRONG> |
Print log information to this file</p> |
115 |
Run from init (do not run in background)</P> |
<p><strong>-p</strong> <em>pidfile</em> |
116 |
<P><STRONG>-g</STRONG> |
Use this lock file in daemon mode</p> |
117 |
Set group name for start, stop, restart and status</P> |
<p><strong>-i</strong> |
118 |
<P><STRONG>-v</STRONG> |
Validate mode, startup in validate mode</p> |
119 |
Verbose mode, work noisy (diagnostic output)</P> |
<p><strong>-I</strong> |
120 |
<P><STRONG>-V</STRONG> |
Run from init (do not run in background)</p> |
121 |
Print version number and patchlevel</P> |
<p><strong>-t</strong> |
122 |
<P><STRONG>-h</STRONG> |
Configuration syntax testing mode</p> |
123 |
Print a help text</P> |
<p><strong>-v</strong> |
124 |
<P>In addition to the options above, monit can be started with one |
Verbose mode, work noisy (diagnostic output)</p> |
125 |
|
<p><strong>-V</strong> |
126 |
|
Print version number and patchlevel</p> |
127 |
|
<p><strong>-h</strong> |
128 |
|
Print a help text</p> |
129 |
|
<p>In addition to the options above, monit can be started with one |
130 |
of the following action arguments; monit will then execute the |
of the following action arguments; monit will then execute the |
131 |
action and exit without transforming itself to a deamon.</P> |
action and exit without transforming itself to a deamon.</p> |
132 |
<P><STRONG>start</STRONG> |
<p><strong>start</strong> |
133 |
Start all programs listed in the control file. If |
Start all programs listed in the control file. If |
134 |
the group option is set, only start the programs in |
the group option is set, only start the programs in |
135 |
the named group.</P> |
the named group.</p> |
136 |
<P><STRONG>start name</STRONG> |
<p><strong>start name</strong> |
137 |
Start the named program. The name must exist in the |
Start the named program. The name must exist in the |
138 |
monitrc file, after a <EM>check</EM> keyword. See also |
monitrc file, after a <em>check</em> keyword. See also |
139 |
the MONIT HTTPD section below.</P> |
the MONIT HTTPD section below.</p> |
140 |
<P><STRONG>stop</STRONG> |
<p><strong>stop</strong> |
141 |
Stop all programs listed in the control file. If |
Stop all programs listed in the control file. If |
142 |
the group option is set, only stop the programs in |
the group option is set, only stop the programs in |
143 |
the named group.</P> |
the named group.</p> |
144 |
<P><STRONG>stop name</STRONG> |
<p><strong>stop name</strong> |
145 |
Stop the named program. The name must exist in the |
Stop the named program. The name must exist in the |
146 |
monitrc file, after a <EM>check</EM> keyword. See also |
monitrc file, after a <em>check</em> keyword. See also |
147 |
the MONIT HTTPD section below.</P> |
the MONIT HTTPD section below.</p> |
148 |
<P><STRONG>restart</STRONG> |
<p><strong>reload</strong> |
149 |
|
Will reinitialize running monit daemon, specifically |
150 |
|
it will reread its configuration, close and reopen |
151 |
|
log files.</p> |
152 |
|
<p><strong>restart</strong> |
153 |
Stop and start all programs. If the group option is |
Stop and start all programs. If the group option is |
154 |
set, only restart the programs in the named group.</P> |
set, only restart the programs in the named group.</p> |
155 |
<P><STRONG>restart name</STRONG> |
<p><strong>restart name</strong> |
156 |
Restart the named program. The name must exist in |
Restart the named program. The name must exist in |
157 |
the monitrc file, after a <EM>check</EM> keyword. also |
the monitrc file, after a <em>check</em> keyword. also |
158 |
the MONIT HTTPD section below.</P> |
the MONIT HTTPD section below.</p> |
159 |
<P><STRONG>status</STRONG> |
<p><strong>status</strong> |
160 |
Print status information for each program. If the |
Print status information for each program. If the |
161 |
group option is set, only print the status for the |
group option is set, only print the status for the |
162 |
named group.</P> |
named group.</p> |
163 |
<P><STRONG>quit</STRONG> |
<p><strong>quit</strong> |
164 |
Kill monit daemon process</P> |
Kill monit daemon process</p> |
165 |
<P><STRONG>validate</STRONG> |
<p><strong>validate</strong> |
166 |
Check all programs and start the ones not running. |
Check all programs and start the ones not running. |
167 |
Also if a program indicates (in the control file) |
Also if a program indicates (in the control file) |
168 |
that it's listening on a port number, although |
that it's listening on a port number, although |
169 |
monit cannot connect to the port, then restart the |
monit cannot connect to the port, then restart the |
170 |
program. This action is also the default |
program. This action is also the default |
171 |
behavior when monit runs in daemon mode.</P> |
behavior when monit runs in daemon mode.</p> |
172 |
<P> |
<p> |
173 |
<HR> |
</p> |
174 |
<H1><A NAME="logging">LOGGING</A></H1> |
<hr /> |
175 |
<P>monit will log status and error messages to a log file. If |
<h1><a name="logging">LOGGING</a></h1> |
176 |
<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 |
177 |
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 |
178 |
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 |
179 |
|
will use the <strong>syslog</strong> system daemon for logging messages. To |
180 |
turn off logging, simply do not set the logfile in the control |
turn off logging, simply do not set the logfile in the control |
181 |
file (and of course, do not use the -l switch)</P> |
file (and of course, do not use the -l switch)</p> |
182 |
<P> |
<p> |
183 |
<HR> |
</p> |
184 |
<H1><A NAME="daemon mode">DAEMON MODE</A></H1> |
<hr /> |
185 |
<P>The <EM>-d interval</EM> option runs monit in daemon mode. You must |
<h1><a name="daemon_mode">DAEMON MODE</a></h1> |
186 |
|
<p>The <em>-d interval</em> option runs monit in daemon mode. You must |
187 |
specify a numeric argument which is a polling interval in |
specify a numeric argument which is a polling interval in |
188 |
seconds.</P> |
seconds.</p> |
189 |
<P>In daemon mode, monit puts itself in the background and runs |
<p>In daemon mode, monit puts itself in the background and runs |
190 |
continously, monitoring each specified program and then sleeping |
continously, monitoring each specified program and then sleeping |
191 |
for the given polling interval.</P> |
for the given polling interval.</p> |
192 |
<PRE> |
<pre> |
193 |
Simply invoking</PRE> |
Simply invoking</pre> |
194 |
<PRE> |
<pre> |
195 |
monit -d 300</PRE> |
monit -d 300</pre> |
196 |
<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 |
197 |
5 minutes.</P> |
5 minutes.</p> |
198 |
<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 |
199 |
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 |
200 |
seconds. If you do this, monit will always start in daemon mode |
seconds. If you do this, monit will always start in daemon mode |
201 |
(as long as no action arguments are given).</P> |
(as long as no action arguments are given).</p> |
202 |
<P>Only one daemon process is permitted per user; in daemon mode, |
<p>Only one daemon process is permitted per user; in daemon mode, |
203 |
monit makes a per-user lockfile to guarantee this.</P> |
monit makes a per-user lockfile to guarantee this.</p> |
204 |
<P>Calling monit with a daemon in the background sends a wakeup |
<p>Calling monit with a daemon in the background sends a wakeup |
205 |
signal to the daemon, forcing it to check programs immediately.</P> |
signal to the daemon, forcing it to check programs immediately.</p> |
206 |
<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 |
207 |
of waking it up.</P> |
of waking it up.</p> |
208 |
<P>If you touch or change the <EM>.monitrc</EM> file while monit is |
<p> |
209 |
running in daemon mode, this will be detected at the beginning of |
</p> |
210 |
the next poll cycle. When a changed <EM>.monitrc</EM> is detected, |
<h2><a name="monit_lock_file">monit lock file</a></h2> |
211 |
monit rereads it and reinitialize itself. Note also that if you |
<p>monit utilize a lock file to prevent concurrent runs in daemon |
|
break the <EM>.monitrc</EM> file's syntax, the monit daemon will exit |
|
|
after logging the appropriate error message.</P> |
|
|
<P> |
|
|
<H2><A NAME="monit lock file">monit lock file</A></H2> |
|
|
<P>monit utilize a lock file to prevent concurrent runs in daemon |
|
212 |
mode. That is, only one monit daemon is permitted per user. The |
mode. That is, only one monit daemon is permitted per user. The |
213 |
lock file contains the process id (pid) from the current running |
lock file contains the process id (pid) from the current running |
214 |
monit daemon. If monit is run by the root user the location of |
monit daemon. If monit is run by the root user the location of |
215 |
the lock file is either <EM>/var/run/monit.pid</EM> or |
the lock file is either <em>/var/run/monit.pid</em> or |
216 |
<EM>/etc/monit.pid</EM> depending on the operating system. For a |
<em>/etc/monit.pid</em> depending on the operating system. For a |
217 |
non-root user the location of the lock file is |
non-root user the location of the lock file is |
218 |
<EM>$HOME/.monit.pid</EM>. The lock file is removed when a monit daemon |
<em>$HOME/.monit.pid</em>. The lock file is removed when a monit daemon |
219 |
is stopped.</P> |
is stopped.</p> |
220 |
<P>Normally it's not necessary to consider the location of the lock |
<p>Normally it's not necessary to consider the location of the lock |
221 |
file but in certain very special situations, you may need to |
file but in certain very special situations, you may need to |
222 |
control the location. For instance if you run monit as root on |
control the location. For instance if you run monit as root on |
223 |
two different machines but with the same file system you will |
two different machines but with the same file system you will |
224 |
need to change the location of the monit lock file via the <EM>-p</EM> |
need to change the location of the monit lock file via the <em>-p</em> |
225 |
option. You can also set the location of the lock file on a more |
option. You can also set the location of the lock file on a more |
226 |
permanent basis via this global set-statement in a monitrc |
permanent basis via this global set-statement in a monitrc |
227 |
control file: (keywords are in capital)</P> |
control file: (keywords are in capital)</p> |
228 |
<PRE> |
<pre> |
229 |
SET PIDFILE {pidfile}</PRE> |
SET PIDFILE {pidfile}</pre> |
230 |
<P>For instance, <EM>set pidfile /run/monit.pid</EM>.</P> |
<p>For instance, <em>set pidfile /run/monit.pid</em>.</p> |
231 |
<P> |
<p> |
232 |
<HR> |
</p> |
233 |
<H1><A NAME="init support">INIT SUPPORT</A></H1> |
<hr /> |
234 |
<P>Monit can be run and controlled from <EM>init</EM>. In case monit |
<h1><a name="init_support">INIT SUPPORT</a></h1> |
235 |
crashes init will respawn a new monit process.</P> |
<p>Monit can be run and controlled from <em>init</em>. In case monit |
236 |
<P>You can use either the 'set init' statement in monit's |
crashes init will respawn a new monit process.</p> |
237 |
|
<p>You can use either the 'set init' statement in monit's |
238 |
configuration file or use the -I option from the command line. |
configuration file or use the -I option from the command line. |
239 |
Here's a sample /etc/inittab entry for monit:</P> |
Here's a sample /etc/inittab entry for monit:</p> |
240 |
<PRE> |
<pre> |
241 |
# Run monit in standard runlevels |
# Run monit in standard runlevels |
242 |
mo:2345:respawn:/usr/local/sbin/monit -Ic /etc/monitrc</PRE> |
mo:2345:respawn:/usr/local/sbin/monit -Ic /etc/monitrc</pre> |
243 |
<P>After you have modified init's configuration file, you can run |
<p>After you have modified init's configuration file, you can run |
244 |
the following command to re-examine /etc/inittab and start monit:</P> |
the following command to re-examine /etc/inittab and start monit:</p> |
245 |
<PRE> |
<pre> |
246 |
telinit q |
telinit q |
247 |
</PRE> |
|
248 |
<PRE> |
For systems without telinit:</pre> |
249 |
|
<pre> |
250 |
For systems without telinit:</PRE> |
kill -1 1</pre> |
251 |
<PRE> |
<p>Make sure that if you run monit from init, that you do not start |
252 |
kill -1 1</PRE> |
monit in your startup scripts as well.</p> |
253 |
<P>Make sure that if you run monit from init, that you do not start |
<p> |
254 |
monit in your startup scripts as well.</P> |
</p> |
255 |
<P> |
<hr /> |
256 |
<HR> |
<h1><a name="group_support">GROUP SUPPORT</a></h1> |
257 |
<H1><A NAME="group support">GROUP SUPPORT</A></H1> |
<p>Program entries in the control file, <em>monitrc</em>, can be grouped |
258 |
<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 |
259 |
together by the <EM>group</EM> statement. The syntax is simply (keyword |
in capital):</p> |
260 |
in capital):</P> |
<pre> |
261 |
<PRE> |
GROUP groupname</pre> |
262 |
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 |
|
263 |
entries together and manage them as a whole. Monit provides |
entries together and manage them as a whole. Monit provides |
264 |
functions to start, stop and restart a group of programs, like |
functions to start, stop and restart a group of programs, like |
265 |
so:</P> |
so:</p> |
266 |
<P>To start a group of programs:</P> |
<p>To start a group of programs:</p> |
267 |
<PRE> |
<pre> |
268 |
monit -g <groupname> start</PRE> |
monit -g <groupname> start</pre> |
269 |
<P>To stop a group of programs:</P> |
<p>To stop a group of programs:</p> |
270 |
<PRE> |
<pre> |
271 |
monit -g <groupname> stop</PRE> |
monit -g <groupname> stop</pre> |
272 |
<P>To restart a group of programs:</P> |
<p>To restart a group of programs:</p> |
273 |
<PRE> |
<pre> |
274 |
monit -g <groupname> restart</PRE> |
monit -g <groupname> restart</pre> |
275 |
<P>Show the status of a program group:</P> |
<p>Show the status of a program group:</p> |
276 |
<PRE> |
<pre> |
277 |
monit -g <groupname> status</PRE> |
monit -g <groupname> status</pre> |
278 |
<P> |
<p> |
279 |
<HR> |
</p> |
280 |
<H1><A NAME="monitoring mode selection">MONITORING MODE SELECTION</A></H1> |
<hr /> |
281 |
<P>Monit supports three monitoring modes per service: active, |
<h1><a name="monitoring_mode_selection">MONITORING MODE SELECTION</a></h1> |
282 |
|
<p>Monit supports three monitoring modes per service: active, |
283 |
passive and manual. See also the example section below for usage |
passive and manual. See also the example section below for usage |
284 |
of the mode statement.</P> |
of the mode statement.</p> |
285 |
<P>In <EM>active</EM> mode, monit will monitor a service and in case of |
<p>In <em>active</em> mode, monit will monitor a service and in case of |
286 |
problems monit will act and raise alerts, start, stop or restart |
problems monit will act and raise alerts, start, stop or restart |
287 |
the service. Active mode is the default mode.</P> |
the service. Active mode is the default mode.</p> |
288 |
<P>In <EM>passive</EM> mode, monit will passively monitor a service and |
<p>In <em>passive</em> mode, monit will passively monitor a service and |
289 |
specifically <STRONG>not</STRONG> try to fix a problem, but it will still raise |
specifically <strong>not</strong> try to fix a problem, but it will still raise |
290 |
alerts in case of a problem.</P> |
alerts in case of a problem.</p> |
291 |
<P>For clustered environments there is also a <EM>manual</EM> mode. In |
<p>For clustered environments there is also a <em>manual</em> mode. In |
292 |
this mode, monit will enter <EM>active</EM> mode only if a service was |
this mode, monit will enter <em>active</em> mode only if a service was |
293 |
started under monit's control, for example by:</P> |
started under monit's control, for example by:</p> |
294 |
<PRE> |
<pre> |
295 |
monit start sybase</PRE> |
monit start sybase</pre> |
296 |
<P>or</P> |
<p>or</p> |
297 |
<PRE> |
<pre> |
298 |
monit -g database start (for service group)</PRE> |
monit -g database start (for service group)</pre> |
299 |
<P>If the service wasn't started by monit or was stopped for example |
<p>If the service wasn't started by monit or was stopped for example |
300 |
by:</P> |
by:</p> |
301 |
<PRE> |
<pre> |
302 |
monit stop sybase</PRE> |
monit stop sybase</pre> |
303 |
<P>or</P> |
<p>or</p> |
304 |
<PRE> |
<pre> |
305 |
monit -g database stop (for service group)</PRE> |
monit -g database stop (for service group)</pre> |
306 |
<P>monit will not monitor the service at all. This allows for having |
<p>monit will not monitor the service at all. This allows for having |
307 |
services configured in monitrc and start it with monit only if it |
services configured in monitrc and start it with monit only if it |
308 |
should run. This could be used for building simple failsafe |
should run. This could be used for building simple failsafe |
309 |
clusters. For instance, using the <EM>heartbeat</EM> system |
clusters. For instance, using the <em>heartbeat</em> system |
310 |
(http://linux-ha.org/) to watch the health of nodes and in the |
(http://linux-ha.org/) to watch the health of nodes and in the |
311 |
case of one machine failure start services on a secondary node.</P> |
case of one machine failure start services on a secondary node. |
312 |
<P>Appropriate scripts that can call monit to start/stop specific |
See section bellow for more informations.</p> |
313 |
services are needed on both nodes - typical usage:</P> |
<p> |
314 |
<PRE> |
</p> |
315 |
FILE DESCRIPTION |
<h2><a name="monit_with_heartbeat">Monit with Heartbeat</a></h2> |
316 |
----------------------------------- |
<p>The first thing you have to do is install and configure |
317 |
/etc/inittab starts monit |
<em>heartbeat</em> (http://www.linux-ha.org/downloads) . |
318 |
/etc/rcS.d/S41heartbeat execute "monit start heartbeat" |
The Getting Started Guide is very usefull for this task |
319 |
/etc/init.d/monit-node1 execute "monit -g node1 start" |
(http://www.linux-ha.org/download/GettingStarted.html).</p> |
320 |
/etc/init.d/monit-node2 execute "monit -g node2 start"</PRE> |
<p><strong>Starting up a Node</strong></p> |
321 |
<P>This way hearbeat can easily control the cluster state and if one |
<p>This is the normal start sequence for a cluster-node. |
322 |
node fails, hearbeat will start monit-xxxxx on the running node |
With this sequence, there should be no error-case, which is not |
323 |
and monit is instructed to start the services of the failing node |
handled either by heartbeat or monit. For example, if monit |
324 |
and monitor them...</P> |
dies, initd restart it. If heatbeat dies, monit restart it. If |
325 |
<P> |
the node dies, heartbeat on the other node dedect it and restart |
326 |
<HR> |
the services there.</p> |
327 |
<H1><A NAME="alert messages">ALERT MESSAGES</A></H1> |
<pre> |
328 |
<P>monit will raise an email alert if:</P> |
1) initd starts monit with group local |
329 |
<PRE> |
2) monit starts heartbeat in local group |
330 |
|
3) heartbeat requests monit to start the node group |
331 |
|
4) monit starts the node group</pre> |
332 |
|
<p><strong>Monit <em>/etc/monitrc</em></strong></p> |
333 |
|
<p>This sample describe a cluster with 2 nodes. |
334 |
|
Services running on Node 1 are in group <em>node1</em>, Node 2 services |
335 |
|
are in <em>node2</em>.</p> |
336 |
|
<p>The local group entries are mode <em>active</em>, the node group |
337 |
|
entries are mode <em>manual</em> and controlled by heartbeat</p> |
338 |
|
<pre> |
339 |
|
# |
340 |
|
# local services on every host |
341 |
|
# |
342 |
|
# |
343 |
|
check heartbeat with pidfile /var/run/heartbeat.pid |
344 |
|
start program = "/etc/init.d/heartbeat start" |
345 |
|
stop program = "/etc/init.d/heartbeat start" |
346 |
|
mode active |
347 |
|
alert foo@bar |
348 |
|
group local |
349 |
|
# |
350 |
|
# |
351 |
|
check postfix with pidfile /var/spool/postfix/pid/master.pid |
352 |
|
start program = "/etc/init.d/postfix start" |
353 |
|
stop program = "/etc/init.d/postfix stop" |
354 |
|
mode active |
355 |
|
alert foo@bar |
356 |
|
group local |
357 |
|
# |
358 |
|
# node1 services |
359 |
|
# |
360 |
|
check apache with pidfile /var/apache/logs/httpd.pid |
361 |
|
start program = "/etc/init.d/apache start" |
362 |
|
stop program = "/etc/init.d/apache stop" |
363 |
|
depends named |
364 |
|
alert foo@bar |
365 |
|
mode manual |
366 |
|
group node1 |
367 |
|
# |
368 |
|
# |
369 |
|
check named with pidfile /var/tmp/named.pid |
370 |
|
start program = "/etc/init.d/named start" |
371 |
|
stop program = "/etc/init.d/named stop" |
372 |
|
alert foo@bar |
373 |
|
mode manual |
374 |
|
group node1 |
375 |
|
# |
376 |
|
# node2 services |
377 |
|
# |
378 |
|
check named-slave with pidfile /var/tmp/named-slave.pid |
379 |
|
start program = "/etc/init.d/named-slave start" |
380 |
|
stop program = "/etc/init.d/named-slave stop" |
381 |
|
mode manual |
382 |
|
alert foo@bar |
383 |
|
group node2 |
384 |
|
# |
385 |
|
# |
386 |
|
check squid with pidfile /var/squid/logs/squid.pid |
387 |
|
start program = "/etc/init.d/squid start" |
388 |
|
stop program = "/etc/init.d/squid stop" |
389 |
|
depends named-slave |
390 |
|
alert foo@bar |
391 |
|
mode manual |
392 |
|
group node2</pre> |
393 |
|
<p><strong>initd <em>/etc/inittab</em></strong></p> |
394 |
|
<p>Monit is started on both nodes with initd. You have to add a |
395 |
|
entry in <em>/etc/inittab</em> starting monit with the local group, |
396 |
|
where heartbeat is member of.</p> |
397 |
|
<pre> |
398 |
|
#/etc/inittab |
399 |
|
mo:2345:respawn:/usr/local/bin/monit -i -d 10 -c /etc/monitrc -g local</pre> |
400 |
|
<p><strong>heartbeat <em>/etc/ha.d/haresources</em></strong></p> |
401 |
|
<p>When heartbeat starts, heartbeat lookup for the node entry and |
402 |
|
start the script <em>/etc/init.d/monit-node1</em> or |
403 |
|
<em>/etc/init.d/monit-node2</em>. The script calls monit |
404 |
|
to start the node specific group.</p> |
405 |
|
<pre> |
406 |
|
# /etc/ha.d/haresources |
407 |
|
node1 IPaddr::172.16.100.1 monit-node1 |
408 |
|
node2 IPaddr::172.16.100.2 monit-node2</pre> |
409 |
|
<p><strong><em>/etc/init.d/monit-node1</em></strong></p> |
410 |
|
<pre> |
411 |
|
#!/bin/bash |
412 |
|
# |
413 |
|
# sample script for starting/stopping all services for node1 |
414 |
|
# |
415 |
|
prog="/usr/local/bin/monit -g node1" |
416 |
|
start() |
417 |
|
{ |
418 |
|
echo -n $"Starting $prog:" |
419 |
|
$prog start |
420 |
|
echo |
421 |
|
}</pre> |
422 |
|
<pre> |
423 |
|
stop() |
424 |
|
{ |
425 |
|
echo -n $"Stopping $prog:" |
426 |
|
$prog stop> |
427 |
|
echo |
428 |
|
} |
429 |
|
|
430 |
|
case "$1" in |
431 |
|
start) |
432 |
|
start;; |
433 |
|
stop) |
434 |
|
stop;; |
435 |
|
*) |
436 |
|
echo $"Usage: $0 {start|stop}" |
437 |
|
RETVAL=1 |
438 |
|
esac |
439 |
|
exit $RETVAL</pre> |
440 |
|
<p> |
441 |
|
</p> |
442 |
|
<hr /> |
443 |
|
<h1><a name="alert_messages">ALERT MESSAGES</a></h1> |
444 |
|
<p>monit will raise an email alert if:</p> |
445 |
|
<pre> |
446 |
o A program timed out |
o A program timed out |
447 |
o A program was restarted |
o A program was restarted |
448 |
o A program was stopped |
o A program was stopped |
450 |
o A resource statement match (see also the section RESOURCE |
o A resource statement match (see also the section RESOURCE |
451 |
TESTING below) |
TESTING below) |
452 |
o A checksum error occurred (see also the section MD5 CHECKSUM |
o A checksum error occurred (see also the section MD5 CHECKSUM |
453 |
below)</PRE> |
below)</pre> |
454 |
<P>More than one alert statement can be used in a process entry. |
<p>More than one alert statement can be used in a process entry. |
455 |
This means that you can send different emails to different |
This means that you can send different emails to different |
456 |
addresses. The full syntax for the alert statement is as |
addresses. The full syntax for the alert statement is as |
457 |
follows (keywords are in capital):</P> |
follows (keywords are in capital):</p> |
458 |
<PRE> |
<pre> |
459 |
ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</PRE> |
ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</pre> |
460 |
<P>Simply using:</P> |
<p>Simply using:</p> |
461 |
<PRE> |
<pre> |
462 |
alert foo@bar</PRE> |
alert foo@bar</pre> |
463 |
<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 |
464 |
timeout, restart, checksum, resource, stop or timestamp error |
timeout, restart, checksum, resource, stop or timestamp error |
465 |
occurs.</P> |
occurs.</p> |
466 |
<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 |
467 |
occurs for example a timeout or when a program is restarted, |
occurs for example a timeout or when a program is restarted, |
468 |
postfix the alert-statement respectively</P> |
postfix the alert-statement respectively</p> |
469 |
<PRE> |
<pre> |
470 |
alert foo@bar only on { timeout } or |
alert foo@bar only on { timeout } or |
471 |
alert foo@bar { timeout }</PRE> |
alert foo@bar { timeout }</pre> |
472 |
<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> |
473 |
<P>or</P> |
<p>or</p> |
474 |
<PRE> |
<pre> |
475 |
alert foo@bar { restart }</PRE> |
alert foo@bar { restart }</pre> |
476 |
<P>The same applies for a checksum error</P> |
<p>The same applies for a checksum error</p> |
477 |
<PRE> |
<pre> |
478 |
alert foo@bar { checksum }</PRE> |
alert foo@bar { checksum }</pre> |
479 |
<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 |
480 |
email addresses like:</P> |
email addresses like:</p> |
481 |
<PRE> |
<pre> |
482 |
alert foo@bar { restart, timeout, resource } |
alert foo@bar { restart, timeout, resource } |
483 |
alert security@bar on { checksum, stop } |
alert security@bar on { checksum, stop } |
484 |
alert manager@bar</PRE> |
alert manager@bar</pre> |
485 |
<P>This will send an alert message to foo@bar when a timeout, |
<p>This will send an alert message to foo@bar when a timeout, |
486 |
resource or restart occurs and a message to security@bar if a |
resource or restart occurs and a message to security@bar if a |
487 |
checksum error or stop occurs. And finally, a message to |
checksum error or stop occurs. And finally, a message to |
488 |
manager@bar whenever any error event occurs. |
manager@bar whenever any error event occurs. |
489 |
</P> |
</p> |
490 |
<PRE> |
<pre> |
491 |
|
|
492 |
The following alert-statement:</PRE> |
The following alert-statement:</pre> |
493 |
<PRE> |
<pre> |
494 |
|
|
495 |
alert foo@bar { timeout |
alert foo@bar { timeout |
496 |
restart |
restart |
497 |
checksum |
checksum |
498 |
resource |
resource |
499 |
stop |
stop |
500 |
timestamp }</PRE> |
timestamp }</pre> |
501 |
<P>is equivalent to:</P> |
<p>is equivalent to:</p> |
502 |
<PRE> |
<pre> |
503 |
alert foo@bar</PRE> |
alert foo@bar</pre> |
504 |
<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 |
505 |
restart, checksum, resource, stop or timestamp error occurs. (If |
restart, checksum, resource, stop or timestamp error occurs. (If |
506 |
the postfix variant is used, then note that the parenthesis are |
the postfix variant is used, then note that the parenthesis are |
507 |
<EM>mandatory</EM>).</P> |
<em>mandatory</em>).</p> |
508 |
<P>A restart alert is also sent <EM>if monit fails to execute</EM> a start |
<p>A restart alert is also sent <em>if monit fails to execute</em> a start |
509 |
or stop program for an entry. <STRONG>It is therefor strongly advised</STRONG> |
or stop program for an entry. <strong>It is therefor strongly advised</strong> |
510 |
that at least one alert statement register interest for restart |
that at least one alert statement register interest for restart |
511 |
alerts.</P> |
alerts.</p> |
512 |
<P>monit will provide a default mail message layout that is short |
<p>monit will provide a default mail message layout that is short |
513 |
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 |
514 |
by monit:</P> |
by monit:</p> |
515 |
<PRE> |
<pre> |
516 |
From: monit@tildeslash.com |
From: monit@tildeslash.com |
517 |
Subject: monit alert -- apache restarted |
Subject: monit alert -- apache restarted |
518 |
To: hauk@tildeslash.com |
To: hauk@tildeslash.com |
519 |
Date: Tue, 28 May 2002 20:42:30 +0200</PRE> |
Date: Tue, 28 May 2002 20:42:30 +0200</pre> |
520 |
<PRE> |
<pre> |
521 |
Program apache restarted</PRE> |
Program apache restarted</pre> |
522 |
<PRE> |
<pre> |
523 |
Date: Tue May 28 20:42:30 2002 |
Date: Tue May 28 20:42:30 2002 |
524 |
Host: www.tildeslash.com</PRE> |
Host: www.tildeslash.com</pre> |
525 |
<PRE> |
<pre> |
526 |
Your faithful employee, |
Your faithful employee, |
527 |
monit</PRE> |
monit</pre> |
528 |
<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 |
529 |
the optional <EM>mail-format</EM> statement. The syntax for this |
the optional <em>mail-format</em> statement. The syntax for this |
530 |
statement is as follows:</P> |
statement is as follows:</p> |
531 |
<PRE> |
<pre> |
532 |
mail-format { |
mail-format { |
533 |
from: monit@localhost |
from: monit@localhost |
534 |
subject: apache $EVENT at $DATE |
subject: apache $EVENT at $DATE |
545 |
* Where's the DIR command? |
* Where's the DIR command? |
546 |
* Why is my "rm" taking so long? |
* Why is my "rm" taking so long? |
547 |
* System coming down in 0 min ... |
* System coming down in 0 min ... |
548 |
}</PRE> |
}</pre> |
549 |
<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 |
550 |
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 |
551 |
address, but must be a proper formated mail address, on the form; |
address, but must be a proper formated mail address, on the form; |
552 |
name@domain. The keyword <EM>subject:</EM> is for the email subject |
name@domain. The keyword <em>subject:</em> is for the email subject |
553 |
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> |
554 |
keyword denotes the mail body. If used, this keyword should |
keyword denotes the mail body. If used, this keyword should |
555 |
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 |
556 |
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> |
557 |
<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 |
558 |
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 |
559 |
is using you can do:</P> |
is using you can do:</p> |
560 |
<PRE> |
<pre> |
561 |
alert foo@bar with mail-format { from: bofh@xyzzy.no }</PRE> |
alert foo@bar with mail-format { from: bofh@xyzzy.no }</pre> |
562 |
<P>From the previous example you will notice that 4 special |
<p>From the previous example you will notice that 4 special |
563 |
variables was used. If used they will be substituted into the |
variables was used. If used they will be substituted into the |
564 |
text with a special value:</P> |
text with a special value:</p> |
565 |
<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 |
566 |
are fixed and are, ``restarted'', ``timed out'', ``stopped and |
are fixed and are, ``restarted'', ``timed out'', ``stopped and |
567 |
''checksum error``</P> |
''checksum error``</p> |
568 |
<P><EM>$PROGRAM</EM> The program entry name in monitrc</P> |
<p><em>$PROGRAM</em> The program entry name in monitrc</p> |
569 |
<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> |
570 |
<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> |
571 |
<P> |
<p> |
572 |
<H2><A NAME="setting a global mail format">Setting a global mail format</A></H2> |
</p> |
573 |
<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> |
574 |
|
<p>Finally, it is possible to set a standard mail format with the |
575 |
following global set-statement (keywords are in capital): |
following global set-statement (keywords are in capital): |
576 |
</P> |
</p> |
577 |
<PRE> |
<pre> |
578 |
|
|
579 |
SET MAIL-FORMAT {mail-format}</PRE> |
SET MAIL-FORMAT {mail-format}</pre> |
580 |
<P>Format set with this statement will apply to every alert |
<p>Format set with this statement will apply to every alert |
581 |
statement that does <EM>not</EM> have its own specified mail-format. |
statement that does <em>not</em> have its own specified mail-format. |
582 |
This statement is most usefull for setting a default from address |
This statement is most usefull for setting a default from address |
583 |
for messages sent by monit, like so:</P> |
for messages sent by monit, like so:</p> |
584 |
<PRE> |
<pre> |
585 |
set mail-format { from: monit@foo.bar.no }</PRE> |
set mail-format { from: monit@foo.bar.no }</pre> |
586 |
<P> |
<p> |
587 |
<HR> |
</p> |
588 |
<H1><A NAME="program timeout">PROGRAM TIMEOUT</A></H1> |
<hr /> |
589 |
<P><STRONG>monit</STRONG> provides a program timeout mechanism for situations |
<h1><a name="program_timeout">PROGRAM TIMEOUT</a></h1> |
590 |
|
<p><strong>monit</strong> provides a program timeout mechanism for situations |
591 |
where a program simply refuses to start or respond over a longer |
where a program simply refuses to start or respond over a longer |
592 |
period. In cases like this, and particularly if monits poll-cycle |
period. In cases like this, and particularly if monits poll-cycle |
593 |
is low, monit will simply increase the machine load by trying to |
is low, monit will simply increase the machine load by trying to |
594 |
restart the program.</P> |
restart the program.</p> |
595 |
<P>The timeout mechanism monit provides is based on two variables, |
<p>The timeout mechanism monit provides is based on two variables, |
596 |
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 |
597 |
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 |
598 |
<EM>y</EM> poll-cycles (where <EM>x</EM> <= <EM>y</EM>) then monit will timeout and |
<em>y</em> poll-cycles (where <em>x</em> <= <em>y</em>) then monit will timeout and |
599 |
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 |
600 |
use the alert statement in conjunction with timeout, so if a |
use the alert statement in conjunction with timeout, so if a |
601 |
timeout occurs monit will send an alert notification. A legal |
timeout occurs monit will send an alert notification. A legal |
602 |
(but verbose) way to write a timeout statement for a program |
(but verbose) way to write a timeout statement for a program |
603 |
entry in the control file is:</P> |
entry in the control file is:</p> |
604 |
<PRE> |
<pre> |
605 |
timeout if 3 restarts within 3 cycles</PRE> |
timeout if 3 restarts within 3 cycles</pre> |
606 |
<P>The shorthand version is:</P> |
<p>The shorthand version is:</p> |
607 |
<PRE> |
<pre> |
608 |
timeout(3,3)</PRE> |
timeout(3,3)</pre> |
609 |
<P>Where the first digit is the number of program restarts, the |
<p>Where the first digit is the number of program restarts, the |
610 |
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 |
611 |
reached without a timeout, the program start-counter is reset to |
reached without a timeout, the program start-counter is reset to |
612 |
zero. This provides some granularity to catch expectional cases |
zero. This provides some granularity to catch expectional cases |
613 |
and do a program timeout, but to let occasional program restarts |
and do a program timeout, but to let occasional program restarts |
614 |
happen without having an accumulated timeout.</P> |
happen without having an accumulated timeout.</p> |
615 |
<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 |
616 |
statement to notify the responsible administrator. Such as: |
statement to notify the responsible administrator. Such as: |
617 |
</P> |
</p> |
618 |
<PRE> |
<pre> |
619 |
|
|
620 |
timeout(3, 5) and alert bofh@foo.bar on { timeout }</PRE> |
timeout(3, 5) and alert bofh@foo.bar on { timeout }</pre> |
621 |
<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 |
622 |
start program' from the command line. This will remove the |
start program' from the command line. This will remove the |
623 |
timeout lock in the daemon and make the daemon start and check |
timeout lock in the daemon and make the daemon start and check |
624 |
the program again.</P> |
the program again.</p> |
625 |
<P> |
<p> |
626 |
<HR> |
</p> |
627 |
<H1><A NAME="resource testing">RESOURCE TESTING</A></H1> |
<hr /> |
628 |
<P>Monit can examine how much system resources a service or the |
<h1><a name="resource_testing">RESOURCE TESTING</a></h1> |
629 |
system is using.</P> |
<p>Monit can examine how much system resources a service or the |
630 |
<P>Depending on this indicator services can be stopped or restarted |
system is using.</p> |
631 |
|
<p>Depending on this indicator services can be stopped or restarted |
632 |
and alerts can be generated. Thus it is possible to utilize |
and alerts can be generated. Thus it is possible to utilize |
633 |
systems which are idle and to spare system under high load.</P> |
systems which are idle and to spare system under high load.</p> |
634 |
<P>The full syntax for the resource-statements used for resource |
<p>The full syntax for the resource-statements used for resource |
635 |
testing is as follows (keywords are in capital and optional |
testing is as follows (keywords are in capital and optional |
636 |
statements in [brackets]),</P> |
statements in [brackets]),</p> |
637 |
<PRE> |
<pre> |
638 |
resource operator value [cycles] action</PRE> |
resource operator value [cycles] action</pre> |
639 |
<P><EM>resource</EM> is a choice of ``CPUUSAGE'', ``MEMUSAGE'', ``MEMKBYTE'', |
<p><em>resource</em> is a choice of ``CPUUSAGE'', ``MEMUSAGE'', ``MEMKBYTE'', |
640 |
``LOADAVG([1min|5min|15min])'':</P> |
``LOADAVG([1min|5min|15min])'':</p> |
641 |
<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 |
642 |
parts of hundred (percent). This resource <EM>value</EM> is a floating |
parts of hundred (percent). This resource <em>value</em> is a floating |
643 |
point number. For instance, 60.0.</P> |
point number. For instance, 60.0.</p> |
644 |
<P>MEMUSAGE is the memory usage of the process in parts of hundred |
<p>MEMUSAGE is the memory usage of the process in parts of hundred |
645 |
(percent). This resource <EM>value</EM> is also a floating point |
(percent). This resource <em>value</em> is also a floating point |
646 |
number.</P> |
number.</p> |
647 |
<P>MEMKBYTE is the memory amount of the process in KiB (1024 |
<p>MEMKBYTE is the memory amount of the process in KiB (1024 |
648 |
byte). This resource <EM>value</EM> is an integer number.</P> |
byte). This resource <em>value</em> is an integer number.</p> |
649 |
<P><CODE>LOADAVG([1min|5min|15min])</CODE> refers to the system's load average. |
<p><code>LOADAVG([1min|5min|15min])</code> refers to the system's load average. |
650 |
The load average is the number of processes in the system run |
The load average is the number of processes in the system run |
651 |
queue averaged over the specified time period. This resource |
queue averaged over the specified time period. This resource |
652 |
<EM>value</EM> is again a floating point number.</P> |
<em>value</em> is again a floating point number.</p> |
653 |
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
654 |
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
655 |
``equal'', ``notequal'' in human readable form (if not specified, |
``equal'', ``notequal'' in human readable form (if not specified, |
656 |
default is EQUAL).</P> |
default is EQUAL).</p> |
657 |
<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 |
658 |
has to be true in order to start an action. If <EM>cycles</EM> is |
has to be true in order to start an action. If <em>cycles</em> is |
659 |
omitted then it is set to one.</P> |
omitted then it is set to one.</p> |
660 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'':</P> |
<p><em>action</em> is a choice of ``ALERT'', ``RESTART'', ``STOP'':</p> |
661 |
<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 |
662 |
of cycles has been reached.</P> |
of cycles has been reached.</p> |
663 |
<P>RESTART restarts the service in case the maximum number of cycles |
<p>RESTART restarts the service in case the maximum number of cycles |
664 |
has been reached.</P> |
has been reached.</p> |
665 |
<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 |
666 |
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 |
667 |
monit anymore nor restarted again later. You must explicit start |
monit anymore nor restarted again later. You must explicit start |
668 |
it again from the web interface or from the console, like: 'monit |
it again from the web interface or from the console, like: 'monit |
669 |
start apache' if you want the monit daemon to monitor the service |
start apache' if you want the monit daemon to monitor the service |
670 |
again.</P> |
again.</p> |
671 |
<P>To calculate the cycles, a counter is raised whenever the |
<p>To calculate the cycles, a counter is raised whenever the |
672 |
expression above is true and it is lowered whenever it is false |
expression above is true and it is lowered whenever it is false |
673 |
(but not below 0). All counters are reseted in case of a |
(but not below 0). All counters are reseted in case of a |
674 |
restart.</P> |
restart.</p> |
675 |
<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 |
676 |
beyond 50% for five cycles before restarting it, the following |
beyond 50% for five cycles before restarting it, the following |
677 |
expression could be used:</P> |
expression could be used:</p> |
678 |
<PRE> |
<pre> |
679 |
if cpuusage is greater than 50.0 for 5 cycles then restart</PRE> |
if cpuusage is greater than 50.0 for 5 cycles then restart</pre> |
680 |
<P>Or the short version without noise keywords:</P> |
<p>Or the short version without noise keywords:</p> |
681 |
<PRE> |
<pre> |
682 |
cpuusage > 50.0 5 restart</PRE> |
cpuusage > 50.0 5 restart</pre> |
683 |
<P>See also the example section below.</P> |
<p>See also the example section below.</p> |
684 |
<P> |
<p> |
685 |
<HR> |
</p> |
686 |
<H1><A NAME="timestamp testing">TIMESTAMP TESTING</A></H1> |
<hr /> |
687 |
<P>Monit can watch the timestamp of any file or directory associated |
<h1><a name="timestamp_testing">TIMESTAMP TESTING</a></h1> |
688 |
with a program.</P> |
<p>Monit can watch the timestamp of any file or directory associated |
689 |
<P>The full syntax for the timestamp statement is as follows |
with a program.</p> |
690 |
(keywords are in capital and optional statements in [brackets]):</P> |
<p>The full syntax for the timestamp statement is as follows |
691 |
<PRE> |
(keywords are in capital and optional statements in [brackets]):</p> |
692 |
TIMESTAMP object [operator] value [unit] action</PRE> |
<pre> |
693 |
<P><EM>object</EM> is a path to the associated file or directory to watch.</P> |
TIMESTAMP object [operator] value [unit] action</pre> |
694 |
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``GT'', |
<p><em>object</em> is a path to the associated file or directory to watch.</p> |
695 |
|
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``GT'', |
696 |
``LT'', ``EQ'', ``NE'' in shell sh notation and ``GREATER'', ``LESS'', |
``LT'', ``EQ'', ``NE'' in shell sh notation and ``GREATER'', ``LESS'', |
697 |
``EQUAL'', ``NOTEQUAL'' in human readable form (if not specified, |
``EQUAL'', ``NOTEQUAL'' in human readable form (if not specified, |
698 |
default is EQUAL).</P> |
default is EQUAL).</p> |
699 |
<P><EM>value</EM> is a time watermark.</P> |
<p><em>value</em> is a time watermark.</p> |
700 |
<P><EM>unit</EM> is either ``SECOND'', ``MINUTE'', ``HOUR'' or ``DAY'' (it is also |
<p><em>unit</em> is either ``SECOND'', ``MINUTE'', ``HOUR'' or ``DAY'' (it is also |
701 |
possible to use ``SECONDS'', ``MINUTES'', ``HOURS'', or ``DAYS'').</P> |
possible to use ``SECONDS'', ``MINUTES'', ``HOURS'', or ``DAYS'').</p> |
702 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'':</P> |
<p><em>action</em> is a choice of ``ALERT'', ``RESTART'', ``STOP'':</p> |
703 |
<PRE> |
<pre> |
704 |
o ALERT sends the user a timestamp alert.</PRE> |
o ALERT sends the user a timestamp alert.</pre> |
705 |
<PRE> |
<pre> |
706 |
o RESTART restarts the service.</PRE> |
o RESTART restarts the service.</pre> |
707 |
<PRE> |
<pre> |
708 |
o STOP stops the service. If monit stops a service it will not |
o STOP stops the service. If monit stops a service it will not |
709 |
be checked by monit anymore nor restarted again later. You |
be checked by monit anymore nor restarted again later. You |
710 |
must explicit start it again from the web interface or from |
must explicit start it again from the web interface or from |
711 |
the console, like: 'monit start apache' if you want the monit |
the console, like: 'monit start apache' if you want the monit |
712 |
daemon to monitor the service again.</PRE> |
daemon to monitor the service again.</pre> |
713 |
<P>The timestamp statement is useful for monitoring systems, that |
<p>The timestamp statement is useful for monitoring systems, that |
714 |
are able to report its state by changing the timestamp of certain |
are able to report its state by changing the timestamp of certain |
715 |
state files. For instance the <EM>iPlanet Messaging server stored |
state files. For instance the <em>iPlanet Messaging server stored |
716 |
process</EM> system update the timestamp of:</P> |
process</em> system update the timestamp of:</p> |
717 |
<PRE> |
<pre> |
718 |
o stored.ckp |
o stored.ckp |
719 |
o stored.lcu |
o stored.lcu |
720 |
o stored.per</PRE> |
o stored.per</pre> |
721 |
<P>whenever it runs tasks and if a task failed, the system keeps the |
<p>whenever it runs tasks and if a task failed, the system keeps the |
722 |
timestamp.</P> |
timestamp.</p> |
723 |
<P>To report stored problems you can use following statements:</P> |
<p>To report stored problems you can use following statements:</p> |
724 |
<PRE> |
<pre> |
725 |
if timestamp "/msg-foo/config/stored.ckp" > 1 minute then alert |
if timestamp "/msg-foo/config/stored.ckp" > 1 minute then alert |
726 |
if timestamp "/msg-foo/config/stored.lcu" > 5 minutes then alert |
if timestamp "/msg-foo/config/stored.lcu" > 5 minutes then alert |
727 |
if timestamp "/msg-foo/config/stored.per" > 1 hour then alert</PRE> |
if timestamp "/msg-foo/config/stored.per" > 1 hour then alert</pre> |
728 |
<P>or the equivalent less verbose form:</P> |
<p>or the equivalent less verbose form:</p> |
729 |
<PRE> |
<pre> |
730 |
timestamp "/msg-foo/config/stored.ckp" > 60 alert |
timestamp "/msg-foo/config/stored.ckp" > 60 alert |
731 |
timestamp "/msg-foo/config/stored.lcu" > 300 alert |
timestamp "/msg-foo/config/stored.lcu" > 300 alert |
732 |
timestamp "/msg-foo/config/stored.per" > 3600 alert</PRE> |
timestamp "/msg-foo/config/stored.per" > 3600 alert</pre> |
733 |
<P>As mentioned above, you can also use the timestamp statement for |
<p>As mentioned above, you can also use the timestamp statement for |
734 |
monitoring directories for changes. If files are added or removed |
monitoring directories for changes. If files are added or removed |
735 |
to/from a directory, its timestamp is changed:</P> |
to/from a directory, its timestamp is changed:</p> |
736 |
<PRE> |
<pre> |
737 |
if timestamp "/foo/directory" > 1 hour then alert</PRE> |
if timestamp "/foo/directory" > 1 hour then alert</pre> |
738 |
<P>or</P> |
<p>or</p> |
739 |
<PRE> |
<pre> |
740 |
if timestamp "/foo/secure/directory" < 1 hour then alert</PRE> |
if timestamp "/foo/secure/directory" < 1 hour then alert</pre> |
741 |
<P>The following example is a neat trick for restarting a process |
<p>The following example is a neat trick for restarting a process |
742 |
after a certain time. Sometimes this is a necessary workaround |
after a certain time. Sometimes this is a necessary workaround |
743 |
for some products, until the vendor fix a problem:</P> |
for some products, until the vendor fix a problem:</p> |
744 |
<PRE> |
<pre> |
745 |
if timestamp "/var/run/crappy_program.pid" > 7 days then restart</PRE> |
if timestamp "/var/run/crappy_program.pid" > 7 days then restart</pre> |
746 |
<P> |
<p> |
747 |
<HR> |
</p> |
748 |
<H1><A NAME="connection testing">CONNECTION TESTING</A></H1> |
<hr /> |
749 |
<P>Monit is able to perfom connection testing via networked ports |
<h1><a name="connection_testing">CONNECTION TESTING</a></h1> |
750 |
and via unix sockets.</P> |
<p>Monit is able to perfom connection testing via networked ports |
751 |
<P>If a program listens on one or more sockets, monit can connect to |
and via unix sockets.</p> |
752 |
|
<p>If a program listens on one or more sockets, monit can connect to |
753 |
the port (using either tcp or udp) and verify that the program |
the port (using either tcp or udp) and verify that the program |
754 |
will accept a connection and that it is possible to read and |
will accept a connection and that it is possible to read and |
755 |
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 |
756 |
is a problem with the socket i|o, monit will assume that |
is a problem with the socket i|o, monit will assume that |
757 |
something is wrong and restart the program. Additionally, if |
something is wrong and restart the program. Additionally, if |
758 |
monit is compiled with openssl support ssl forged network |
monit is compiled with openssl support ssl forged network |
759 |
services can be tested, too.</P> |
services can be tested, too.</p> |
760 |
<P>The full syntax for the port-statement used for connection |
<p>The full syntax for the port-statement used for connection |
761 |
testing is as follows (keywords are in capital and optional |
testing is as follows (keywords are in capital and optional |
762 |
statements in [brackets]) for networked ports,</P> |
statements in [brackets]) for networked ports,</p> |
763 |
<PRE> |
<pre> |
764 |
[HOST hostname] PORT number |
[HOST hostname] PORT number |
765 |
[TYPE {TCP|UDP|TCPSSL [CERTMD5 md5sum]}] |
[TYPE {TCP|UDP|TCPSSL [SSLAUTO|SSLV2|SSLV3|TLSV1] |
766 |
[PROTO(COL) {name} [REQUEST {"/path"}]]</PRE> |
[CERTMD5 md5sum] |
767 |
<P>or for unix sockets,</P> |
}] |
768 |
<PRE> |
[PROTO(COL) {name} [REQUEST {"/path"}]]</pre> |
769 |
|
<p>or for unix sockets,</p> |
770 |
|
<pre> |
771 |
UNIX(SOCKET) path [TYPE {TCP|UDP}] [PROTO(COL) {name} |
UNIX(SOCKET) path [TYPE {TCP|UDP}] [PROTO(COL) {name} |
772 |
[REQUEST {"/path"}]]</PRE> |
[REQUEST {"/path"}]]</pre> |
773 |
<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> |
774 |
<PRE> |
<pre> |
775 |
port 80</PRE> |
port 80</pre> |
776 |
<P>In this case the machine in question is assumed to be |
<p>In this case the machine in question is assumed to be |
777 |
<EM>localhost</EM> and monit will issue a tcp connection to localhost |
<em>localhost</em> and monit will issue a tcp connection to localhost |
778 |
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 |
779 |
with udp, you can specify this after the port-statement;</P> |
with udp, you can specify this after the port-statement;</p> |
780 |
<PRE> |
<pre> |
781 |
port 53 use type udp ('use' is a noise keyword)</PRE> |
port 53 use type udp ('use' is a noise keyword)</pre> |
782 |
<P>The <EM>TCPSSL</EM> statement accepts optionally the md5 sum of the |
<p>The <em>TCPSSL</em> statement accepts optionally the md5 sum of the |
783 |
server's certificate. The md5 sum is matched against the one |
server's certificate. The md5 sum is matched against the one |
784 |
delivered by the server. In case they do not match the |
delivered by the server. In case they do not match the |
785 |
connection test fails.</P> |
connection test fails. In case the ssl version independant |
786 |
<P>In case a server is listening to a unix socket called |
handshake is not working properly you can force a specific ssl |
787 |
/var/run/mysocket, the following statement can be used:</P> |
version, too.</p> |
788 |
<PRE> |
<p>In case a server is listening to a unix socket called |
789 |
unix /var/run/mysocket</PRE> |
/var/run/mysocket, the following statement can be used:</p> |
790 |
<P>If your machine answers for several virtual hosts you can prefix |
<pre> |
791 |
the port statement with a host-statement like so:</P> |
unix /var/run/mysocket</pre> |
792 |
<PRE> |
<p>If your machine answers for several virtual hosts you can prefix |
793 |
|
the port statement with a host-statement like so:</p> |
794 |
|
<pre> |
795 |
host www.sol.no port 80 |
host www.sol.no port 80 |
796 |
host shop.sol.no port 443 |
host shop.sol.no port 443 |
797 |
host kvasir.sol.no port 80 |
host kvasir.sol.no port 80 |
798 |
host 10.2.3.4 port 80</PRE> |
host 10.2.3.4 port 80</pre> |
799 |
<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, |
800 |
<EM>localhost</EM> is assumed.</P> |
<em>localhost</em> is assumed.</p> |
801 |
<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 |
802 |
Internet protocols. So, besides testing for connections, monit |
Internet protocols. So, besides testing for connections, monit |
803 |
can also speak with the server in question to verify that the |
can also speak with the server in question to verify that the |
804 |
server works. For example, the following is used to test a http |
server works. For example, the following is used to test a http |
805 |
server: |
server: |
806 |
</P> |
</p> |
807 |
<PRE> |
<pre> |
808 |
|
|
809 |
host www.tildeslash.com port 80 protocol http</PRE> |
host www.tildeslash.com port 80 protocol http</pre> |
810 |
<P>At the moment monit knows how to speak <EM>HTTP</EM>, <EM>SMTP</EM>, <EM>FTP</EM>, |
<p>At the moment monit knows how to speak <em>HTTP</em>, <em>SMTP</em>, <em>FTP</em>, |
811 |
<EM>POP</EM>, <EM>IMAP</EM>, <EM>NNTP</EM> and <EM>SSH</EM>. If you have compiled monit |
<em>POP</em>, <em>IMAP</em>, <em>NNTP</em>, <em>SSH</em>, <em>DWP</em>, <em>LDAP2</em> and <em>LDAP3</em>. |
812 |
with ssl support, monit can also speak <EM>HTTPS</EM>, <EM>FTPS</EM>, <EM>POPS</EM> |
If you have compiled monit with ssl support, monit can also speak |
813 |
and <EM>IMAPS</EM>.</P> |
<em>HTTPS</em>, <em>FTPS</em>, <em>POPS</em> and <em>IMAPS</em>.</p> |
814 |
<P>Some protocols also support a request statement. This statement |
<p>Some protocols also support a request statement. This statement |
815 |
can be used to ask the server for a special document entity.</P> |
can be used to ask the server for a special document entity.</p> |
816 |
<P>Currently <STRONG>only</STRONG> the <EM>HTTP</EM> protocol module supports the |
<p>Currently <strong>only</strong> the <em>HTTP</em> protocol module supports the |
817 |
request statement, such as:</P> |
request statement, such as:</p> |
818 |
<PRE> |
<pre> |
819 |
host www.myhost.com port 80 protocol http |
host www.myhost.com port 80 protocol http |
820 |
request "/data/show.php?a=b&c=d"</PRE> |
request "/data/show.php?a=b&c=d"</pre> |
821 |
<P>The request should contain an URI string specifying a document |
<p>The request should contain an URI string specifying a document |
822 |
from the http server. The string will be url encoded by monit |
from the http server. The string will be url encoded by monit |
823 |
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 |
824 |
use url unsafe characters in the request.</P> |
use url unsafe characters in the request.</p> |
825 |
<P>If the request statement isn't specified, the default web server |
<p>If the request statement isn't specified, the default web server |
826 |
page will be requested.</P> |
page will be requested.</p> |
827 |
<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 |
828 |
checks for a service.</P> |
checks for a service.</p> |
829 |
<P>See also the example section below.</P> |
<p>See also the example section below.</p> |
830 |
<P> |
<p> |
831 |
<HR> |
</p> |
832 |
<H1><A NAME="monit httpd">MONIT HTTPD</A></H1> |
<hr /> |
833 |
<P>If specified in the control file, monit will start a monit daemon |
<h1><a name="monit_httpd">MONIT HTTPD</a></h1> |
834 |
|
<p>If specified in the control file, monit will start a monit daemon |
835 |
with http support. From a Browser you can then start and stop |
with http support. From a Browser you can then start and stop |
836 |
programs as well as view the status of each program. Also, if |
programs as well as view the status of each program. Also, if |
837 |
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 |
838 |
logfile in a Browser.</P> |
logfile in a Browser.</p> |
839 |
<P>The control file statement for starting a monit daemon with http |
<p>The control file statement for starting a monit daemon with http |
840 |
support is a global set-statement:</P> |
support is a global set-statement:</p> |
841 |
<PRE> |
<pre> |
842 |
set httpd port 2812</PRE> |
set httpd port 2812</pre> |
843 |
<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 |
844 |
the daemon from a browser.</P> |
the daemon from a browser.</p> |
845 |
<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 |
846 |
are allowed to bind to.</P> |
are allowed to bind to.</p> |
847 |
<P>If you have compiled monit with openssl support, you can also |
<p>If you have compiled monit with openssl support, you can also |
848 |
start the httpd server with ssl support, using the following |
start the httpd server with ssl support, using the following |
849 |
expression:</P> |
expression:</p> |
850 |
<PRE> |
<pre> |
851 |
set httpd port 2812 |
set httpd port 2812 |
852 |
ssl enable |
ssl enable |
853 |
pemfile /etc/certs/monit.pem</PRE> |
pemfile /etc/certs/monit.pem</pre> |
854 |
<P>And you can use this URL, <EM><A HREF="https://localhost:2812/">https://localhost:2812/</A></EM>, to access |
<p>And you can use this URL, <em><a href="https://localhost:2812/">https://localhost:2812/</a></em>, to access |
855 |
the monit web server over an ssl encrypted connection.</P> |
the monit web server over an ssl encrypted connection.</p> |
856 |
<P>The pemfile, in the example above, holds the private key and the |
<p>The pemfile, in the example above, holds the private key and the |
857 |
certificate. This file should be stored on a safe place on the |
certificate. This file should be stored on a safe place on the |
858 |
filesystem and should have strict permissions, that is, no more |
filesystem and should have strict permissions, that is, no more |
859 |
than 0700. For more information on how to generate this file, |
than 0700. For more information on how to generate this file, |
860 |
please consult README.ssl</P> |
please consult README.ssl</p> |
861 |
<P>In addition, if you want to check for client certificates you can |
<p>In addition, if you want to check for client certificates you can |
862 |
use the CLIENTPEMFILE statement. In that case a connecting |
use the CLIENTPEMFILE statement. In that case a connecting |
863 |
client has to have a sufficient key and certificate in order to |
client has to have a sufficient key and certificate in order to |
864 |
connect. This file also needs to have all necessary CA |
connect. This file also needs to have all necessary CA |
865 |
certificates. A configuration could look like: |
certificates. A configuration could look like: |
866 |
</P> |
</p> |
867 |
<PRE> |
<pre> |
868 |
|
|
869 |
set httpd port 2812 |
set httpd port 2812 |
870 |
ssl enable |
ssl enable |
871 |
pemfile /etc/certs/monit.pem |
pemfile /etc/certs/monit.pem |
872 |
clientpemfile /etc/certs/monit-client.pem</PRE> |
clientpemfile /etc/certs/monit-client.pem</pre> |
873 |
<P>By default self signed certificates are not allowed. In case you need |
<p>By default self signed certificates are not allowed. In case you need |
874 |
to use them it has to be allowed explicitly with the |
to use them it has to be allowed explicitly with the |
875 |
ALLOWSELFCERTIFICATION statement.</P> |
ALLOWSELFCERTIFICATION statement.</p> |
876 |
<P>If you only want the http server to accept connect requests to |
<p>If you only want the http server to accept connect requests to |
877 |
one host addresses you can specify the bind address either as an |
one host addresses you can specify the bind address either as an |
878 |
IP number string or as a hostname. In the following example we |
IP number string or as a hostname. In the following example we |
879 |
bind the http server to the loopback device. In other words the |
bind the http server to the loopback device. In other words the |
880 |
http server will only be reachable from localhost:</P> |
http server will only be reachable from localhost:</p> |
881 |
<PRE> |
<pre> |
882 |
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> |
883 |
<P>or</P> |
<p>or</p> |
884 |
<PRE> |
<pre> |
885 |
set httpd port 2812 and use the address localhost</PRE> |
set httpd port 2812 and use the address localhost</pre> |
886 |
<P>or with ssl</P> |
<p>or with ssl</p> |
887 |
<PRE> |
<pre> |
888 |
set httpd port 2812 |
set httpd port 2812 |
889 |
ssl enable |
ssl enable |
890 |
address localhost |
address localhost |
891 |
pemfile /var/certs/monit.pem</PRE> |
pemfile /var/certs/monit.pem</pre> |
892 |
<P>If you do not use the ADDRESS statement the http server will |
<p>If you do not use the ADDRESS statement the http server will |
893 |
accept connections on any/all local addresses.</P> |
accept connections on any/all local addresses.</p> |
894 |
<P>If you remove the httpd statement from the config file, monit will |
<p>If you remove the httpd statement from the config file, monit will |
895 |
stop the httpd server on its next cycle. Likewise if you change |
stop the httpd server on its next cycle. Likewise if you change |
896 |
the port number, monit will restart the http server using the new |
the port number, monit will restart the http server using the new |
897 |
specified port number.</P> |
specified port number.</p> |
898 |
<P>The status page displayed by the monit web server is |
<p>The status page displayed by the monit web server is |
899 |
automatically refreshed with the same poll time set for the monit |
automatically refreshed with the same poll time set for the monit |
900 |
daemon.</P> |
daemon.</p> |
901 |
<P><STRONG>Note:</STRONG></P> |
<p><strong>Note:</strong></p> |
902 |
<P>You <EM>must</EM> start a monit daemon with http support if you want to |
<p>You <em>must</em> start a monit daemon with http support if you want to |
903 |
be able to use the following console commands.</P> |
be able to use the following console commands.</p> |
904 |
<PRE> |
<pre> |
905 |
'monit stop' |
'monit stop' |
906 |
'monit start program' |
'monit start program' |
907 |
'monit stop program' |
'monit stop program' |
908 |
'monit restart program' |
'monit restart program' |
909 |
'monit -g groupname start' |
'monit -g groupname start' |
910 |
'monit -g groupname stop' |
'monit -g groupname stop' |
911 |
'monit -g groupname restart'</PRE> |
'monit -g groupname restart'</pre> |
912 |
<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 |
913 |
deamon (via the HTTP protocol) to execute the above commands. |
deamon (via the HTTP protocol) to execute the above commands. |
914 |
That is, the daemon is requested to start and stop the programs. |
That is, the daemon is requested to start and stop the programs. |
915 |
This ensures that a daemon will not restart a program that you |
This ensures that a daemon will not restart a program that you |
916 |
requested to stop and that (any) timeout lock will be removed |
requested to stop and that (any) timeout lock will be removed |
917 |
from a program when you start it.</P> |
from a program when you start it.</p> |
918 |
<P> |
<p> |
919 |
<H2><A NAME="monit httpd authentication">Monit HTTPD Authentication</A></H2> |
</p> |
920 |
<P>monit supports two types of autenthication schemas for connecting |
<h2><a name="monit_httpd_authentication">Monit HTTPD Authentication</a></h2> |
921 |
|
<p>monit supports two types of autenthication schemas for connecting |
922 |
to the httpd server. Both schemas can be used together or by |
to the httpd server. Both schemas can be used together or by |
923 |
itself. You <STRONG>must</STRONG> choose at least one.</P> |
itself. You <strong>must</strong> choose at least one.</p> |
924 |
<P><STRONG>Host allow list</STRONG></P> |
<p><strong>Host allow list</strong></p> |
925 |
<P>The http server maintains an access-control list of hosts allowed |
<p>The http server maintains an access-control list of hosts allowed |
926 |
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 |
927 |
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 |
928 |
allowed. If you specify a host that does not resolve, monit will |
allowed. If you specify a host that does not resolve, monit will |
929 |
write an error message in the console and not start.</P> |
write an error message in the console and not start.</p> |
930 |
<P>The http server will query a nameserver to check any hosts |
<p>The http server will query a nameserver to check any hosts |
931 |
connecting to the server. If a host (client) is trying to connect |
connecting to the server. If a host (client) is trying to connect |
932 |
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 |
933 |
be resolved, the server will shutdown the connection to the |
be resolved, the server will shutdown the connection to the |
934 |
client promptly.</P> |
client promptly.</p> |
935 |
<P>Control file example:</P> |
<p>Control file example:</p> |
936 |
<PRE> |
<pre> |
937 |
set httpd port 2812 |
set httpd port 2812 |
938 |
allow localhost |
allow localhost |
939 |
allow my.other.work.machine.com |
allow my.other.work.machine.com |
940 |
allow 10.1.1.1</PRE> |
allow 10.1.1.1</pre> |
941 |
<P><STRONG>Basic Authentication</STRONG></P> |
<p><strong>Basic Authentication</strong></p> |
942 |
<P>This authentication schema is HTTP specific and described in more |
<p>This authentication schema is HTTP specific and described in more |
943 |
detail in RFC 2617.</P> |
detail in RFC 2617.</p> |
944 |
<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 |
945 |
authentication information (username and password) and if |
authentication information (username and password) and if |
946 |
accepted, the server will allow the client access to the |
accepted, the server will allow the client access to the |
947 |
requested document.</P> |
requested document.</p> |
948 |
<P>The biggest weakness with Basic Authentication is that the |
<p>The biggest weakness with Basic Authentication is that the |
949 |
username and password is sent in clear-text (i.e. base64 encoded) |
username and password is sent in clear-text (i.e. base64 encoded) |
950 |
over the network. It is therefor recommended that you do not use |
over the network. It is therefor recommended that you do not use |
951 |
this authentication method unless you run the monit http server |
this authentication method unless you run the monit http server |
952 |
with <EM>ssl</EM> support. With ssl support it is completely safe to |
with <em>ssl</em> support. With ssl support it is completely safe to |
953 |
use Basic Authentication since <STRONG>all</STRONG> http data, including Basic |
use Basic Authentication since <strong>all</strong> http data, including Basic |
954 |
Authentication headers will be encrypted.</P> |
Authentication headers will be encrypted.</p> |
955 |
<P>monit will use Basic Authentication if an allow statement contains |
<p>monit will use Basic Authentication if an allow statement contains |
956 |
a username and password separated with a single ':' character, |
a username and password separated with a single ':' character, |
957 |
like so; <EM>allow username:password</EM>. The username and password |
like so; <em>allow username:password</em>. The username and password |
958 |
must be written in clear-text. Only one username and password |
must be written in clear-text. Only one username and password |
959 |
pair is supported.</P> |
pair is supported.</p> |
960 |
<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 |
961 |
clients from the listed hosts will be allowed to connect to the |
clients from the listed hosts will be allowed to connect to the |
962 |
monit http server and each client will be asked to provide a |
monit http server and each client will be asked to provide a |
963 |
username and password.</P> |
username and password.</p> |
964 |
<P>Example:</P> |
<p>Example:</p> |
965 |
<PRE> |
<pre> |
966 |
set httpd port 2812 |
set httpd port 2812 |
967 |
allow localhost |
allow localhost |
968 |
allow my.other.work.machine.com |
allow my.other.work.machine.com |
969 |
allow 10.1.1.1 |
allow 10.1.1.1 |
970 |
allow hauk:monit</PRE> |
allow hauk:monit</pre> |
971 |
<P>If you only want to use Basic Authentication, then just provide |
<p>If you only want to use Basic Authentication, then just provide |
972 |
the one line with username and password, like:</P> |
the one line with username and password, like:</p> |
973 |
<PRE> |
<pre> |
974 |
set httpd port 2812 |
set httpd port 2812 |
975 |
allow hauk:monit</PRE> |
allow hauk:monit</pre> |
976 |
<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 |
977 |
access permission for the control file (~/.monitrc) to only |
access permission for the control file (~/.monitrc) to only |
978 |
readable and writeable for the user running monit, because the |
readable and writeable for the user running monit, because the |
979 |
password is written in clear-text. (Use this command, /bin/chmod |
password is written in clear-text. (Use this command, /bin/chmod |
980 |
600 ~/.monitrc). In fact, since monit <STRONG>version 3.0</STRONG>, monit will |
600 ~/.monitrc). In fact, since monit <strong>version 3.0</strong>, monit will |
981 |
complain and exit if the control file is readable by others.</P> |
complain and exit if the control file is readable by others.</p> |
982 |
<P> |
<p> |
983 |
<HR> |
</p> |
984 |
<H1><A NAME="md5 checksum">MD5 CHECKSUM</A></H1> |
<hr /> |
985 |
<P>If specified in the control file, monit will compute a md5 |
<h1><a name="md5_checksum">MD5 CHECKSUM</a></h1> |
986 |
|
<p>If specified in the control file, monit will compute a md5 |
987 |
checksum for programs. The checksum is used to verify that a |
checksum for programs. The checksum is used to verify that a |
988 |
program does not change. If a program was changed, monit will |
program does not change. If a program was changed, monit will |
989 |
send an (optional) alert notification, log an alert message and |
send an (optional) alert notification, log an alert message and |
990 |
not check the process anymore. The web interface will also show a |
not check the process anymore. The web interface will also show a |
991 |
checksum warning.</P> |
checksum warning.</p> |
992 |
<P>The rationale for this feature is security and that monit does |
<p>The rationale for this feature is security and that monit does |
993 |
not start a possible cracked program or script.</P> |
not start a possible cracked program or script.</p> |
994 |
<P>The full syntax for the checksum-statement is as follows: |
<p>The full syntax for the checksum-statement is as follows: |
995 |
(keywords are in capital)</P> |
(keywords are in capital)</p> |
996 |
<PRE> |
<pre> |
997 |
CHECKSUM [file [EXPECT checksum] ]+</PRE> |
CHECKSUM [file [EXPECT checksum] ]+</pre> |
998 |
<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 |
999 |
process entry in the control file is:</P> |
process entry in the control file is:</p> |
1000 |
<PRE> |
<pre> |
1001 |
checksum the /usr/bin/httpd program</PRE> |
checksum the /usr/bin/httpd program</pre> |
1002 |
<P>The shorthand version is just:</P> |
<p>The shorthand version is just:</p> |
1003 |
<PRE> |
<pre> |
1004 |
checksum /usr/bin/httpd</PRE> |
checksum /usr/bin/httpd</pre> |
1005 |
<P>Several files can be used in a checksum statement:</P> |
<p>Several files can be used in a checksum statement:</p> |
1006 |
<PRE> |
<pre> |
1007 |
checksum /usr/apache/bin/httpd /usr/apache-ssl/bin/httpsd</PRE> |
checksum /usr/apache/bin/httpd /usr/apache-ssl/bin/httpsd</pre> |
1008 |
<P>or on a line by itself:</P> |
<p>or on a line by itself:</p> |
1009 |
<PRE> |
<pre> |
1010 |
checksum /usr/apache/bin/httpd |
checksum /usr/apache/bin/httpd |
1011 |
checksum /usr/apache-ssl/bin/httpsd</PRE> |
checksum /usr/apache-ssl/bin/httpsd</pre> |
1012 |
<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 |
1013 |
described above, if the checksum for a file changes, monit will |
described above, if the checksum for a file changes, monit will |
1014 |
log a warning, issue an alert message and not check the |
log a warning, issue an alert message and not check the |
1015 |
associated process anymore.</P> |
associated process anymore.</p> |
1016 |
<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 |
1017 |
string monit should expect when testing a file's checksum. If |
string monit should expect when testing a file's checksum. If |
1018 |
this statement is used monit will not compute an initial checksum |
this statement is used monit will not compute an initial checksum |
1019 |
for the file, as in the examples above, but instead use the |
for the file, as in the examples above, but instead use the |
1020 |
string you submit. For example:</P> |
string you submit. For example:</p> |
1021 |
<PRE> |
<pre> |
1022 |
checksum /usr/bin/httpd expect 8f7f419955cefa0b33a2ba316cba3659</PRE> |
checksum /usr/bin/httpd expect 8f7f419955cefa0b33a2ba316cba3659</pre> |
1023 |
<P>or verbose style;</P> |
<p>or verbose style;</p> |
1024 |
<PRE> |
<pre> |
1025 |
checksum /usr/bin/httpd and |
checksum /usr/bin/httpd and |
1026 |
expect the sum 4e5309d1956f003bcdff168748bea647</PRE> |
expect the sum 4e5309d1956f003bcdff168748bea647</pre> |
1027 |
<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 |
1028 |
checksum string for a file and then use this string in the |
checksum string for a file and then use this string in the |
1029 |
expect-statement.</P> |
expect-statement.</p> |
1030 |
<P> |
<p> |
1031 |
<HR> |
</p> |
1032 |
<H1><A NAME="dependency checking">DEPENDENCY CHECKING</A></H1> |
<hr /> |
1033 |
<P>If specified in the control file, monit can do dependency |
<h1><a name="dependency_checking">DEPENDENCY CHECKING</a></h1> |
1034 |
|
<p>If specified in the control file, monit can do dependency |
1035 |
checking before starting or stopping processes. The syntax for |
checking before starting or stopping processes. The syntax for |
1036 |
the depend statement is simply:</P> |
the depend statement is simply:</p> |
1037 |
<PRE> |
<pre> |
1038 |
DEPENDS [process]+</PRE> |
DEPENDS [process]+</pre> |
1039 |
<P>Where <STRONG>process</STRONG> is a process entry name, for instance <STRONG>apache</STRONG>. |
<p>Where <strong>process</strong> is a process entry name, for instance <strong>apache</strong>. |
1040 |
You may add more than one process name or use more than one |
You may add more than one process name or use more than one |
1041 |
depend statement in a check entry.</P> |
depend statement in a check entry.</p> |
1042 |
<P>Processes specified in a <EM>depends</EM> statement will be checked |
<p>Processes specified in a <em>depends</em> statement will be checked |
1043 |
during stop/start operations. If a process is stopped it will |
during stop/start operations. If a process is stopped it will |
1044 |
first stop any processes that depends on itself. Likewise, if a |
first stop any processes that depends on itself. Likewise, if a |
1045 |
process is started, it will first stop any processes that depends |
process is started, it will first stop any processes that depends |
1046 |
on itself and after it is started, start all depending processes |
on itself and after it is started, start all depending processes |
1047 |
again.</P> |
again.</p> |
1048 |
<P>Consider the following common server setup:</P> |
<p>Consider the following common server setup:</p> |
1049 |
<PRE> |
<pre> |
1050 |
(a) WEB-SERVER -> (b) APPLICATION-SERVER -> (c) DATABASE</PRE> |
(a) WEB-SERVER -> (b) APPLICATION-SERVER -> (c) DATABASE</pre> |
1051 |
<P>You can set dependencies so that the web-server depends on the |
<p>You can set dependencies so that the web-server depends on the |
1052 |
application server to run before the web-server starts and the |
application server to run before the web-server starts and the |
1053 |
application server depends on the database server. See also the |
application server depends on the database server. See also the |
1054 |
example section below for examples using the depend statement.</P> |
example section below for examples using the depend statement.</p> |
1055 |
<P>Here we describe how monit will function with the above |
<p>Here we describe how monit will function with the above |
1056 |
dependencies:</P> |
dependencies:</p> |
1057 |
<DL> |
<dl> |
1058 |
<DT><STRONG><A NAME="item_If_no_servers_are_running">If no servers are running</A></STRONG><BR> |
<dt><strong><a name="item_if_no_servers_are_running">If no servers are running</a></strong><br /> |
1059 |
<DD> |
</dt> |
1060 |
monit will start the servers in the following order: <EM>c</EM>, <EM>b</EM>, |
<dd> |
1061 |
<EM>a</EM> |
monit will start the servers in the following order: <em>c</em>, <em>b</em>, |
1062 |
<P></P> |
<em>a</em> |
1063 |
<DT><STRONG><A NAME="item_If_all_servers_are_running">If all servers are running</A></STRONG><BR> |
</dd> |
1064 |
<DD> |
<p></p> |
1065 |
When you run 'monit stop' this is the stop order: <EM>a</EM>, <EM>b</EM>, |
<dt><strong><a name="item_if_all_servers_are_running">If all servers are running</a></strong><br /> |
1066 |
<EM>c</EM>. If you run 'monit stop c' then <EM>a</EM> and <EM>b</EM> are stopped |
</dt> |
1067 |
because they depend on <EM>c</EM> and finally <EM>c</EM> is stopped. |
<dd> |
1068 |
<P></P> |
When you run 'monit stop' this is the stop order: <em>a</em>, <em>b</em>, |
1069 |
<DT><STRONG><A NAME="item_If_a_does_not_run">If <EM>a</EM> does not run</A></STRONG><BR> |
<em>c</em>. If you run 'monit stop c' then <em>a</em> and <em>b</em> are stopped |
1070 |
<DD> |
because they depend on <em>c</em> and finally <em>c</em> is stopped. |
1071 |
When monit runs it will start <EM>a</EM> |
</dd> |
1072 |
<P></P> |
<p></p> |
1073 |
<DT><STRONG><A NAME="item_If_b_does_not_run">If <EM>b</EM> does not run</A></STRONG><BR> |
<dt><strong><a name="item_if_a_does_not_run">If <em>a</em> does not run</a></strong><br /> |
1074 |
<DD> |
</dt> |
1075 |
When monit runs it will first stop <EM>a</EM> then start <EM>b</EM> and |
<dd> |
1076 |
finally start <EM>a</EM> again. |
When monit runs it will start <em>a</em> |
1077 |
<P></P> |
</dd> |
1078 |
<DT><STRONG><A NAME="item_If_c_does_not_run">If <EM>c</EM> does not run</A></STRONG><BR> |
<p></p> |
1079 |
<DD> |
<dt><strong><a name="item_if_b_does_not_run">If <em>b</em> does not run</a></strong><br /> |
1080 |
When monit runs it will first stop <EM>a</EM> and <EM>b</EM> then start <EM>c</EM> |
</dt> |
1081 |
and finally start <EM>b</EM> then <EM>a</EM>. |
<dd> |
1082 |
<P></P> |
When monit runs it will first stop <em>a</em> then start <em>b</em> and |
1083 |
<DT><STRONG><A NAME="item_If_the_control_file_contains_a_depend_loop%2E">If the control file contains a depend loop.</A></STRONG><BR> |
finally start <em>a</em> again. |
1084 |
<DD> |
</dd> |
1085 |
|
<p></p> |
1086 |
|
<dt><strong><a name="item_if_c_does_not_run">If <em>c</em> does not run</a></strong><br /> |
1087 |
|
</dt> |
1088 |
|
<dd> |
1089 |
|
When monit runs it will first stop <em>a</em> and <em>b</em> then start <em>c</em> |
1090 |
|
and finally start <em>b</em> then <em>a</em>. |
1091 |
|
</dd> |
1092 |
|
<p></p> |
1093 |
|
<dt><strong><a name="item_if_the_control_file_contains_a_depend_loop%2e">If the control file contains a depend loop.</a></strong><br /> |
1094 |
|
</dt> |
1095 |
|
<dd> |
1096 |
A depend loop is for example; a->b and b->a or a->b->c->a. |
A depend loop is for example; a->b and b->a or a->b->c->a. |
1097 |
<P>When monit starts it will check for any such loops and complain |
</dd> |
1098 |
|
<dd> |
1099 |
|
<p>When monit starts it will check for any such loops and complain |
1100 |
and exit if a loop was found. It will also exit with a complaint |
and exit if a loop was found. It will also exit with a complaint |
1101 |
if a depend statement was used that does not point to any |
if a depend statement was used that does not point to any |
1102 |
processes in the controlfile.</P> |
processes in the controlfile.</p> |
1103 |
<P></P></DL> |
</dd> |
1104 |
<P> |
<p></p></dl> |
1105 |
<HR> |
<p> |
1106 |
<H1><A NAME="the run control file">THE RUN CONTROL FILE</A></H1> |
</p> |
1107 |
<P>The preferred way to set up monit is to write a <EM>.monitrc</EM> file |
<hr /> |
1108 |
|
<h1><a name="the_run_control_file">THE RUN CONTROL FILE</a></h1> |
1109 |
|
<p>The preferred way to set up monit is to write a <em>.monitrc</em> file |
1110 |
in your home directory. When there is a conflict between the |
in your home directory. When there is a conflict between the |
1111 |
command-line arguments and the arguments in this file, the |
command-line arguments and the arguments in this file, the |
1112 |
command-line arguments take precedence. To protect the security |
command-line arguments take precedence. To protect the security |
1113 |
of your control file and passwords the control file must have |
of your control file and passwords the control file must have |
1114 |
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 |
1115 |
complain and exit otherwise.</P> |
complain and exit otherwise.</p> |
1116 |
<P> |
<p> |
1117 |
<H2><A NAME="run control syntax">Run Control Syntax</A></H2> |
</p> |
1118 |
<P>Comments begin with a '#' and extend through the end of the line. |
<h2><a name="run_control_syntax">Run Control Syntax</a></h2> |
1119 |
|
<p>Comments begin with a '#' and extend through the end of the line. |
1120 |
Otherwise the file consists of a series of program entries or |
Otherwise the file consists of a series of program entries or |
1121 |
global option statements in a free-format, token-oriented syntax.</P> |
global option statements in a free-format, token-oriented syntax.</p> |
1122 |
<P>There are three kinds of tokens: grammar keywords, numbers (i.e. |
<p>There are three kinds of tokens: grammar keywords, numbers (i.e. |
1123 |
decimal digit sequences) and strings. Strings can be either |
decimal digit sequences) and strings. Strings can be either |
1124 |
quoted or unquoted. A quoted string is bounded by double quotes |
quoted or unquoted. A quoted string is bounded by double quotes |
1125 |
and may contain whitespace (and quoted digits are treated as a |
and may contain whitespace (and quoted digits are treated as a |
1126 |
string). An unquoted string is any whitespace-delimited token, |
string). An unquoted string is any whitespace-delimited token, |
1127 |
containing characters and/or numbers.</P> |
containing characters and/or numbers.</p> |
1128 |
<P>Each program entry consists of the keywords `check', followed by |
<p>Each program entry consists of the keywords `check', followed by |
1129 |
a unique descriptive name for the program, which is again |
a unique descriptive name for the program, which is again |
1130 |
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 |
1131 |
have a number of optional statements. These statements are |
have a number of optional statements. These statements are |
1132 |
described below and in the example section.</P> |
described below and in the example section.</p> |
1133 |
<P>You can use noise keywords like 'if', `and', `with(in)', `has', |
<p>You can use noise keywords like 'if', `and', `with(in)', `has', |
1134 |
`using', 'use', 'on(ly)' and `program' anywhere in an entry to |
`using', 'use', 'on(ly)' and `program' anywhere in an entry to |
1135 |
make it resemble English. They're ignored, but can make entries |
make it resemble English. They're ignored, but can make entries |
1136 |
much easier to read at a glance. The punctuation characters ';' |
much easier to read at a glance. The punctuation characters ';' |
1137 |
',' and '=' are also ignored. Keywords are case insensitive.</P> |
',' and '=' are also ignored. Keywords are case insensitive.</p> |
1138 |
<PRE> |
<pre> |
1139 |
Here are the legal global keywords:</PRE> |
Here are the legal global keywords:</pre> |
1140 |
<PRE> |
<pre> |
1141 |
Keyword Function |
Keyword Function |
1142 |
----------------------------------------------------------- |
----------------------------------------------------------- |
1143 |
set daemon Set a background poll interval in seconds |
set daemon Set a background poll interval in seconds |
1170 |
a username and password allowed to connect |
a username and password allowed to connect |
1171 |
to the server. More than one allow statement |
to the server. More than one allow statement |
1172 |
are allowed. This statement is also an |
are allowed. This statement is also an |
1173 |
optional part of the set httpd statement.</PRE> |
optional part of the set httpd statement.</pre> |
1174 |
<PRE> |
<pre> |
1175 |
Here are the legal program entry keywords:</PRE> |
Here are the legal program entry keywords:</pre> |
1176 |
<PRE> |
<pre> |
1177 |
Keyword Function |
Keyword Function |
1178 |
------------------------------------------------------------ |
------------------------------------------------------------ |
1179 |
check Starts an entry and must be followed by a |
check Starts an entry and must be followed by a |
1212 |
server has to deliver. |
server has to deliver. |
1213 |
proto(col) This keyword specifies the type of service |
proto(col) This keyword specifies the type of service |
1214 |
found at the port. monit knows at the moment |
found at the port. monit knows at the moment |
1215 |
how to speak HTTP, SMPT, FTP, POP and IMAP. |
how to speak HTTP, SMTP, FTP, POP, IMAP, NNTP, |
1216 |
You're welcome to write new protocol test |
SSH, DWP, LDAP2 and LDAP3. You're welcome |
1217 |
modules. If no protocol is specified monit |
to write new protocol test modules. If no |
1218 |
will use a default test which in most cases |
protocol is specified monit will use a default |
1219 |
are good enough. |
test which in most cases are good enough. |
1220 |
request Specifies a server request and must come |
request Specifies a server request and must come |
1221 |
after the protocol keyword mentioned above. |
after the protocol keyword mentioned above. |
1222 |
- for http it can contain an URI and an |
- for http it can contain an URI and an |
1284 |
action. This statement is used to check the |
action. This statement is used to check the |
1285 |
system load average over a number of cylces. If |
system load average over a number of cylces. If |
1286 |
the compare expression matches then the action |
the compare expression matches then the action |
1287 |
start, alert or stop is avtivated.</PRE> |
start, alert or stop is avtivated.</pre> |
1288 |
<PRE> |
<pre> |
1289 |
depends (on) Must be followed by the name of a process this |
depends (on) Must be followed by the name of a process this |
1290 |
process depends on to run before it starts.</PRE> |
process depends on to run before it starts.</pre> |
1291 |
<P>Here's the complete list of reserved <STRONG>keywords</STRONG> used by monit:</P> |
<p>Here's the complete list of reserved <strong>keywords</strong> used by monit:</p> |
1292 |
<P><EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, <EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>, |
<p><em>set</em>, <em>daemon</em>, <em>logfile</em>, <em>syslog</em>, <em>address</em>, <em>httpd</em>, |
1293 |
<EM>ssl</EM>, <EM>enable</EM>, <EM>disable</EM>, <EM>pemfile</EM>, <EM>allow</EM>, <EM>check</EM>, |
<em>ssl</em>, <em>enable</em>, <em>disable</em>, <em>pemfile</em>, <em>allow</em>, <em>check</em>, |
1294 |
<EM>init</EM>, <EM>pidfile</EM>, <EM>group</EM>, <EM>start</EM>, <EM>stop</EM>, |
<em>init</em>, <em>pidfile</em>, <em>group</em>, <em>start</em>, <em>stop</em>, |
1295 |
<EM>port(number)</EM>, <EM>unix(socket)</EM>, <EM>type</EM>, <EM>proto(col)</EM>, <EM>tcp</EM>, |
<em>port(number)</em>, <em>unix(socket)</em>, <em>type</em>, <em>proto(col)</em>, <em>tcp</em>, |
1296 |
<EM>tcpssl</EM>, <EM>udp</EM>, <EM>alert</EM>, <EM>mail-format</EM>, <EM>restart</EM>, |
<em>tcpssl</em>, <em>udp</em>, <em>alert</em>, <em>mail-format</em>, <em>restart</em>, |
1297 |
<EM>timeout</EM>, <EM>checksum</EM>, <EM>resource</EM>, <EM>expect</EM>, <EM>mailserver</EM>, |
<em>timeout</em>, <em>checksum</em>, <em>resource</em>, <em>expect</em>, <em>mailserver</em>, |
1298 |
<EM>every</EM>, <EM>mode</EM>, <EM>active</EM>, <EM>passive</EM>, <EM>manual</EM>, <EM>depends</EM>, |
<em>every</em>, <em>mode</em>, <em>active</em>, <em>passive</em>, <em>manual</em>, <em>depends</em>, |
1299 |
<EM>host</EM>, <EM>default</EM>, <EM>http</EM>, <EM>ftp</EM>, <EM>smtp</EM>, <EM>pop</EM>, <EM>nntp</EM>, |
<em>host</em>, <em>default</em>, <em>http</em>, <em>ftp</em>, <em>smtp</em>, <em>pop</em>, <em>nntp</em>, |
1300 |
<EM>imap</EM>, <EM>ssh</EM>, <EM>request</EM>, <EM>cpuusage</EM>, <EM>memusage</EM>, |
<em>imap</em>, <em>ssh</em>, <em>dwp</em>, <em>ldap2</em>, <em>ldap3</em>, <em>request</em>, |
1301 |
<EM>memkbyte</EM>, <EM>loadavg</EM>, <EM>timestamp</EM>, <EM>second(s)</EM>, |
<em>cpuusage</em>, <em>memusage</em>, <em>memkbyte</em>, <em>loadavg</em>, <em>timestamp</em>, |
1302 |
<EM>minute(s)</EM>, <EM>hour(s)</EM> and <EM>day(s)</EM>.</P> |
<em>second(s)</em>, <em>minute(s)</em>, <em>hour(s)</em> and <em>day(s)</em>.</p> |
1303 |
<P>And here is a complete list of <STRONG>noise keywords</STRONG> ignored by |
<p>And here is a complete list of <strong>noise keywords</strong> ignored by |
1304 |
monit:</P> |
monit:</p> |
1305 |
<P><EM>if</EM>, <EM>is</EM>, <EM>are</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>, |
<p><em>if</em>, <em>is</em>, <em>are</em>, <em>on(ly)</em>, <em>with(in)</em>, <em>and</em>, <em>has</em>, |
1306 |
<EM>using</EM>, <EM>use</EM>, <EM>the</EM>, <EM>sum</EM>, <EM>restarts</EM>, <EM>program(s)</EM>, |
<em>using</em>, <em>use</em>, <em>the</em>, <em>sum</em>, <em>restarts</em>, <em>program(s)</em>, |
1307 |
<EM>cycle(s)</EM>, <EM>than</EM>, <EM>then</EM>, <EM>for</EM>.</P> |
<em>cycle(s)</em>, <em>than</em>, <em>then</em>, <em>for</em>.</p> |
1308 |
<P><STRONG>Note:</STRONG> If the <EM>start</EM> or <EM>stop</EM> programs are shell scripts, |
<p><strong>Note:</strong> If the <em>start</em> or <em>stop</em> programs are shell scripts, |
1309 |
then the script must begin with <CODE>#!</CODE> and the remainder of the |
then the script must begin with <code>#!</code> and the remainder of the |
1310 |
first line must specify an interpreter for the |
first line must specify an interpreter for the |
1311 |
program. E.g. <CODE>#!/bin/sh</CODE></P> |
program. E.g. <code>#!/bin/sh</code></p> |
1312 |
<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 |
1313 |
<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> |
1314 |
<PRE> |
<pre> |
1315 |
start: "/bin/sh -c { echo $$ > pidfile; exec program }" |
start: "/bin/sh -c { echo $$ > pidfile; exec program }" |
1316 |
stop: "/bin/sh -c { kill -s SIGTERM `cat pidfile` }"</PRE> |
stop: "/bin/sh -c { kill -s SIGTERM `cat pidfile` }"</pre> |
1317 |
<P> |
<p> |
1318 |
<H2><A NAME="configuration examples">CONFIGURATION EXAMPLES</A></H2> |
</p> |
1319 |
<P>The simplest form is just the check statement. In this example we |
<h2><a name="configuration_examples">CONFIGURATION EXAMPLES</a></h2> |
1320 |
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 |
1321 |
<PRE> |
check to see if the server is running and log a message if not:</p> |
1322 |
check resin with pidfile /usr/local/resin/srun.pid</PRE> |
<pre> |
1323 |
<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> |
1324 |
statement:</P> |
<p>To have monit start the server if it's not running, add a start |
1325 |
<PRE> |
statement:</p> |
1326 |
|
<pre> |
1327 |
check resin with pidfile /usr/local/resin/srun.pid |
check resin with pidfile /usr/local/resin/srun.pid |
1328 |
start program = "/usr/local/resin/bin/srun.sh start"</PRE> |
start program = "/usr/local/resin/bin/srun.sh start"</pre> |
1329 |
<P>Here's a more advanced example for monitoring an apache |
<p>Here's a more advanced example for monitoring an apache |
1330 |
web-server listening on the default portnumber for HTTP and |
web-server listening on the default portnumber for HTTP and |
1331 |
HTTPS. In this example monit will restart apache if it's not |
HTTPS. In this example monit will restart apache if it's not |
1332 |
accepting connections at the portnumbers. The method monit use |
accepting connections at the portnumbers. The method monit use |
1333 |
for a process restart is to first execute the stop-program, wait |
for a process restart is to first execute the stop-program, wait |
1334 |
for the process to stop and then execute the start-program.</P> |
for the process to stop and then execute the start-program.</p> |
1335 |
<PRE> |
<pre> |
1336 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1337 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1338 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1339 |
port 80 |
port 80 |
1340 |
port 443</PRE> |
port 443</pre> |
1341 |
<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 |
1342 |
'named' service is running and also use timeout and alert:</P> |
'named' service is running and also use timeout and alert:</p> |
1343 |
<PRE> |
<pre> |
1344 |
check named with pidfile /var/run/named.pid |
check named with pidfile /var/run/named.pid |
1345 |
start program = "/etc/init.d/named start" |
start program = "/etc/init.d/named start" |
1346 |
stop program = "/etc/init.d/named stop" |
stop program = "/etc/init.d/named stop" |
1347 |
port 53 use type udp |
port 53 use type udp |
1348 |
timeout (3,5) |
timeout (3,5) |
1349 |
alert bofh@norid.no</PRE> |
alert bofh@norid.no</pre> |
1350 |
<P>The following example illustrate how to check if the service |
<p>The following example illustrate how to check if the service |
1351 |
'sophie' is answering connections on its unix domain socket:</P> |
'sophie' is answering connections on its unix domain socket:</p> |
1352 |
<PRE> |
<pre> |
1353 |
check sophie with pidfile /var/run/sophie.pid |
check sophie with pidfile /var/run/sophie.pid |
1354 |
start program = "/etc/init.d/sophie start" |
start program = "/etc/init.d/sophie start" |
1355 |
stop program = "/etc/init.d/sophie stop" |
stop program = "/etc/init.d/sophie stop" |
1356 |
unix /var/run/sophie</PRE> |
unix /var/run/sophie</pre> |
1357 |
<P>In this example we check an apache web-server running on |
<p>In this example we check an apache web-server running on |
1358 |
localhost that answers for several IP-based virtual hosts or |
localhost that answers for several IP-based virtual hosts or |
1359 |
vhosts, hence the host statement before port:</P> |
vhosts, hence the host statement before port:</p> |
1360 |
<PRE> |
<pre> |
1361 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1362 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1363 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1364 |
host www.sol.no port 80 |
host www.sol.no port 80 |
1365 |
host shop.sol.no port 443 |
host shop.sol.no port 443 |
1366 |
host chat.sol.no port 80 |
host chat.sol.no port 80 |
1367 |
host www.tildeslash.com port 80</PRE> |
host www.tildeslash.com port 80</pre> |
1368 |
<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 |
1369 |
checksum for the underlying apache binary used by the start and |
checksum for the underlying apache binary used by the start and |
1370 |
stop programs.</P> |
stop programs.</p> |
1371 |
<PRE> |
<pre> |
1372 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1373 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1374 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1375 |
host www.tildeslash.com port 80 |
host www.tildeslash.com port 80 |
1376 |
checksum /usr/local/apache/bin/httpd</PRE> |
checksum /usr/local/apache/bin/httpd</pre> |
1377 |
<P>Some servers are slow starters, like for example Java based |
<p>Some servers are slow starters, like for example Java based |
1378 |
Application Servers. So if we want to keep the poll-cycle low |
Application Servers. So if we want to keep the poll-cycle low |
1379 |
(i.e. < 60 seconds) but allow some programs to take its time to |
(i.e. < 60 seconds) but allow some programs to take its time to |
1380 |
start, the <STRONG>every</STRONG> statement is handy:</P> |
start, the <strong>every</strong> statement is handy:</p> |
1381 |
<PRE> |
<pre> |
1382 |
check dynamo with pidfile /etc/dynamo.pid |
check dynamo with pidfile /etc/dynamo.pid |
1383 |
start program = "/etc/init.d/dynamo start" |
start program = "/etc/init.d/dynamo start" |
1384 |
stop program = "/etc/init.d/dynamo stop" |
stop program = "/etc/init.d/dynamo stop" |
1385 |
port 8840 |
port 8840 |
1386 |
every 2 cycle</PRE> |
every 2 cycle</pre> |
1387 |
<P>Here is an example where we group together two database entries. |
<p>Here is an example where we group together two database entries. |
1388 |
The mode statement is also illustrated in the first entry and |
The mode statement is also illustrated in the first entry and |
1389 |
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 |
1390 |
if it is not running:</P> |
if it is not running:</p> |
1391 |
<PRE> |
<pre> |
1392 |
check sybase with pidfile /var/run/sybase.pid |
check sybase with pidfile /var/run/sybase.pid |
1393 |
start program = "/etc/init.d/sybase start" |
start program = "/etc/init.d/sybase start" |
1394 |
stop program = "/etc/init.d/sybase stop" |
stop program = "/etc/init.d/sybase stop" |
1395 |
mode passive |
mode passive |
1396 |
group database</PRE> |
group database</pre> |
1397 |
<PRE> |
<pre> |
1398 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1399 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1400 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1401 |
mode active # Not necessary really, since this is the default |
mode active # Not necessary really, since this is the default |
1402 |
port 9001 |
port 9001 |
1403 |
alert bofh@foo.bar |
alert bofh@foo.bar |
1404 |
group database</PRE> |
group database</pre> |
1405 |
<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 |
1406 |
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 |
1407 |
child processes raises beyond 60% for over two cycles. It is |
child processes raises beyond 60% for over two cycles. It is |
1408 |
restarted when the CPU usage it over 80% for five cycles, the |
restarted when the CPU usage it over 80% for five cycles, the |
1409 |
memory usage over 100Mb for five cycles or if the machines load |
memory usage over 100Mb for five cycles or if the machines load |
1410 |
average is beyond 10 for 8 cycles:</P> |
average is beyond 10 for 8 cycles:</p> |
1411 |
<PRE> |
<pre> |
1412 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1413 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1414 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1415 |
if cpuusage > 60.0 for 2 cycles then alert |
if cpuusage > 60.0 for 2 cycles then alert |
1416 |
if cpuusage > 80.0 for 5 cycles then restart |
if cpuusage > 80.0 for 5 cycles then restart |
1417 |
if memkbyte > 100000 for 5 cycles then stop |
if memkbyte > 100000 for 5 cycles then stop |
1418 |
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> |
1419 |
<P>In this example we demonstrate usage of the extended alert |
<p>In this example we demonstrate usage of the extended alert |
1420 |
statement:</P> |
statement:</p> |
1421 |
<PRE> |
<pre> |
1422 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1423 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1424 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1430 |
with mail-format { |
with mail-format { |
1431 |
from: bofh@$HOST |
from: bofh@$HOST |
1432 |
subject: apache $EVENT |
subject: apache $EVENT |
1433 |
message: This event occurred on $HOST at $DATE.</PRE> |
message: This event occurred on $HOST at $DATE.</pre> |
1434 |
<PRE> |
<pre> |
1435 |
Your faithful employee, |
Your faithful employee, |
1436 |
monit |
monit |
1437 |
} |
} |
1438 |
timeout (3, 5) |
timeout (3, 5) |
1439 |
group server</PRE> |
group server</pre> |
1440 |
<P>In this example, we demonstrate usage of the depend statement. In |
<p>In this example, we demonstrate usage of the depend statement. In |
1441 |
this case, we want to start oracle and apache. However, we've set |
this case, we want to start oracle and apache. However, we've set |
1442 |
up apache to use oracle as a backend, and if oracle is restarted, |
up apache to use oracle as a backend, and if oracle is restarted, |
1443 |
apache must be restarted as well.</P> |
apache must be restarted as well.</p> |
1444 |
<PRE> |
<pre> |
1445 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1446 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1447 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1448 |
depends on oracle</PRE> |
depends on oracle</pre> |
1449 |
<PRE> |
<pre> |
1450 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1451 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1452 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1453 |
port 9001</PRE> |
port 9001</pre> |
1454 |
<P>In the next example, we have a standard three tier setup with |
<p>In the next example, we have a standard three tier setup with |
1455 |
apache, an application server and a back end database server. |
apache, an application server and a back end database server. |
1456 |
Dependencies are setup so should oracle be restarted then both |
Dependencies are setup so should oracle be restarted then both |
1457 |
apache and the weblogic application server are also restarted.</P> |
apache and the weblogic application server are also restarted.</p> |
1458 |
<PRE> |
<pre> |
1459 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1460 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1461 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1462 |
depends on weblogic</PRE> |
depends on weblogic</pre> |
1463 |
<PRE> |
<pre> |
1464 |
check weblogic with pidfile /var/run/weblogic.pid |
check weblogic with pidfile /var/run/weblogic.pid |
1465 |
start program = "/etc/init.d/weblogic start" |
start program = "/etc/init.d/weblogic start" |
1466 |
stop program = "/etc/init.d/weblogic stop" |
stop program = "/etc/init.d/weblogic stop" |
1467 |
depends on oracle</PRE> |
depends on oracle</pre> |
1468 |
<PRE> |
<pre> |
1469 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1470 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1471 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1472 |
port 9001</PRE> |
port 9001</pre> |
1473 |
<P>Next, we have 2 programs oracle-import and oracle-export that |
<p>Next, we have 2 programs oracle-import and oracle-export that |
1474 |
need to be restarted if oracle is restarted, but are independent |
need to be restarted if oracle is restarted, but are independent |
1475 |
of each other.</P> |
of each other.</p> |
1476 |
<PRE> |
<pre> |
1477 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1478 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1479 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1480 |
port 9001</PRE> |
port 9001</pre> |
1481 |
<PRE> |
<pre> |
1482 |
check oracle-import with pidfile /var/run/oracle-import.pid |
check oracle-import with pidfile /var/run/oracle-import.pid |
1483 |
start program = "/etc/init.d/oracle-import start" |
start program = "/etc/init.d/oracle-import start" |
1484 |
stop program = "/etc/init.d/oracle-import stop" |
stop program = "/etc/init.d/oracle-import stop" |
1485 |
depends on oracle</PRE> |
depends on oracle</pre> |
1486 |
<PRE> |
<pre> |
1487 |
check oracle-export with pidfile /var/run/oracle-export.pid |
check oracle-export with pidfile /var/run/oracle-export.pid |
1488 |
start program = "/etc/init.d/oracle-export start" |
start program = "/etc/init.d/oracle-export start" |
1489 |
stop program = "/etc/init.d/oracle-export stop" |
stop program = "/etc/init.d/oracle-export stop" |
1490 |
depends on oracle</PRE> |
depends on oracle</pre> |
1491 |
<P>Finally an example with all statements:</P> |
<p>Finally an example with all statements:</p> |
1492 |
<PRE> |
<pre> |
1493 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1494 |
group server |
group server |
1495 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1510 |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
1511 |
every 2 cycles |
every 2 cycles |
1512 |
mode active |
mode active |
1513 |
depends on weblogic</PRE> |
depends on weblogic</pre> |
1514 |
<P>Note; only the <STRONG>check-</STRONG> and <STRONG>pidfile statement</STRONG> are mandatory, |
<p>Note; only the <strong>check-</strong> and <strong>pidfile statement</strong> are mandatory, |
1515 |
the other statements are optional and the order of the optional |
the other statements are optional and the order of the optional |
1516 |
statements is not important.</P> |
statements is not important.</p> |
1517 |
<P> |
<p> |
1518 |
<HR> |
</p> |
1519 |
<H1><A NAME="files">FILES</A></H1> |
<hr /> |
1520 |
<P><EM>~/.monitrc</EM> |
<h1><a name="files">FILES</a></h1> |
1521 |
Default run control file</P> |
<p><em>~/.monitrc</em> |
1522 |
<P><EM>./monitrc</EM> |
Default run control file</p> |
1523 |
|
<p><em>./monitrc</em> |
1524 |
If the control file is not found in the default |
If the control file is not found in the default |
1525 |
location, and the current working directory |
location, and the current working directory |
1526 |
contains a <EM>monitrc</EM> file, this file is used |
contains a <em>monitrc</em> file, this file is used |
1527 |
instead.</P> |
instead.</p> |
1528 |
<P><EM>/etc/monitrc</EM> |
<p><em>/etc/monitrc</em> |
1529 |
If the control file is not found in either of the |
If the control file is not found in either of the |
1530 |
previous two locations, and /etc contains a |
previous two locations, and /etc contains a |
1531 |
<EM>monitrc</EM> file, this file will be used instead.</P> |
<em>monitrc</em> file, this file will be used instead.</p> |
1532 |
<P><EM>~/.monitrc.pid</EM> |
<p><em>~/.monitrc.pid</em> |
1533 |
Lock file to help prevent concurrent runs (non-root |
Lock file to help prevent concurrent runs (non-root |
1534 |
mode).</P> |
mode).</p> |
1535 |
<P><EM>/var/run/monit.pid</EM> |
<p><em>/var/run/monit.pid</em> |
1536 |
Lock file to help prevent concurrent runs (root mode, |
Lock file to help prevent concurrent runs (root mode, |
1537 |
Linux systems).</P> |
Linux systems).</p> |
1538 |
<P><EM>/etc/monit.pid</EM> |
<p><em>/etc/monit.pid</em> |
1539 |
Lock file to help prevent concurrent runs (root mode, |
Lock file to help prevent concurrent runs (root mode, |
1540 |
systems without /var/run).</P> |
systems without /var/run).</p> |
1541 |
<P> |
<p> |
1542 |
<HR> |
</p> |
1543 |
<H1><A NAME="signals">SIGNALS</A></H1> |
<hr /> |
1544 |
<P>If a monit daemon is running, SIGUSR1 wakes it up from its sleep |
<h1><a name="signals">SIGNALS</a></h1> |
1545 |
|
<p>If a monit daemon is running, SIGUSR1 wakes it up from its sleep |
1546 |
phase and forces a poll of all processes. SIGTERM will gracefully |
phase and forces a poll of all processes. SIGTERM will gracefully |
1547 |
terminate a monit daemon. This signal is sent to a monit daemon |
terminate a monit daemon. This signal is sent to a monit daemon |
1548 |
if monit is started with the <EM>quit</EM> action argument. Sending a |
if monit is started with the <em>quit</em> action argument.</p> |
1549 |
SIGHUP signal to a running monit daemon will force the daemon to |
<p>Sending a SIGHUP signal to a running monit daemon will force |
1550 |
reload itself, specifically it will close and reopen log files.</P> |
the daemon to reinitialize itself, specifically it will reread |
1551 |
<P>Running monit in foreground while a background monit daemon is |
configuration, close and reopen log files.</p> |
1552 |
running will wake up the daemon.</P> |
<p>Running monit in foreground while a background monit daemon is |
1553 |
<P> |
running will wake up the daemon.</p> |
1554 |
<HR> |
<p> |
1555 |
<H1><A NAME="notes">NOTES</A></H1> |
</p> |
1556 |
<P>This is a very silent program. Use the -v switch if you want to |
<hr /> |
1557 |
see what monit is doing, and tail -f the logfile.</P> |
<h1><a name="notes">NOTES</a></h1> |
1558 |
<P>The syntax (and parser) of the control file is inspired by Eric |
<p>This is a very silent program. Use the -v switch if you want to |
1559 |
|
see what monit is doing, and tail -f the logfile.</p> |
1560 |
|
<p>The syntax (and parser) of the control file is inspired by Eric |
1561 |
S. Raymond et al. excellent fetchmail program. Some portions of |
S. Raymond et al. excellent fetchmail program. Some portions of |
1562 |
this man page does also receive inspiration from the same |
this man page does also receive inspiration from the same |
1563 |
authors.</P> |
authors.</p> |
1564 |
<P> |
<p> |
1565 |
<HR> |
</p> |
1566 |
<H1><A NAME="authors">AUTHORS</A></H1> |
<hr /> |
1567 |
<P>Jan-Henrik Haukeland <<A HREF="mailto:hauk@tildeslash.com">hauk@tildeslash.com</A>>, |
<h1><a name="authors">AUTHORS</a></h1> |
1568 |
Martin Pala <<A HREF="mailto:martin.pala@hq.iol.cz">martin.pala@hq.iol.cz</A>>, |
<p>Jan-Henrik Haukeland <<a href="mailto:hauk@tildeslash.com">hauk@tildeslash.com</a>>, |
1569 |
Christian Hopp <<A HREF="mailto:chopp@iei.tu-clausthal.de">chopp@iei.tu-clausthal.de</A>>, |
Martin Pala <<a href="mailto:martin.pala@hq.iol.cz">martin.pala@hq.iol.cz</a>>, |
1570 |
Rory Toma <<A HREF="mailto:rory@digeo.com">rory@digeo.com</A>>, |
Christian Hopp <<a href="mailto:chopp@iei.tu-clausthal.de">chopp@iei.tu-clausthal.de</a>>, |
1571 |
Thomas Oppel <<A HREF="mailto:oppel@kbis.de">oppel@kbis.de</A>></P> |
Rory Toma <<a href="mailto:rory@digeo.com">rory@digeo.com</a>></p> |
1572 |
<P>See also <A HREF="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</A></P> |
<p>See also <a href="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</a> |
1573 |
<P> |
|
1574 |
<HR> |
</p> |
1575 |
<H1><A NAME="copyright">COPYRIGHT</A></H1> |
<p> |
1576 |
<P>Copyright (C) 2000-2003 by Contributors to the monit codebase. All |
</p> |
1577 |
|
<hr /> |
1578 |
|
<h1><a name="copyright">COPYRIGHT</a></h1> |
1579 |
|
<p>Copyright (C) 2000-2003 by Contributors to the monit codebase. All |
1580 |
Rights Reserved. This product is distributed in the hope that it |
Rights Reserved. This product is distributed in the hope that it |
1581 |
will be useful, but WITHOUT any warranty; without even the |
will be useful, but WITHOUT any warranty; without even the |
1582 |
implied warranty of MERCHANTABILITY or FITNESS for a particular |
implied warranty of MERCHANTABILITY or FITNESS for a particular |
1583 |
purpose.</P> |
purpose. |
1584 |
<P> |
|
1585 |
<HR> |
</p> |
1586 |
<H1><A NAME="see also">SEE ALSO</A></H1> |
<p> |
1587 |
<P>GNU text utilities; md5sum(1); <CODE>openssl(1)</CODE></P> |
</p> |
1588 |
|
<hr /> |
1589 |
|
<h1><a name="see_also">SEE ALSO</a></h1> |
1590 |
|
<p>GNU text utilities; md5sum(1); <code>openssl(1)</code> |
1591 |
|
|
1592 |
|
|
1593 |
|
</p> |
1594 |
|
|
1595 |
</BODY> |
</body> |
1596 |
|
|
1597 |
</HTML> |
</html> |