4 |
<LINK REV="made" HREF="mailto:bhcompile@daffy.perf.redhat.com"> |
<LINK REV="made" HREF="mailto:bhcompile@daffy.perf.redhat.com"> |
5 |
</HEAD> |
</HEAD> |
6 |
|
|
7 |
<BODY> |
<BODY bgcolor="#ffffff"> |
8 |
|
|
9 |
<A NAME="__index__"></A> |
<A NAME="__index__"></A> |
10 |
<!-- INDEX BEGIN --> |
<!-- INDEX BEGIN --> |
20 |
<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> |
21 |
</UL> |
</UL> |
22 |
|
|
23 |
|
<LI><A HREF="#what to monitor">WHAT TO MONITOR</A></LI> |
24 |
|
<LI><A HREF="#how to monitor">HOW TO MONITOR</A></LI> |
25 |
<LI><A HREF="#logging">LOGGING</A></LI> |
<LI><A HREF="#logging">LOGGING</A></LI> |
26 |
<LI><A HREF="#daemon mode">DAEMON MODE</A></LI> |
<LI><A HREF="#daemon mode">DAEMON MODE</A></LI> |
27 |
<LI><A HREF="#init support">INIT SUPPORT</A></LI> |
<LI><A HREF="#init support">INIT SUPPORT</A></LI> |
30 |
<LI><A HREF="#alert messages">ALERT MESSAGES</A></LI> |
<LI><A HREF="#alert messages">ALERT MESSAGES</A></LI> |
31 |
<UL> |
<UL> |
32 |
|
|
33 |
|
<LI><A HREF="#alert message layout">Alert message layout</A></LI> |
34 |
<LI><A HREF="#setting a global mail format">Setting a global mail format</A></LI> |
<LI><A HREF="#setting a global mail format">Setting a global mail format</A></LI> |
35 |
</UL> |
</UL> |
36 |
|
|
37 |
<LI><A HREF="#service timeout">SERVICE TIMEOUT</A></LI> |
<LI><A HREF="#service timeout">SERVICE TIMEOUT</A></LI> |
38 |
<LI><A HREF="#resource testing">RESOURCE TESTING</A></LI> |
<LI><A HREF="#service tests">SERVICE TESTS</A></LI> |
|
<LI><A HREF="#file checksum testing">FILE CHECKSUM TESTING</A></LI> |
|
|
<LI><A HREF="#timestamp testing">TIMESTAMP TESTING</A></LI> |
|
|
<LI><A HREF="#file size testing">FILE SIZE TESTING</A></LI> |
|
|
<LI><A HREF="#connection testing">CONNECTION TESTING</A></LI> |
|
39 |
<UL> |
<UL> |
40 |
|
|
41 |
|
<LI><A HREF="#resource testing">RESOURCE TESTING</A></LI> |
42 |
|
<LI><A HREF="#file checksum testing">FILE CHECKSUM TESTING</A></LI> |
43 |
|
<LI><A HREF="#timestamp testing">TIMESTAMP TESTING</A></LI> |
44 |
|
<LI><A HREF="#file size testing">FILE SIZE TESTING</A></LI> |
45 |
|
<LI><A HREF="#space testing">SPACE TESTING</A></LI> |
46 |
|
<LI><A HREF="#inode testing">INODE TESTING</A></LI> |
47 |
|
<LI><A HREF="#permission testing">PERMISSION TESTING</A></LI> |
48 |
|
<LI><A HREF="#uid testing">UID TESTING</A></LI> |
49 |
|
<LI><A HREF="#gid testing">GID TESTING</A></LI> |
50 |
|
<LI><A HREF="#connection testing">CONNECTION TESTING</A></LI> |
51 |
<UL> |
<UL> |
52 |
|
|
53 |
<UL> |
<UL> |
59 |
|
|
60 |
</UL> |
</UL> |
61 |
|
|
|
<LI><A HREF="#space testing">SPACE TESTING</A></LI> |
|
|
<LI><A HREF="#inode testing">INODE TESTING</A></LI> |
|
|
<LI><A HREF="#permission testing">PERMISSION TESTING</A></LI> |
|
|
<LI><A HREF="#uid testing">UID TESTING</A></LI> |
|
|
<LI><A HREF="#gid testing">GID TESTING</A></LI> |
|
62 |
<LI><A HREF="#monit httpd">MONIT HTTPD</A></LI> |
<LI><A HREF="#monit httpd">MONIT HTTPD</A></LI> |
63 |
<UL> |
<UL> |
64 |
|
|
65 |
<LI><A HREF="#monit httpd authentication">Monit HTTPD Authentication</A></LI> |
<LI><A HREF="#monit httpd authentication">Monit HTTPD Authentication</A></LI> |
66 |
|
<UL> |
67 |
|
|
68 |
|
<UL> |
69 |
|
|
70 |
|
<LI><A HREF="#host allow list">Host allow list</A></LI> |
71 |
|
<LI><A HREF="#basic authentication">Basic Authentication</A></LI> |
72 |
|
</UL> |
73 |
|
|
74 |
|
</UL> |
75 |
|
|
76 |
</UL> |
</UL> |
77 |
|
|
78 |
<LI><A HREF="#dependency checking">DEPENDENCY CHECKING</A></LI> |
<LI><A HREF="#dependency tree">DEPENDENCY TREE</A></LI> |
79 |
<LI><A HREF="#the run control file">THE RUN CONTROL FILE</A></LI> |
<LI><A HREF="#the run control file">THE RUN CONTROL FILE</A></LI> |
80 |
<UL> |
<UL> |
81 |
|
|
85 |
</UL> |
</UL> |
86 |
|
|
87 |
<LI><A HREF="#files">FILES</A></LI> |
<LI><A HREF="#files">FILES</A></LI> |
88 |
|
<LI><A HREF="#environment">ENVIRONMENT</A></LI> |
89 |
<LI><A HREF="#signals">SIGNALS</A></LI> |
<LI><A HREF="#signals">SIGNALS</A></LI> |
90 |
<LI><A HREF="#notes">NOTES</A></LI> |
<LI><A HREF="#notes">NOTES</A></LI> |
91 |
<LI><A HREF="#authors">AUTHORS</A></LI> |
<LI><A HREF="#authors">AUTHORS</A></LI> |
105 |
<P> |
<P> |
106 |
<HR> |
<HR> |
107 |
<H1><A NAME="description">DESCRIPTION</A></H1> |
<H1><A NAME="description">DESCRIPTION</A></H1> |
108 |
<P><STRONG>Monit</STRONG> is a utility for monitoring and managing processes, |
<P><STRONG>monit</STRONG> is a utility for managing and monitoring processes, |
109 |
files, directories and devices on a Unix system. Monit conducts |
files, directories and devices on a Unix system. Monit conducts |
110 |
automatic maintenance and repair and can execute meaningful |
automatic maintenance and repair and can execute meaningful |
111 |
causal actions in error situations. E.g. monit can start a |
causal actions in error situations. E.g. monit can start a |
112 |
process if it does not run, restart a process if it does not |
process if it does not run, restart a process if it does not |
113 |
respond and stop a process if it use to much resources. You may |
respond and stop a process if it uses to much resources. You may |
114 |
use monit to monitor files, directories and devices for changes, |
use monit to monitor files, directories and devices for changes, |
115 |
such as timestamps changes, checksum changes or size changes.</P> |
such as timestamps changes, checksum changes or size changes.</P> |
116 |
<P>Monit is controlled via an easy to configure control file based |
<P>Monit is controlled via an easy to configure control file based |
118 |
to its own log file and notifies you about error conditions via |
to its own log file and notifies you about error conditions via |
119 |
customizable alert messages. Monit can perform various TCP/IP |
customizable alert messages. Monit can perform various TCP/IP |
120 |
network checks, protocol checks and can utilize SSL for such |
network checks, protocol checks and can utilize SSL for such |
121 |
checks. Monit provides a <CODE>HTTP(S)</CODE> interface and you may use a |
checks. Monit provides a <CODE>http(s)</CODE> interface and you may use a |
122 |
browser to access the monit program.</P> |
browser to access the monit program.</P> |
123 |
<P> |
<P> |
124 |
<HR> |
<HR> |
127 |
<EM>and</EM> a run control file, <EM>~/.monitrc</EM>, the syntax of which we |
<EM>and</EM> a run control file, <EM>~/.monitrc</EM>, the syntax of which we |
128 |
describe in a later section. Command-line options override |
describe in a later section. Command-line options override |
129 |
<EM>.monitrc</EM> declarations.</P> |
<EM>.monitrc</EM> declarations.</P> |
130 |
<P>The following options are recognized by monit. It's recommended |
<P>The following options are recognized by monit. However, it is |
131 |
that you set the log and daemon options in the control |
recommended that you set options (when applicable) directly in |
132 |
<EM>.monitrc</EM> file.</P> |
the <EM>.monitrc</EM> control file.</P> |
133 |
<P> |
<P> |
134 |
<H2><A NAME="general options and arguments">General Options and Arguments</A></H2> |
<H2><A NAME="general options and arguments">General Options and Arguments</A></H2> |
135 |
<P><STRONG>-c</STRONG> <EM>file</EM> |
<P><STRONG>-c</STRONG> <EM>file</EM> |
153 |
<P><STRONG>-v</STRONG> |
<P><STRONG>-v</STRONG> |
154 |
Verbose mode, work noisy (diagnostic output)</P> |
Verbose mode, work noisy (diagnostic output)</P> |
155 |
<P><STRONG>-V</STRONG> |
<P><STRONG>-V</STRONG> |
156 |
Print version number and patchlevel</P> |
Print version number and patch level</P> |
157 |
<P><STRONG>-h</STRONG> |
<P><STRONG>-h</STRONG> |
158 |
Print a help text</P> |
Print a help text</P> |
159 |
<P>In addition to the options above, monit can be started with one |
<P>In addition to the options above, monit can be started with one |
160 |
of the following action arguments; monit will then execute the |
of the following action arguments; monit will then execute the |
161 |
action and exit without transforming itself to a deamon.</P> |
action and exit without transforming itself to a daemon.</P> |
162 |
<P><STRONG>start all</STRONG> |
<P><STRONG>start all</STRONG> |
163 |
Start all services listed in the control file and enable |
Start all services listed in the control file and enable |
164 |
monitoring for them. If the group option is set, only |
monitoring for them. If the group option is set, only |
165 |
start and enable monitoring of services in the named group.</P> |
start and enable monitoring of services in the named group.</P> |
166 |
<P><STRONG>start name</STRONG> |
<P><STRONG>start name</STRONG> |
167 |
Start the named service and enable monitoring for it. The |
Start the named service and enable monitoring for it. The |
168 |
name must exist in the monitrc file, after a <EM>check</EM> |
name is a service entry name from the monitrc file.</P> |
|
keyword. See also the MONIT HTTPD section below.</P> |
|
169 |
<P><STRONG>stop all</STRONG> |
<P><STRONG>stop all</STRONG> |
170 |
Stop all services listed in the control file and disable |
Stop all services listed in the control file and disable |
171 |
their monitoring. If the group option is set, only stop and |
their monitoring. If the group option is set, only stop and |
172 |
disable monitoring of the services in the named group.</P> |
disable monitoring of the services in the named group.</P> |
173 |
<P><STRONG>stop name</STRONG> |
<P><STRONG>stop name</STRONG> |
174 |
Stop the named service and disable its monitoring. The name |
Stop the named service and disable its monitoring. The |
175 |
must exist in the monitrc file, after a <EM>check</EM> keyword. |
name is a service entry name from the monitrc file.</P> |
|
See also the MONIT HTTPD section below.</P> |
|
176 |
<P><STRONG>restart all</STRONG> |
<P><STRONG>restart all</STRONG> |
177 |
Stop and start <EM>all</EM> services. If the group option is |
Stop and start <EM>all</EM> services. If the group option is |
178 |
set, only restart the services in the named group.</P> |
set, only restart the services in the named group.</P> |
179 |
<P><STRONG>restart name</STRONG> |
<P><STRONG>restart name</STRONG> |
180 |
Restart the named service. The name must exist in |
Restart the named service. The name is a service entry name |
181 |
the monitrc file, after a <EM>check</EM> keyword. also |
from the monitrc file.</P> |
|
the MONIT HTTPD section below.</P> |
|
182 |
<P><STRONG>monitor all</STRONG> |
<P><STRONG>monitor all</STRONG> |
183 |
Enable monitoring of all services listed in the |
Enable monitoring of all services listed in the |
184 |
control file. If the group option is set, only start |
control file. If the group option is set, only start |
185 |
the services monitoring in the named group.</P> |
the services monitoring in the named group.</P> |
186 |
<P><STRONG>monitor name</STRONG> |
<P><STRONG>monitor name</STRONG> |
187 |
Enable monitoring of the named service. The name must |
Enable monitoring of the named service. The name is a |
188 |
exist in the monitrc file, after a <EM>check</EM> keyword. |
service entry name from the monitrc file. Monit will also |
189 |
Monit will enable monitoring of all services chain which |
enable monitoring of all services this service depends on.</P> |
|
this service depends on before actualy starting monitoring |
|
|
of this service. See also the MONIT HTTPD section below.</P> |
|
190 |
<P><STRONG>unmonitor all</STRONG> |
<P><STRONG>unmonitor all</STRONG> |
191 |
Disable monitoring of all services listed in the |
Disable monitoring of all services listed in the |
192 |
control file. If the group option is set, only stop |
control file. If the group option is set, only disable |
193 |
the services monitoring in the named group.</P> |
monitoring of services in the named group.</P> |
194 |
<P><STRONG>unmonitor name</STRONG> |
<P><STRONG>unmonitor name</STRONG> |
195 |
Disable monitoring of the named service. The name must |
Disable monitoring of the named service. The name is a |
196 |
exist in the monitrc file, after a <EM>check</EM> keyword. |
service entry name from the monitrc file. Monit will also |
197 |
Monit will disable monitoring of the whole services chain |
disable monitoring of all services that depends on this |
198 |
which depends on this service before actualy stopping |
service.</P> |
|
monitoring of this service. See also the MONIT HTTPD |
|
|
section below.</P> |
|
199 |
<P><STRONG>status</STRONG> |
<P><STRONG>status</STRONG> |
200 |
Print status information for each service. If the |
Print status information for each service. If the |
201 |
group option is set, only print the status for the |
group option is set, only print the status for the |
204 |
Reinitialize a running monit daemon, the daemon will |
Reinitialize a running monit daemon, the daemon will |
205 |
reread its configuration, close and reopen log files.</P> |
reread its configuration, close and reopen log files.</P> |
206 |
<P><STRONG>quit</STRONG> |
<P><STRONG>quit</STRONG> |
207 |
Kill monit daemon process</P> |
Kill a monit daemon process</P> |
208 |
<P><STRONG>validate</STRONG> |
<P><STRONG>validate</STRONG> |
209 |
Check all services and start the ones not running. |
Check all services listed in the control file. This action is |
210 |
Also if a process indicates (in the control file) |
also the default behavior when monit runs in daemon mode.</P> |
211 |
that it's listening on a port number, although |
<P> |
212 |
monit cannot connect to the port, then restart the |
<HR> |
213 |
process. This action is also the default |
<H1><A NAME="what to monitor">WHAT TO MONITOR</A></H1> |
214 |
behavior when monit runs in daemon mode.</P> |
<P>You may use monit to monitor daemon processes or similar programs |
215 |
|
running on localhost. Monit is particular useful for monitoring |
216 |
|
daemon processes, such as those started at system boot time from |
217 |
|
/etc/init.d/. For instance sendmail, sshd, apache and mysql. In |
218 |
|
difference to many monitoring systems, monit can act if an error |
219 |
|
situation should occur, e.g.; if sendmail is not running, monit |
220 |
|
can start sendmail or if apache is using to much system resources |
221 |
|
(e.g. if a DoS attack is in progress) monit can stop or restart |
222 |
|
apache and send you an alert message. Monit does also monitor |
223 |
|
process characteristics, such as; if a process has become a |
224 |
|
zombie and how much memory or cpu cycles a process is using.</P> |
225 |
|
<P>You may also use monit to monitor files, directories and devices |
226 |
|
on localhost. Monit can monitor these items for changes, such as |
227 |
|
timestamps changes, checksum changes or size changes. This is |
228 |
|
also useful for security reasons - you can monitor the md5 |
229 |
|
checksum of files that should not change.</P> |
230 |
|
<P>You may even use monit to monitor remote hosts. First and |
231 |
|
foremost monit is a utility for monitoring and mending services |
232 |
|
on localhost, but if a service depends on a remote service, |
233 |
|
e.g. a database server or an application server, it might by |
234 |
|
useful to be able to test a remote host as well.</P> |
235 |
|
<P> |
236 |
|
<HR> |
237 |
|
<H1><A NAME="how to monitor">HOW TO MONITOR</A></H1> |
238 |
|
<P>monit is configured and controlled via a control file called |
239 |
|
<STRONG>monitrc</STRONG>. The default location for this file is ~/.monitrc. If |
240 |
|
this file does not exist, monit will try /etc/monitrc and finally |
241 |
|
./monitrc.</P> |
242 |
|
<P>A monit control file consists of a series of service entries and |
243 |
|
global option statements in a free-format, token-oriented syntax. |
244 |
|
Comments begin with a # and extend through the end of the line. |
245 |
|
There are three kinds of tokens in the control file: grammar |
246 |
|
keywords, numbers and strings.</P> |
247 |
|
<P>On a semantic level, the control file consists of two types of |
248 |
|
entries:</P> |
249 |
|
<OL> |
250 |
|
<LI><STRONG><A NAME="item_Global_set%2Dstatements">Global set-statements</A></STRONG><BR> |
251 |
|
|
252 |
|
A global set-statement starts with the keyword <EM>set</EM> and the |
253 |
|
item to configure. |
254 |
|
<P></P> |
255 |
|
<LI><STRONG><A NAME="item_One_or_more_service_entry_statements%2E">One or more service entry statements.</A></STRONG><BR> |
256 |
|
|
257 |
|
A service entry starts with the keyword <EM>check</EM> followed by the |
258 |
|
service type. |
259 |
|
<P></P></OL> |
260 |
|
<P>This is the hello galaxy version of a monit control file:</P> |
261 |
|
<PRE> |
262 |
|
# |
263 |
|
# monit control file |
264 |
|
#</PRE> |
265 |
|
<PRE> |
266 |
|
set daemon 120 # Poll at 2-minute intervals |
267 |
|
set logfile syslog facility log_daemon |
268 |
|
set httpd port 2812 and use address localhost |
269 |
|
allow localhost # Allow localhost to connect |
270 |
|
allow admin:monit # Allow Basic Auth</PRE> |
271 |
|
<PRE> |
272 |
|
check process apache |
273 |
|
with pidfile "/usr/local/apache/logs/httpd.pid" |
274 |
|
start program = "/etc/init.d/httpd start" |
275 |
|
stop program = "/etc/init.d/httpd stop" |
276 |
|
alert foo@bar.baz |
277 |
|
if 2 restarts within 3 cycles then timeout |
278 |
|
if totalmem > 100 Mb then alert |
279 |
|
if children > 255 for 5 cycles then stop |
280 |
|
if cpu usage > 95% for 3 cycles then restart |
281 |
|
if failed port 80 protocol http request then restart |
282 |
|
group server |
283 |
|
depends on httpd.conf, httpd.bin</PRE> |
284 |
|
<PRE> |
285 |
|
check file httpd.conf |
286 |
|
with path /usr/local/apache/conf/httpd.conf |
287 |
|
# Restart apache if the httpd.conf file was changed |
288 |
|
if failed checksum then restart</PRE> |
289 |
|
<PRE> |
290 |
|
check file httpd.bin |
291 |
|
with path /usr/local/apache/bin/httpd |
292 |
|
# Alert and unmonitor apache if the binary was changed |
293 |
|
if failed checksum then unmonitor |
294 |
|
alert foo@bar.baz</PRE> |
295 |
|
<P>This example illustrate a service entry for monitoring the apache |
296 |
|
web server process as well as related files. The meaning of the |
297 |
|
various statements will be explained in the following sections.</P> |
298 |
<P> |
<P> |
299 |
<HR> |
<HR> |
300 |
<H1><A NAME="logging">LOGGING</A></H1> |
<H1><A NAME="logging">LOGGING</A></H1> |
301 |
<P>monit will log status and error messages to a log file. If |
<P>monit will log status and error messages to a log file. If |
302 |
<STRONG>syslog</STRONG> is given as a value for the <EM>-l</EM> option (or the |
<STRONG>syslog</STRONG> is given as a value for the <EM>-l</EM> command-line switch |
303 |
keyword <EM>set logfile syslog</EM> is found in the control file) monit |
(or the keyword <EM>set logfile syslog</EM> is found in the control |
304 |
will use the <STRONG>syslog</STRONG> system daemon for logging messages. To |
file) monit will use the <STRONG>syslog</STRONG> system daemon for logging |
305 |
turn off logging, simply do not set the logfile in the control |
messages. To turn off logging, simply do not set the logfile in |
306 |
file (and of course, do not use the -l switch)</P> |
the control file (and of course, do not use the -l switch)</P> |
307 |
<P> |
<P> |
308 |
<HR> |
<HR> |
309 |
<H1><A NAME="daemon mode">DAEMON MODE</A></H1> |
<H1><A NAME="daemon mode">DAEMON MODE</A></H1> |
310 |
<P>The <EM>-d interval</EM> option runs monit in daemon mode. You must |
<P>The <EM>-d interval</EM> command-line switch runs monit in daemon |
311 |
specify a numeric argument which is a polling interval in |
mode. You must specify a numeric argument which is a polling |
312 |
seconds.</P> |
interval in seconds.</P> |
313 |
<P>In daemon mode, monit puts itself in the background and runs |
<P>In daemon mode, monit detaches from the console, puts itself in |
314 |
continously, monitoring each specified service and then sleeping |
the background and runs continuously, monitoring each specified |
315 |
for the given polling interval.</P> |
service and then goes to sleep for the given poll interval.</P> |
316 |
<PRE> |
<PRE> |
317 |
Simply invoking</PRE> |
Simply invoking</PRE> |
318 |
<PRE> |
<PRE> |
319 |
monit -d 300</PRE> |
monit -d 300</PRE> |
320 |
<P>will poll all services described in your <EM>~/.monitrc</EM> file every |
<P>will poll all services described in your <EM>~/.monitrc</EM> file every |
321 |
5 minutes.</P> |
5 minutes.</P> |
322 |
<P>It is possible and recommended to set a polling interval in your |
<P>It is possible and also strongly recommended to you set the poll |
323 |
~/.monitrc file by saying 'set daemon <STRONG>n</STRONG>', where <STRONG>n</STRONG> is an |
interval in your ~/.monitrc file by using 'set daemon <STRONG>n</STRONG>', |
324 |
integer number of seconds. If you do this, monit will always |
where <STRONG>n</STRONG> is an integer number of seconds. If you do this, |
325 |
start in daemon mode (as long as no action arguments are given).</P> |
monit will always start in daemon mode (as long as no action |
326 |
|
arguments are given).</P> |
327 |
<P>Monit makes a per-instance lockfile in daemon mode. If you need |
<P>Monit makes a per-instance lockfile in daemon mode. If you need |
328 |
more monit instances, you will need more configuration files, |
more monit instances, you will need more configuration files, |
329 |
each pointing to its own lockfile.</P> |
each pointing to its own lockfile.</P> |
330 |
<P>Calling monit with a daemon in the background sends a wakeup |
<P>Calling monit with a monit daemon running in the background sends |
331 |
signal to the daemon, forcing it to check services immediately.</P> |
a wakeup signal to the daemon, forcing it to check services |
332 |
|
immediately.</P> |
333 |
<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 |
334 |
of waking it up.</P> |
of waking it up.</P> |
335 |
<P> |
<P> |
336 |
<HR> |
<HR> |
337 |
<H1><A NAME="init support">INIT SUPPORT</A></H1> |
<H1><A NAME="init support">INIT SUPPORT</A></H1> |
338 |
<P>Monit can be run and controlled from <EM>init</EM>. In case monit |
<P>Monit can run and be controlled from <EM>init</EM>. If monit should |
339 |
crashes init will respawn a new monit process.</P> |
crash <EM>init</EM> will re-spawn a new monit process. Using init to |
340 |
<P>You can use either the 'set init' statement in monit's |
start monit is probably the best way to run monit if you want to |
341 |
configuration file or use the -I option from the command line. |
be certain that you always have a running monit daemon on your |
342 |
Here's a sample /etc/inittab entry for monit:</P> |
system. (It's obvious, but never the less worth to stress; Make |
343 |
|
sure that the control file does not have any syntax errors before |
344 |
|
you start monit from init. Also, make sure that if you run monit |
345 |
|
from init, that you do not start monit in your startup scripts as |
346 |
|
well).</P> |
347 |
|
<P>To setup monit to run from init, you can either use the 'set |
348 |
|
init' statement in monit's control file or use the -I option from |
349 |
|
the command line. Here is a sample /etc/inittab entry for monit:</P> |
350 |
<PRE> |
<PRE> |
351 |
# Run monit in standard runlevels |
# Run monit in standard run-levels |
352 |
mo:2345:respawn:/usr/local/sbin/monit -Ic /etc/monitrc</PRE> |
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc</PRE> |
353 |
<P>After you have modified init's configuration file, you can run |
<P>After you have modified init's configuration file, you can run |
354 |
the following command to re-examine /etc/inittab and start monit:</P> |
the following command to re-examine /etc/inittab and start monit:</P> |
355 |
<PRE> |
<PRE> |
360 |
For systems without telinit:</PRE> |
For systems without telinit:</PRE> |
361 |
<PRE> |
<PRE> |
362 |
kill -1 1</PRE> |
kill -1 1</PRE> |
|
<P>Make sure that if you run monit from init, that you do not start |
|
|
monit in your startup scripts as well.</P> |
|
363 |
<P> |
<P> |
364 |
<HR> |
<HR> |
365 |
<H1><A NAME="group support">GROUP SUPPORT</A></H1> |
<H1><A NAME="group support">GROUP SUPPORT</A></H1> |
372 |
entries together and manage them as a whole. Monit provides |
entries together and manage them as a whole. Monit provides |
373 |
functions to start, stop and restart a group of services, like |
functions to start, stop and restart a group of services, like |
374 |
so:</P> |
so:</P> |
375 |
<P>To start a group of services:</P> |
<P>To start a group of services from the console:</P> |
376 |
<PRE> |
<PRE> |
377 |
monit -g <groupname> start</PRE> |
monit -g <groupname> start</PRE> |
378 |
<P>To stop a group of services:</P> |
<P>To stop a group of services:</P> |
387 |
<P> |
<P> |
388 |
<HR> |
<HR> |
389 |
<H1><A NAME="monitoring mode">MONITORING MODE</A></H1> |
<H1><A NAME="monitoring mode">MONITORING MODE</A></H1> |
390 |
<P>Monit supports three monitoring modes per service: active, |
<P>Monit supports three monitoring modes per service: <EM>active</EM>, |
391 |
passive and manual. See also the example section below for usage |
<EM>passive</EM> and <EM>manual</EM>. See also the example section below for |
392 |
of the mode statement.</P> |
usage of the mode statement.</P> |
393 |
<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 |
394 |
problems monit will act and raise alerts, start, stop or restart |
problems monit will act and raise alerts, start, stop or restart |
395 |
the service. Active mode is the default mode.</P> |
the service. Active mode is the default mode.</P> |
398 |
alerts in case of a problem.</P> |
alerts in case of a problem.</P> |
399 |
<P>For use in clustered environments there is also a <EM>manual</EM> |
<P>For use in clustered environments there is also a <EM>manual</EM> |
400 |
mode. In this mode, monit will enter <EM>active</EM> mode <STRONG>only</STRONG> if a |
mode. In this mode, monit will enter <EM>active</EM> mode <STRONG>only</STRONG> if a |
401 |
service was brough under monit's control, for example by:</P> |
service was brought under monit's control, for example by |
402 |
<PRE> |
executing the following command in the console:</P> |
|
monit start sybase (it will call start method and enable |
|
|
monitoring)</PRE> |
|
|
<P>or</P> |
|
|
<PRE> |
|
|
monit -g database start (for service group)</PRE> |
|
|
<P>or</P> |
|
403 |
<PRE> |
<PRE> |
404 |
monit monitor sybase (it will just enable monitoring)</PRE> |
monit start sybase |
405 |
<P>or</P> |
(monit will call sybase's start method and enable monitoring)</PRE> |
406 |
<PRE> |
<P>If a service was not started by monit or was stopped or disabled |
407 |
monit -g database monitor (for service group)</PRE> |
for example by:</P> |
408 |
<P>If the service wasn't started by monit or was stopped or |
<PRE> |
409 |
disabled for example by:</P> |
monit stop sybase |
410 |
<PRE> |
(monit will call sybase's stop method and disable monitoring)</PRE> |
411 |
monit stop sybase (it will call stop method and disable |
<P>monit will not monitor the service. This allows for having |
|
monitoring)</PRE> |
|
|
<P>or</P> |
|
|
<PRE> |
|
|
monit -g database stop (for service group)</PRE> |
|
|
<P>or</P> |
|
|
<PRE> |
|
|
monit unmonitor sybase (it will just disable monitoring)</PRE> |
|
|
<P>or</P> |
|
|
<PRE> |
|
|
monit -g database unmonitor (for service group)</PRE> |
|
|
<P>monit will not monitor the service at all. This allows for having |
|
412 |
services configured in monitrc and start it with monit only if it |
services configured in monitrc and start it with monit only if it |
413 |
should run. This can be used to build simple failsafe clusters. |
should run. This feature can be used to build a simple failsafe |
414 |
You can read more about how you can setup a cluster with monit |
cluster. To see how, read more about how to setup a cluster with |
415 |
using the <EM>heartbeat</EM> system in the examples sections below.</P> |
monit using the <EM>heartbeat</EM> system in the examples sections |
416 |
|
below.</P> |
417 |
<P> |
<P> |
418 |
<HR> |
<HR> |
419 |
<H1><A NAME="alert messages">ALERT MESSAGES</A></H1> |
<H1><A NAME="alert messages">ALERT MESSAGES</A></H1> |
421 |
<PRE> |
<PRE> |
422 |
o A service timed out |
o A service timed out |
423 |
o A service was stopped |
o A service was stopped |
|
o A service monitoring was disabled (unmonitor) |
|
424 |
o A port connection failed |
o A port connection failed |
425 |
o A resource statement match |
o A resource statement match |
426 |
o A permission error occurred |
o A permission error occurred |
429 |
o A file size test didn't pass |
o A file size test didn't pass |
430 |
o A service was started or restarted |
o A service was started or restarted |
431 |
o A file/directory/device uid error occurred |
o A file/directory/device uid error occurred |
432 |
o A file/directory/device gid error occurred</PRE> |
o A file/directory/device gid error occurred |
433 |
<P>More than one alert statement can be used in a service entry. |
o Monitoring of a service was disabled (unmonitor)</PRE> |
434 |
This means that you can send different emails to different |
<P>You should use an alert statement to notify monit that you want |
435 |
addresses. The full syntax for the alert statement is as |
alert messages sent to an email address. If you do not specify an |
436 |
follows (keywords are in capital):</P> |
alert statement, monit will not send alert messages.</P> |
437 |
<PRE> |
<P>An alert statement is bound to a service entry and you can also |
438 |
ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</PRE> |
use more than one alert statement in an entry. In other words, |
439 |
|
you can send many different emails to many different |
440 |
|
addresses. (Just to make it clear, in case you now got a new |
441 |
|
business idea; monit is not suitable for sending spam). The full |
442 |
|
syntax for the alert statement is as follows (keywords are in |
443 |
|
capital):</P> |
444 |
|
<DL> |
445 |
|
<DT><STRONG><A NAME="item_ALERT_mail%2Daddress_%5B%7Bevents%7D%5D_%5BMAIL%2D">ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</A></STRONG><BR> |
446 |
|
<DD> |
447 |
|
</DL> |
448 |
<P>Simply using:</P> |
<P>Simply using:</P> |
449 |
<PRE> |
<PRE> |
450 |
alert foo@bar</PRE> |
alert foo@bar</PRE> |
451 |
<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 |
452 |
timeout, start, restart, checksum, resource, stop, connection, size, |
an event occurred on the service. Such an event may be that a |
453 |
permission, uid, gid, unmonitor or timestamp error occurs.</P> |
service timed out, a service was started or stopped and so on.</P> |
454 |
<P>If you only want an alert message sent when a certain event |
<P>If you only want an alert message sent for certain events, for |
455 |
occurs for example a timeout or when a service is restarted, |
example only for timeout events or only if a service was |
456 |
postfix the alert-statement respectively</P> |
restarted, then postfix the alert-statement with a filter block, |
457 |
<PRE> |
respectively:</P> |
458 |
alert foo@bar only on { timeout } or |
<PRE> |
459 |
alert foo@bar { timeout }</PRE> |
alert foo@bar only on { timeout } and |
460 |
<P>(<EM>only</EM> and <EM>on</EM> are noise keywords, ignored by monit)</P> |
alert foo@bar only on { restart }</PRE> |
461 |
<P>or</P> |
<P>(<EM>only</EM> and <EM>on</EM> are noise keywords, ignored by monit. As a |
462 |
<PRE> |
side note; Noise keywords are used in the control file grammar to |
463 |
alert foo@bar { restart }</PRE> |
make an entry resemble English and thus make it easier to read |
464 |
<P>The same applies for a checksum error</P> |
(or, so goes the philosophy). The full set of available noise |
465 |
|
keywords are listed below in the Control File section)</P> |
466 |
|
<P>It is also possible to combine alert events and send mail to |
467 |
|
different email addresses depending on the events. Like so:</P> |
468 |
<PRE> |
<PRE> |
469 |
alert foo@bar { checksum }</PRE> |
alert foo@bar { restart, timeout, resource, connection } |
470 |
<P>It is also possible to combine events and send mail to different |
alert security@bar on { checksum, permission, uid, gid, stop } |
|
email addresses like:</P> |
|
|
<PRE> |
|
|
alert foo@bar { restart, timeout, resource, connection, |
|
|
unmonitor } |
|
|
alert security@bar on { checksum, permission, uid, gid, |
|
|
stop, unmonitor } |
|
471 |
alert manager@bar</PRE> |
alert manager@bar</PRE> |
472 |
<P>This will send an alert message to foo@bar whenever a restart, |
<P>This will send an alert message to foo@bar whenever a restart, |
473 |
timeout, resource or connection error occurs and a message to |
timeout, resource or connection error occurs and a message to |
474 |
security@bar if a checksum, permission, uid, gid or stop error |
security@bar if a checksum, permission, uid, gid or stop error |
475 |
occurs. And finally, a message to manager@bar whenever any |
occurs. And finally, a message to manager@bar whenever any error |
476 |
error event occurs. |
event occurs.</P> |
477 |
</P> |
<P>The following alert-statement:</P> |
478 |
<PRE> |
<PRE> |
479 |
|
alert foo@bar {uid |
|
The following alert-statement:</PRE> |
|
|
<PRE> |
|
|
|
|
|
alert foo@bar {checksum |
|
|
connection |
|
480 |
gid |
gid |
|
permission |
|
|
resource |
|
|
restart |
|
|
start |
|
481 |
size |
size |
482 |
stop |
stop |
483 |
|
start |
484 |
|
restart |
485 |
timeout |
timeout |
486 |
|
resource |
487 |
|
checksum |
488 |
timestamp |
timestamp |
489 |
uid |
unmonitor |
490 |
unmonitor}</PRE> |
connection |
491 |
|
permission}</PRE> |
492 |
<P>is equivalent to:</P> |
<P>is equivalent to:</P> |
493 |
<PRE> |
<PRE> |
494 |
alert foo@bar</PRE> |
alert foo@bar</PRE> |
495 |
<P>which as stated above, will send a message whenever a timeout, a |
<P> |
496 |
start, restart, checksum, resource, stop, connection, size, |
<H2><A NAME="alert message layout">Alert message layout</A></H2> |
497 |
permission, uid, gid, unmonitor or timestamp error occurs. (If |
<P>monit provides a default mail message layout that is short and to |
498 |
the postfix variant is used, then note that the parenthesis are |
the point. Here's an example of a standard alert mail sent by |
499 |
<EM>mandatory</EM>).</P> |
monit:</P> |
|
<P>A start, stop or restart alert is also sent <EM>if monit fails to |
|
|
execute</EM> a start or stop program for an entry. <STRONG>It is therefore |
|
|
strongly advised</STRONG> that at least one alert statement register |
|
|
interest for either, start, stop or restart alerts.</P> |
|
|
<P>monit will provide a default mail message layout that is short |
|
|
and to the point. Here's an example of a standard alert mail sent |
|
|
by monit:</P> |
|
500 |
<PRE> |
<PRE> |
501 |
From: monit@tildeslash.com |
From: monit@tildeslash.com |
502 |
Subject: monit alert -- Restarted apache |
Subject: monit alert -- Restarted apache |
503 |
To: hauk@tildeslash.com |
To: hauk@tildeslash.com |
504 |
Date: Mon, 04 Aug 2003 06:26:54 +0200</PRE> |
Date: Thu, 04 Sep 2003 02:33:03 +0200</PRE> |
505 |
<PRE> |
<PRE> |
506 |
Restarted Service apache</PRE> |
Restarted Service apache</PRE> |
507 |
<PRE> |
<PRE> |
508 |
Date: Tue May 28 20:42:30 2002 |
Date: Thu, 04 Sep 2003 02:33:03 +0200 |
509 |
Host: www.tildeslash.com</PRE> |
Host: www.tildeslash.com</PRE> |
510 |
<PRE> |
<PRE> |
511 |
Your faithful employee, |
Your faithful employee, |
516 |
<PRE> |
<PRE> |
517 |
mail-format { |
mail-format { |
518 |
from: monit@localhost |
from: monit@localhost |
519 |
subject: apache $EVENT at $DATE |
subject: $SERVICE $EVENT at $DATE |
520 |
message: Monit restarted $SERVICE at $DATE on $HOST. |
message: Monit restarted $SERVICE at $DATE on $HOST. |
521 |
Yours sincerely, |
Yours sincerely, |
522 |
monit |
monit |
523 |
}</PRE> |
}</PRE> |
524 |
<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 |
525 |
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 |
526 |
address, but must be a proper formated mail address, in the form: |
address, but it must be a proper formated mail address, on the |
527 |
name@domain. The keyword <EM>subject:</EM> is for the email subject |
form: name@domain. The keyword <EM>subject:</EM> is for the email |
528 |
line. The subject must be on only <EM>one</EM> line. The <EM>message:</EM> |
subject line. The subject must be on only <EM>one</EM> line. The |
529 |
keyword denotes the mail body. If used, this keyword should |
<EM>message:</EM> keyword denotes the mail body. If used, this keyword |
530 |
always be the last in a mail-format statement. The mail body can |
should always be the last in a mail-format statement. The mail |
531 |
be as long as you want and must <STRONG>not</STRONG> contain the '}' character.</P> |
body can be as long as you want and must <STRONG>not</STRONG> contain the '}' |
532 |
|
character.</P> |
533 |
<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 |
534 |
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 |
535 |
is using you can do:</P> |
is using you can do:</P> |
536 |
<PRE> |
<PRE> |
537 |
alert foo@bar with mail-format { from: bofh@xyzzy.no }</PRE> |
alert foo@bar with mail-format { from: bofh@xyzzy.no }</PRE> |
538 |
<P>From the previous example you will notice that 4 special |
<P>From the previous example you will notice that 4 special |
539 |
variables was used. If used they will be substituted into the |
variables was used. If used, they will be substituted and |
540 |
text with a special value:</P> |
expanded into the text with these values:</P> |
541 |
<P><EM>$EVENT</EM> A string describing the event that occured. The values |
<UL> |
542 |
|
<LI> |
543 |
|
<EM>$EVENT</EM> A string describing the event that occurred. The values |
544 |
are fixed and are, ``Started'', ``Stopped'', ``Restarted'', Checksum |
are fixed and are, ``Started'', ``Stopped'', ``Restarted'', Checksum |
545 |
error``, ''Resource limit matched``, ''Timeout``, ''Size rule matched``, |
changed``, ''Resource limit matched``, ''Timeout``, ''Size rule |
546 |
''Permission error``, ''Connection test failed``, ''UID error``, ''GID |
matched``, ''Permission error``, ''Connection test failed``, ''UID |
547 |
error``, ''Monitoring disabled`` and ''Timestamp rule matched``.</P> |
error``, ''GID error``, ''Monitoring disabled`` and ''Timestamp rule |
548 |
<P><EM>$SERVICE</EM> The service entry name in monitrc (old form |
matched``. |
549 |
<EM>$PROGRAM</EM> is supported too but not recommended).</P> |
<P></P> |
550 |
<P><EM>$DATE</EM> The current time and date (RFC 822 date style).</P> |
<LI> |
551 |
<P><EM>$HOST</EM> The name of the host monit is running on</P> |
<EM>$SERVICE</EM> The service entry name in monitrc |
552 |
|
<P></P> |
553 |
|
<LI> |
554 |
|
<EM>$DATE</EM> The current time and date (RFC 822 date style). |
555 |
|
<P></P> |
556 |
|
<LI> |
557 |
|
<EM>$HOST</EM> The name of the host monit is running on |
558 |
|
<P></P></UL> |
559 |
<P> |
<P> |
560 |
<H2><A NAME="setting a global mail format">Setting a global mail format</A></H2> |
<H2><A NAME="setting a global mail format">Setting a global mail format</A></H2> |
561 |
<P>Finally, it is possible to set a standard mail format with the |
<P>Finally, it is possible to set a standard mail format with the |
562 |
following global set-statement (keywords are in capital): |
following global set-statement (keywords are in capital):</P> |
563 |
</P> |
<DL> |
564 |
<PRE> |
<DT><STRONG><A NAME="item_SET_MAIL%2DFORMAT_%7Bmail%2Dformat%7D">SET MAIL-FORMAT {mail-format}</A></STRONG><BR> |
565 |
|
<DD> |
566 |
SET MAIL-FORMAT {mail-format}</PRE> |
</DL> |
567 |
<P>Format set with this statement will apply to every alert |
<P>Format set with this statement will apply to every alert |
568 |
statement that does <EM>not</EM> have its own specified mail-format. |
statement that does <EM>not</EM> have its own specified mail-format. |
569 |
This statement is most usefull for setting a default from address |
This statement is most useful for setting a default from address |
570 |
for messages sent by monit, like so:</P> |
for messages sent by monit, like so:</P> |
571 |
<PRE> |
<PRE> |
572 |
set mail-format { from: monit@foo.bar.no }</PRE> |
set mail-format { from: monit@foo.bar.no }</PRE> |
584 |
<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 |
585 |
not (re)start the service on the next cycle. If a timeout occurs |
not (re)start the service on the next cycle. If a timeout occurs |
586 |
monit will send you an alert message if you have register |
monit will send you an alert message if you have register |
587 |
interest for this event. See the alert statement above to learn |
interest for this event.</P> |
|
how you may recieve timeout alert messages.</P> |
|
588 |
<P>The syntax for the timestamp statement is as follows (keywords |
<P>The syntax for the timestamp statement is as follows (keywords |
589 |
are in capital):</P> |
are in capital):</P> |
590 |
<DL> |
<DL> |
591 |
<DT><STRONG><A NAME="item_IF_NUMBER_RESTART_NUMBER_CYCLE_THEN_TIMEOUT">IF NUMBER RESTART NUMBER CYCLE THEN TIMEOUT</A></STRONG><BR> |
<DT><STRONG><A NAME="item_CYCLE">IF NUMBER RESTART NUMBER <CODE>CYCLE(S)</CODE> THEN TIMEOUT</A></STRONG><BR> |
592 |
<DD> |
<DD> |
593 |
</DL> |
</DL> |
594 |
<P>Where the first number is the number of service restarts, the |
<P>Where the first number is the number of service restarts and the |
595 |
second is the number of poll-cycles. If the number of cycles was |
second, the number of poll-cycles. If the number of cycles was |
596 |
reached without a timeout, the service start-counter is reset to |
reached without a timeout, the service start-counter is reset to |
597 |
zero. This provides some granularity to catch expectional cases |
zero. This provides some granularity to catch exceptional cases |
598 |
and do a service timeout, but let occasional service start and |
and do a service timeout, but let occasional service start and |
599 |
restarts happen without having an accumulated timeout.</P> |
restarts happen without having an accumulated timeout.</P> |
600 |
<P>Here is an example where monit will timeout (not check the |
<P>Here is an example where monit will timeout (not check the |
607 |
the service again.</P> |
the service again.</P> |
608 |
<P> |
<P> |
609 |
<HR> |
<HR> |
610 |
<H1><A NAME="resource testing">RESOURCE TESTING</A></H1> |
<H1><A NAME="service tests">SERVICE TESTS</A></H1> |
611 |
|
<P>monit provides several if-tests you may utilize in a service |
612 |
|
entry to test a service. Each if-test statement is on the |
613 |
|
following general format:</P> |
614 |
|
<DL> |
615 |
|
<DT><STRONG><A NAME="item_IF_%3CTEST%3E_THEN_ACTION">IF <TEST> THEN ACTION</A></STRONG><BR> |
616 |
|
<DD> |
617 |
|
</DL> |
618 |
|
<P>If the test should validate to true then the selected action is |
619 |
|
executed. You must select the action to be executed from the list |
620 |
|
below:</P> |
621 |
|
<UL> |
622 |
|
<LI> |
623 |
|
<STRONG>ALERT</STRONG> sends the user an alert event. |
624 |
|
<P></P> |
625 |
|
<LI> |
626 |
|
<STRONG>RESTART</STRONG> restarts the service <EM>and</EM> sends an alert. Restart is |
627 |
|
conducted by first calling the service's registered stop method |
628 |
|
and then the service's start method. |
629 |
|
<P></P> |
630 |
|
<LI> |
631 |
|
<STRONG>STOP</STRONG> stops the service by calling the service's registered stop |
632 |
|
method <EM>and</EM> send an alert. If monit stops a service it will not |
633 |
|
be checked by monit anymore nor restarted again later. To |
634 |
|
reactivate monitoring of the service again you must explicitly |
635 |
|
enable monitoring from the web interface or from the console, |
636 |
|
e.g. 'monit monitor apache'. |
637 |
|
<P></P> |
638 |
|
<LI> |
639 |
|
<STRONG>EXEC</STRONG> may be used to execute an arbitrary program <EM>and</EM> send |
640 |
|
an alert. If you choose this action you must state the program to |
641 |
|
be executed. You may also optionally specify the uid and gid the |
642 |
|
executed program should switch to upon start. For instance: |
643 |
|
<PRE> |
644 |
|
exec "/usr/local/tomcat/bin/startup.sh" |
645 |
|
as uid nobody and gid nobody</PRE> |
646 |
|
<P>This may be useful if the program to be started cannot change to |
647 |
|
a lesser privileged user and group. This is typically needed for |
648 |
|
Java Servers. If monit is run by the superuser, the program monit |
649 |
|
execute will be started with superuser privileges unless the uid |
650 |
|
and gid extension was used.</P> |
651 |
|
<P></P> |
652 |
|
<LI> |
653 |
|
<STRONG>UNMONITOR</STRONG> will disable monitoring of the service <EM>and</EM> send |
654 |
|
an alert. The service will not be checked by monit anymore nor |
655 |
|
restarted again later. To reactivate monitoring of the service |
656 |
|
you must explicitly enable monitoring from monit's web interface |
657 |
|
or from the console using the monitor argument. |
658 |
|
<P></P></UL> |
659 |
|
<P> |
660 |
|
<H2><A NAME="resource testing">RESOURCE TESTING</A></H2> |
661 |
<P>Monit can examine how much system resources a service or the |
<P>Monit can examine how much system resources a service or the |
662 |
system is using.</P> |
system is using. This test may only be used within a process |
663 |
<P>Depending on this indicator services can be stopped or restarted |
service entry in the monit control file.</P> |
664 |
and alerts can be generated. Thus it is possible to utilize |
<P>Depending on process characteristics, services can be stopped or |
665 |
systems which are idle and to spare system under high load.</P> |
restarted and alerts can be generated. Thus it is possible to |
666 |
|
utilize systems which are idle and to spare system under high |
667 |
|
load.</P> |
668 |
<P>The full syntax for the resource-statements used for resource |
<P>The full syntax for the resource-statements used for resource |
669 |
testing is as follows (keywords are in capital and optional |
testing is as follows (keywords are in capital and optional |
670 |
statements in [brackets]),</P> |
statements in [brackets]),</P> |
676 |
``TOTALMEMORY'', ``LOADAVG([1min|5min|15min]):</P> |
``TOTALMEMORY'', ``LOADAVG([1min|5min|15min]):</P> |
677 |
<P>CPU is the CPU usage of the process and it's children in |
<P>CPU is the CPU usage of the process and it's children in |
678 |
parts of hundred (percent).</P> |
parts of hundred (percent).</P> |
679 |
<P>MEMORY is the memory usage of the process without it's child |
<P>MEMORY is the memory usage of the process without it's child |
680 |
processes in wheather in parts of hundred (percent) or as an |
processes in either percent (of the systems total) or as an |
681 |
amount (Byte, kB, MB, GB).</P> |
amount (Byte, kB, MB, GB).</P> |
682 |
<P>CHILDREN is the number of child processes of the process.</P> |
<P>CHILDREN is the number of child processes of the process.</P> |
683 |
<P>TOTALMEMORY is the memory usage of the process and it's child |
<P>TOTALMEMORY is the memory usage of the process and it's child |
684 |
processes in whether in parts of hundred (percent) or as an |
processes in either percent or as an amount (Byte, kB, MB, GB).</P> |
|
amount (Byte, kB, MB, GB).</P> |
|
685 |
<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. |
686 |
The load average is the number of processes in the system run |
The load average is the number of processes in the system run |
687 |
queue averaged over the specified time period. This resource</P> |
queue, averaged over the specified time period.</P> |
688 |
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
689 |
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
690 |
``equal'', ``notequal'' in human readable form (if not specified, |
``equal'', ``notequal'' in human readable form (if not specified, |
691 |
default is EQUAL).</P> |
default is EQUAL).</P> |
692 |
<P><EM>value</EM> is whether an integer number or a fixed point number |
<P><EM>value</EM> is either an integer or a real number (except for |
693 |
(except for CHILDREN). For CPU, MEMORY and TOTALMEMORY you need |
CHILDREN). For CPU, MEMORY and TOTALMEMORY you need to specify a |
694 |
to specify a <EM>unit</EM>. This could be ``%'' or if applicable ``B'' |
<EM>unit</EM>. This could be ``%'' or if applicable ``B'' (Byte), ``kB'' |
695 |
(Byte), ``kB'' (1024 Byte), ``MB'' (1024 KiloByte) or ``GB'' (1024 |
(1024 Byte), ``MB'' (1024 KiloByte) or ``GB'' (1024 MegaByte).</P> |
|
MegaByte).</P> |
|
696 |
<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 |
697 |
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. To specify the number |
698 |
omitted then it is set to one.</P> |
of cycles you must state a number followed by the keyword CYCLES. |
699 |
|
If <EM>cycles</EM> is omitted then the default is one cycle.</P> |
700 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
701 |
``UNMONITOR'':</P> |
``UNMONITOR''.</P> |
|
<UL> |
|
|
<LI> |
|
|
ALERT ALERT sends the user a resource alert in case the maximum |
|
|
number of cycles has been reached. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service in case the maximum number of cycles |
|
|
has been reached. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will not be |
|
|
checked by monit anymore nor restarted again later. You must |
|
|
explicitly start it again from the web interface or from the |
|
|
console, like: 'monit start apache' or 'monit monitor apache' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/etc/init.d/network restart'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
702 |
<P>To calculate the cycles, a counter is raised whenever the |
<P>To calculate the cycles, a counter is raised whenever the |
703 |
expression above is true and it is lowered whenever it is false |
expression above is true and it is lowered whenever it is false |
704 |
(but not below 0). All counters are reseted in case of a restart.</P> |
(but not below 0). All counters are reset in case of a restart.</P> |
705 |
<P>In order to check that the CPU usage of a service is not going |
<P>The following is an example to check that the CPU usage of a |
706 |
beyond 50% for five cycles before restarting it, the following |
service is not going beyond 50% during five poll cycles. If it |
707 |
expression could be used:</P> |
does, monit will restart the service:</P> |
708 |
<PRE> |
<PRE> |
709 |
if cpu is greater than 50% for 5 cycles then restart</PRE> |
if cpu is greater than 50% for 5 cycles then restart</PRE> |
710 |
<P>See also the example section below.</P> |
<P>See also the example section below.</P> |
711 |
<P> |
<P> |
712 |
<HR> |
<H2><A NAME="file checksum testing">FILE CHECKSUM TESTING</A></H2> |
|
<H1><A NAME="file checksum testing">FILE CHECKSUM TESTING</A></H1> |
|
713 |
<P>If specified in the control file, monit will compute a md5 |
<P>If specified in the control file, monit will compute a md5 |
714 |
checksum for a file. The checksum is used to verify that a file |
checksum for a file. The checksum is used to verify that a file |
715 |
does not change. The checksum statement may <STRONG>only</STRONG> be used in a |
does not change. The checksum statement may only be used in a |
716 |
file service entry.</P> |
file service entry.</P> |
717 |
<P>The full syntax for the checksum statement is as follows: |
<P>The full syntax for the checksum statement is as follows: |
718 |
(keywords are in capital)</P> |
(keywords are in capital)</P> |
722 |
</DL> |
</DL> |
723 |
<P><EM>expect</EM> is optional and if used specifies a md5 string monit |
<P><EM>expect</EM> is optional and if used specifies a md5 string monit |
724 |
should expect when testing a file's checksum. If <EM>expect</EM> is |
should expect when testing a file's checksum. If <EM>expect</EM> is |
725 |
used monit will not compute an initial checksum for the file, but |
used, monit will not compute an initial checksum for the file, |
726 |
instead use the string you submit. For example:</P> |
but instead use the string you submit. For example:</P> |
727 |
<PRE> |
<PRE> |
728 |
if failed checksum and |
if failed checksum and |
729 |
expect the sum 8f7f419955cefa0b33a2ba316cba3659 |
expect the sum 8f7f419955cefa0b33a2ba316cba3659 |
730 |
then alert</PRE> |
then alert</PRE> |
731 |
<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(1)</EM> to create |
732 |
checksum string for a file and then use this string in the |
a checksum string for a file and then use this string in the |
733 |
expect-statement.</P> |
expect-statement.</P> |
734 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
735 |
``UNMONITOR'':</P> |
``UNMONITOR''</P> |
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a checksum alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service <EM>and</EM> sends an alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service <EM>and</EM> sends an alert. If monit stops a |
|
|
service it will not be checked by monit anymore nor restarted |
|
|
again later. You must explicit start it again from the web |
|
|
interface or from the console, like: 'monit start myfile' or |
|
|
'monit monitor myfile' if you want the monit daemon to monitor |
|
|
the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program <EM>and</EM> send an |
|
|
alert. If you choose this action you must state the program to be |
|
|
executed. For instance; exec ``/sbin/ifconfig eth0 down''. |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
736 |
<P>The checksum statement may be used to check a file for changes |
<P>The checksum statement may be used to check a file for changes |
737 |
and if changed, do a specified action. For instance to reload a |
and if changed, do a specified action. For instance to reload a |
738 |
server if its configuration file was changed. The following |
server if its configuration file was changed. The following |
739 |
illustrate this for the apache web server:</P> |
illustrate this for the apache web server:</P> |
740 |
<PRE> |
<PRE> |
741 |
check file httpd.conf path /usr/local/apache/conf/httpd.conf |
check file httpd.conf path /usr/local/apache/conf/httpd.conf |
742 |
if failed checksum |
if failed checksum |
743 |
then exec "/usr/local/apache/bin/apachectl -k restart"</PRE> |
then exec "/usr/local/apache/bin/apachectl restart"</PRE> |
744 |
<P><STRONG>Note</STRONG>, if you plan to use the checksum statement for security |
<P>If you plan to use the checksum statement for security reasons, |
745 |
reasons, e.g. to monitor a file which should not change, then we |
(a very good idea, by the way) and to monitor a file or files |
746 |
strongly recommend that you choose the <EM>unmonitor</EM> action. The |
which should not change, then please read the DEPENDENCY TREE |
747 |
reason is that you may accidentally execute a cracked program if |
section below to see a detailed example on how to do this |
748 |
a service depends on the file-service containing the checksum |
properly.</P> |
749 |
test, as in this example:</P> |
<P> |
750 |
<PRE> |
<H2><A NAME="timestamp testing">TIMESTAMP TESTING</A></H2> |
751 |
check apache with pidfile "/usr/local/apache/logs/httpd.pid" |
<P>Monit can monitor files and directories for timestamp changes. A |
752 |
start program = "/usr/local/apache/bin/http start" |
timestamp test may only be used within a file or in a directory |
753 |
stop program = "/usr/local/apache/bin/http stop" |
entry in the monit control file.</P> |
|
alert hauk@tildeslash.com |
|
|
depends on http.bin</PRE> |
|
|
<PRE> |
|
|
check file http.bin path /usr/local/apache/bin/http |
|
|
if failed checksum then stop</PRE> |
|
|
<P>If /usr/local/apache/bin/http (in the above example) was changed |
|
|
then the stop action in the checksum statement is executed, but |
|
|
the stop action will also propagate upward in the dependency tree |
|
|
and call the stop program for services that depends on the check |
|
|
file service as well. Since we just found a checksum error in the |
|
|
http binary we should absolutely not want to execute this |
|
|
program, that is; the apache service's stop program.</P> |
|
|
<P>In this example, you should instead choose the unmonitor action. |
|
|
You will then disable monitoring of this service and all services |
|
|
which depends on it and only get an alert message saying that |
|
|
/usr/local/apache/bin/http was changed and you may then start |
|
|
your own cognitive <STRONG>OODA</STRONG> loop, that is; Observe, Orient, Decide |
|
|
and Act. In this case, where your system may be compromised, it's |
|
|
better that you do this than monit.</P> |
|
|
<P> |
|
|
<HR> |
|
|
<H1><A NAME="timestamp testing">TIMESTAMP TESTING</A></H1> |
|
|
<P>Monit can monitor file, directories and devices for timestamp |
|
|
changes. A timestamp test may only be used within a file or |
|
|
directory entry in the monit control file.</P> |
|
754 |
<P>The timestamp statement comes in two flavors. The first and basic |
<P>The timestamp statement comes in two flavors. The first and basic |
755 |
version is simply to test an existing file for timestamp changes |
version is simply to test an existing file for timestamp changes |
756 |
and if changed, execute an action. The second, and more compound, |
and if changed, execute an action. The second, and more compound, |
772 |
<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 |
773 |
possible to use ``SECONDS'', ``MINUTES'', ``HOURS'', or ``DAYS'').</P> |
possible to use ``SECONDS'', ``MINUTES'', ``HOURS'', or ``DAYS'').</P> |
774 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
775 |
``UNMONITOR'':</P> |
``UNMONITOR''.</P> |
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a timestamp alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start datafs' or 'monit monitor datafs' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/bin/rm -f /tmp/foobar'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
776 |
<P>The basic timestamp statement is useful for checking a file for |
<P>The basic timestamp statement is useful for checking a file for |
777 |
changes and then execute an action. This version was written |
changes and then execute an action. This version was written |
778 |
particularly with configuration files in mind. For instance, if |
particularly with configuration files in mind. For instance, if |
782 |
<PRE> |
<PRE> |
783 |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
784 |
if timestamp was changed |
if timestamp was changed |
785 |
then exec "/usr/local/apache/bin/apachectl graceful"</PRE> |
then exec "/usr/local/apache/bin/apachectl graceful"</PRE> |
786 |
<P>The second timestamp version is useful for monitoring systems, |
<P>The second timestamp version is useful for monitoring systems |
787 |
that are able to report its state by changing the timestamp of |
able to report its state by changing the timestamp of certain |
788 |
certain state files. For instance the <EM>iPlanet Messaging server |
state files. For instance the <EM>iPlanet Messaging server stored |
789 |
stored process</EM> system updates the timestamp of:</P> |
process</EM> system updates the timestamp of:</P> |
790 |
<PRE> |
<PRE> |
791 |
o stored.ckp |
o stored.ckp |
792 |
o stored.lcu |
o stored.lcu |
793 |
o stored.per</PRE> |
o stored.per</PRE> |
794 |
<P>whenever it runs tasks and if a task failed, the system keeps the |
<P>If a task should fail, the system keeps the timestamp. To report |
795 |
timestamp.</P> |
stored problems you can use the following statements:</P> |
|
<P>To report stored problems you can use following statements:</P> |
|
796 |
<PRE> |
<PRE> |
797 |
check file stored.ckp with path /msg-foo/config/stored.ckp |
check file stored.ckp with path /msg-foo/config/stored.ckp |
798 |
if timestamp > 1 minute then alert</PRE> |
if timestamp > 1 minute then alert</PRE> |
799 |
<PRE> |
<PRE> |
800 |
check file stored.lcu with path /msg-foo/config/stored.lcu |
check file stored.lcu with path /msg-foo/config/stored.lcu |
801 |
if timestamp 5 minutes then alert |
if timestamp 5 minutes then alert</PRE> |
|
</PRE> |
|
802 |
<PRE> |
<PRE> |
|
|
|
803 |
check file stored.per with path /msg-foo/config/stored.per |
check file stored.per with path /msg-foo/config/stored.per |
804 |
if timestamp > 1 hour then alert</PRE> |
if timestamp > 1 hour then alert</PRE> |
805 |
<P>As mentioned above, you can also use the timestamp statement for |
<P>As mentioned above, you can also use the timestamp statement for |
812 |
<PRE> |
<PRE> |
813 |
check directory myotherdir path /foo/secure/directory |
check directory myotherdir path /foo/secure/directory |
814 |
if timestamp < 1 hour then alert</PRE> |
if timestamp < 1 hour then alert</PRE> |
815 |
<P>The following example is a neat trick for restarting a process |
<P>The following example is a hack for restarting a process after a |
816 |
after a certain time. Sometimes this is a necessary workaround |
certain time. Sometimes this is a necessary workaround for some |
817 |
for some products, until the vendor fix a problem:</P> |
third-party applications, until the vendor fix a problem (we |
818 |
<PRE> |
didn't mention zeus did we?):</P> |
819 |
check file foobar.pid path /var/run/foobar.pid |
<PRE> |
820 |
if timestamp > 7 days then exec "/etc/init.d/foobar restart"</PRE> |
check file zerver.pid path /var/run/zerver.pid |
821 |
<P> |
if timestamp > 7 days |
822 |
<HR> |
then exec "/usr/local/zerver/restart-zerver"</PRE> |
823 |
<H1><A NAME="file size testing">FILE SIZE TESTING</A></H1> |
<P> |
824 |
<P>Monit can monitor files for size changes and act on such |
<H2><A NAME="file size testing">FILE SIZE TESTING</A></H2> |
825 |
changes. This test may only be used within a file service entry |
<P>Monit can monitor files for size changes and act on changes. This |
826 |
in the monit control file.</P> |
test may only be used within a file service entry in the monit |
827 |
<P>The size statement comes in two flavors. The first and basic |
control file.</P> |
828 |
|
<P>The size statement also comes in two flavors. The first and basic |
829 |
version is simply to test an existing file for size changes and |
version is simply to test an existing file for size changes and |
830 |
if changed, execute an action. The second, and more compound, |
if changed, execute an action. The second, and more compound, |
831 |
version is used to test a file for various size changes.</P> |
version is used to test a file for various size changes.</P> |
846 |
``byte'', ``kilobyte'', ``megabyte'', ``gigabyte''. If it is not specified, |
``byte'', ``kilobyte'', ``megabyte'', ``gigabyte''. If it is not specified, |
847 |
``byte'' unit is assumed by default.</P> |
``byte'' unit is assumed by default.</P> |
848 |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
849 |
``UNMONITOR'':</P> |
``UNMONITOR''.</P> |
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a size alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start myfile' or 'monit monitor myfile' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/bin/rm -f /tmp/foobar'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
850 |
<P>The basic size statement is useful for checking a file for |
<P>The basic size statement is useful for checking a file for |
851 |
changes and send alert or execute an action. Monit will register |
changes and send an alert or execute an action. Monit will |
852 |
the size of the file at startup and monitor the file for |
register the size of the file at startup and monitor the file for |
853 |
changes. One usage of this statement is to conduct security |
changes. One example of use for this statement is to conduct |
854 |
checks, for instance:</P> |
security checks, for instance:</P> |
855 |
<PRE> |
<PRE> |
856 |
check file su with path /bin/su |
check file su with path /bin/su |
857 |
if size was changed then exec "/sbin/ifconfig eth0 down"</PRE> |
if size was changed then exec "/sbin/ifconfig eth0 down"</PRE> |
858 |
<P>which will ``cut the cable'' and stop a possible intruder from |
<P>which will ``cut the cable'' and stop a possible intruder from |
859 |
further system compromitation.</P> |
compromising the system further. This test is just one of many |
860 |
<P>This test is just one of many you may use to increase the systems |
you may use to increase the security awareness on a system. If |
861 |
security awareness. If you plan to use monit to raise the |
you plan to use monit for security reasons we recommend that you |
862 |
security level for your system we recommend that you use this |
use this test in combination with other supported tests like |
863 |
test in combination with other supported tests like checksum, |
checksum, timestamp, and so on.</P> |
|
timestamp, and so on.</P> |
|
864 |
<P>The second size version may be useful in different contexts. It |
<P>The second size version may be useful in different contexts. It |
865 |
can, for instance, be used to test if a certain file size was |
can, for instance, be used to test if a certain file size was |
866 |
exceeded and then alert you or monit may execute a certain action |
exceeded and then alert you or monit may execute a certain action |
867 |
specified by you. An example is to use this statement to rotate |
specified by you. An example is to use this statement to rotate |
868 |
log files after they have reached a certain size or to check that |
log files after they have reached a certain size or to check that |
869 |
database files does not grow above a specified threshold.</P> |
a database file does not grow beyond a specified threshold.</P> |
870 |
<P>To rotate a log file:</P> |
<P>To rotate a log file:</P> |
871 |
<PRE> |
<PRE> |
872 |
check file myapp.log with path /var/log/myapp.log |
check file myapp.log with path /var/log/myapp.log |
873 |
if size > 50 MB then |
if size > 50 MB then |
874 |
exec "/usr/local/bin/rotate /var/log/myapp.log myapp"</PRE> |
exec "/usr/local/bin/rotate /var/log/myapp.log myapp"</PRE> |
875 |
<P>where /usr/local/bin/rotate may be a simple script, such as:</P> |
<P>where /usr/local/bin/rotate may be a simple script, such as:</P> |
876 |
<PRE> |
<PRE> |
877 |
#/bin/bash |
#/bin/bash |
878 |
/bin/mv $1 $1.`date +%y-%m-%d` |
/bin/mv $1 $1.`date +%y-%m-%d` |
879 |
/usr/bin/pkill -HUP $2</PRE> |
/usr/bin/pkill -HUP $2</PRE> |
880 |
<P>Or you may use this statement to trigger the <CODE>logrotate(8)</CODE> |
<P>Or you may use this statement to trigger the <CODE>logrotate(8)</CODE> |
881 |
program, to do an ``emergency'' rotate.</P> |
program, to do an ``emergency'' rotate. Or to send an alert if a |
882 |
<P>Or to send alerts if a file becomes a bottleneck if it grows |
file becomes a known bottleneck if it grows behind a certain size |
883 |
behind a fixed size because of limits in a database engine:</P> |
because of limits in a database engine:</P> |
884 |
<PRE> |
<PRE> |
885 |
check file mydb with path /data/mydatabase.db |
check file mydb with path /data/mydatabase.db |
886 |
if size > 1 GB then alert</PRE> |
if size > 1 GB then alert</PRE> |
887 |
<P>This is a more restrictive form of the first example where the |
<P>This is a more restrictive form of the first example where the |
888 |
size is explicitly defined (Note that this is system dependent):</P> |
size is explicitly defined (Note that this is system dependent):</P> |
889 |
<PRE> |
<PRE> |
890 |
check file su with path /bin/su |
check file su with path /bin/su |
891 |
if size != 95564 then exec "/sbin/ifconfig eth0 down"</PRE> |
if size != 95564 then exec "/sbin/ifconfig eth0 down"</PRE> |
892 |
<P> |
<P> |
893 |
<HR> |
<H2><A NAME="space testing">SPACE TESTING</A></H2> |
894 |
<H1><A NAME="connection testing">CONNECTION TESTING</A></H1> |
<P>Monit can test devices/filesystems and check for space |
895 |
<P>Monit is able to perfom connection testing via networked ports or |
usage. This test may only be used within a device service entry |
896 |
via unix sockets.</P> |
in the monit control file.</P> |
897 |
|
<P>Monit will check a device's total space usage. If you only want |
898 |
|
to check available space for non-superuser, you must set the |
899 |
|
watermark appropriately (i.e. total space minus reserved blocks |
900 |
|
for the superuser).</P> |
901 |
|
<P>You can obtain (and set) the superuser's reserved blocks size, |
902 |
|
for example by using the tune2fs utility on Linux. On Linux 5% of |
903 |
|
available blocks are reserved for the superuser by default. To |
904 |
|
list the reserved blocks for the superuser:</P> |
905 |
|
<PRE> |
906 |
|
[root@berry monit]# tune2fs -l /dev/hda1| grep "Reserved block" |
907 |
|
Reserved block count: 319994 |
908 |
|
Reserved blocks uid: 0 (user root) |
909 |
|
Reserved blocks gid: 0 (group root)</PRE> |
910 |
|
<P>On solaris 10% of the blocks are reserved. You can also use |
911 |
|
tunefs on solaris to change values on a live filesystem.</P> |
912 |
|
<P>The full syntax for the space statement is:</P> |
913 |
|
<DL> |
914 |
|
<DT><STRONG><A NAME="item_IF_SPACE_operator_value_unit_THEN_action">IF SPACE operator value unit THEN action</A></STRONG><BR> |
915 |
|
<DD> |
916 |
|
</DL> |
917 |
|
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
918 |
|
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
919 |
|
``equal'', ``notequal'' in human readable form (if not specified, |
920 |
|
default is EQUAL).</P> |
921 |
|
<P><EM>unit</EM> is a choice of ``B'',``KB'',``MB'',``GB'', ``%'' or long |
922 |
|
alternatives ``byte'', ``kilobyte'', ``megabyte'', ``gigabyte'', |
923 |
|
``percent''.</P> |
924 |
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
925 |
|
``UNMONITOR''.</P> |
926 |
|
<P> |
927 |
|
<H2><A NAME="inode testing">INODE TESTING</A></H2> |
928 |
|
<P>If supported by the file-system, you can use monit to test for |
929 |
|
inodes usage. This test may only be used within a device service |
930 |
|
entry in the monit control file.</P> |
931 |
|
<P>If the device becomes unavailable, monit will call the entry's |
932 |
|
registered start method, if it is defined and if monit is running |
933 |
|
in active mode. If monit runs in passive mode or the start |
934 |
|
methods is not defined, monit will just send an error alert.</P> |
935 |
|
<P>The syntax for the inode statement is:</P> |
936 |
|
<DL> |
937 |
|
<DT><STRONG><A NAME="item_INODE">IF <CODE>INODE(S)</CODE> operator value [unit] THEN action</A></STRONG><BR> |
938 |
|
<DD> |
939 |
|
</DL> |
940 |
|
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
941 |
|
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
942 |
|
``equal'', ``notequal'' in human readable form (if not specified, |
943 |
|
default is EQUAL).</P> |
944 |
|
<P><EM>unit</EM> is optional. If not specified, the value is an absolute |
945 |
|
count of inodes. You can use the ``%'' character or the longer |
946 |
|
alternative ``percent'' as a unit.</P> |
947 |
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
948 |
|
``UNMONITOR''.</P> |
949 |
|
<P> |
950 |
|
<H2><A NAME="permission testing">PERMISSION TESTING</A></H2> |
951 |
|
<P>Monit can monitor the permissions for files, directories and |
952 |
|
devices. This test may only be used within a file, directory or |
953 |
|
device service entry in the monit control file.</P> |
954 |
|
<P>The syntax for the permission statement is:</P> |
955 |
|
<DL> |
956 |
|
<DT><STRONG><A NAME="item_PERM">IF FAILED <CODE>PERM(ISSION)</CODE> octalnumber THEN action</A></STRONG><BR> |
957 |
|
<DD> |
958 |
|
</DL> |
959 |
|
<P><EM>octalnumber</EM> defines permissions for a file, a directory or a |
960 |
|
device.</P> |
961 |
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
962 |
|
``UNMONITOR''.</P> |
963 |
|
<P>The web interface will show a permission warning if the test |
964 |
|
failed.</P> |
965 |
|
<P>We recommend that you use the UNMONITOR action in a permission |
966 |
|
statement. The rationale for this feature is security and that |
967 |
|
monit does not start a possible cracked program or |
968 |
|
script. Example:</P> |
969 |
|
<PRE> |
970 |
|
check file monit.bin with path "/usr/local/bin/monit" |
971 |
|
if failed permission 0555 then unmonitor |
972 |
|
alert foo@bar</PRE> |
973 |
|
<P>If the test fails, monit will simply send an alert and stop |
974 |
|
monitoring the file and propagate an unmonitor action upward in |
975 |
|
a depend tree.</P> |
976 |
|
<P> |
977 |
|
<H2><A NAME="uid testing">UID TESTING</A></H2> |
978 |
|
<P>monit can monitor the owner user id (uid) for files, directories |
979 |
|
and devices. This test may only be used within a file, directory |
980 |
|
or device service entry in the monit control file.</P> |
981 |
|
<P>The syntax for the uid statement is:</P> |
982 |
|
<DL> |
983 |
|
<DT><STRONG><A NAME="item_IF_FAILED_UID_user_THEN_action">IF FAILED UID user THEN action</A></STRONG><BR> |
984 |
|
<DD> |
985 |
|
</DL> |
986 |
|
<P><EM>user</EM> defines a user id either in numeric or in string form.</P> |
987 |
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
988 |
|
``UNMONITOR''.</P> |
989 |
|
<P>The web interface will show a uid warning if the test should |
990 |
|
fail.</P> |
991 |
|
<P>We recommend that you use the UNMONITOR action in a uid |
992 |
|
statement. The rationale for this feature is security and that |
993 |
|
monit does not start a possible cracked program or |
994 |
|
script. Example:</P> |
995 |
|
<PRE> |
996 |
|
check file passwd with path /etc/passwd |
997 |
|
if failed uid root then unmonitor |
998 |
|
alert root@localhost</PRE> |
999 |
|
<P>If the test fails, monit will simply send an alert and stop |
1000 |
|
monitoring the file and propagate an unmonitor action upward in |
1001 |
|
a depend tree.</P> |
1002 |
|
<P> |
1003 |
|
<H2><A NAME="gid testing">GID TESTING</A></H2> |
1004 |
|
<P>monit can monitor the owner group id (gid) for files, directories |
1005 |
|
and devices. This test may only be used within a file, directory |
1006 |
|
or device service entry in the monit control file.</P> |
1007 |
|
<P>The syntax for the gid statement is:</P> |
1008 |
|
<DL> |
1009 |
|
<DT><STRONG><A NAME="item_IF_FAILED_GID_user_THEN_action">IF FAILED GID user THEN action</A></STRONG><BR> |
1010 |
|
<DD> |
1011 |
|
</DL> |
1012 |
|
<P><EM>user</EM> defines a group id either in numeric or in string form.</P> |
1013 |
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
1014 |
|
``UNMONITOR''.</P> |
1015 |
|
<P>The web interface will show a gid warning if the test should |
1016 |
|
fail.</P> |
1017 |
|
<P>We recommend that you use the UNMONITOR action in a gid |
1018 |
|
statement. The rationale for this feature is security and that |
1019 |
|
monit does not start a possible cracked program or |
1020 |
|
script. Example:</P> |
1021 |
|
<PRE> |
1022 |
|
check file shadow with path /etc/shadow |
1023 |
|
if failed gid root then unmonitor |
1024 |
|
alert root@localhost</PRE> |
1025 |
|
<P>If the test fails, monit will simply send an alert and stop |
1026 |
|
monitoring the file and propagate an unmonitor action upward in |
1027 |
|
a depend tree.</P> |
1028 |
|
<P> |
1029 |
|
<H2><A NAME="connection testing">CONNECTION TESTING</A></H2> |
1030 |
|
<P>Monit is able to perform connection testing via networked ports |
1031 |
|
or via Unix sockets. A connection test may only be used within a |
1032 |
|
process or within a host service entry in the monit control file.</P> |
1033 |
<P>If a service listens on one or more sockets, monit can connect to |
<P>If a service listens on one or more sockets, monit can connect to |
1034 |
the port (using either tcp or udp) and verify that the service |
the port (using either tcp or udp) and verify that the service |
1035 |
will accept a connection and that it is possible to write and |
will accept a connection and that it is possible to write and |
1036 |
read from the socket. If a connection is not accepted or if there |
read from the socket. If a connection is not accepted or if there |
1037 |
is a problem with socket read/write, monit will assume that |
is a problem with socket read/write, monit will assume that |
1038 |
something is wrong and execute a specified action. If monit is |
something is wrong and execute a specified action. If monit is |
1039 |
compiled with openssl, ssl based network services can also be |
compiled with openssl, then ssl based network services can also |
1040 |
tested.</P> |
be tested.</P> |
1041 |
<P>The full syntax for the statement used for connection testing is |
<P>The full syntax for the statement used for connection testing is |
1042 |
as follows (keywords are in capital and optional statements in |
as follows (keywords are in capital and optional statements in |
1043 |
[brackets]),</P> |
[brackets]),</P> |
1046 |
THEN action</A></STRONG><BR> |
THEN action</A></STRONG><BR> |
1047 |
<DD> |
<DD> |
1048 |
</DL> |
</DL> |
1049 |
<P>or for unix sockets,</P> |
<P>or for Unix sockets,</P> |
1050 |
<DL> |
<DL> |
1051 |
<DT><STRONG><A NAME="item_IF_FAILED_%5Bunixsocket%5D_%5Btype%5D_%5Bprotocol%">IF FAILED [unixsocket] [type] [protocol] [timeout] |
<DT><STRONG><A NAME="item_IF_FAILED_%5Bunixsocket%5D_%5Btype%5D_%5Bprotocol%">IF FAILED [unixsocket] [type] [protocol] [timeout] |
1052 |
THEN action</A></STRONG><BR> |
THEN action</A></STRONG><BR> |
1053 |
<DD> |
<DD> |
1054 |
</DL> |
</DL> |
1055 |
<P><STRONG>host</STRONG> optionally specify the host to connect to. If the host is |
<P><STRONG>host:HOST hostname</STRONG>. Optionally specify the host to connect |
1056 |
not given, localhost is assumed. Although <EM>host</EM> is intended for |
to. If the host is not given, localhost is assumed. Although |
1057 |
testing name based virtual host in a HTTP server running on |
<EM>host</EM> is intended for testing name based virtual host in a HTTP |
1058 |
localhost, it does allow the connection statement to be used to |
server running on localhost, it does allow the connection |
1059 |
test a server running on another machine. This may be very |
statement to be used to test a server running on another |
1060 |
useful; For instance if you use Apache httpd as a front-end and |
machine. This may be useful; For instance if you use Apache httpd |
1061 |
an application-server as the back-end running on another machine, |
as a front-end and an application-server as the back-end running |
1062 |
this statement may be used to test that the back-end server is |
on another machine, this statement may be used to test that the |
1063 |
running and if not raise an alert.</P> |
back-end server is running and if not raise an alert.</P> |
1064 |
<P><STRONG>port</STRONG> is the port number to connect to</P> |
<P><STRONG>port:PORT number</STRONG>. The port number to connect to</P> |
1065 |
<P><STRONG>unixsocket</STRONG> specifies the path to a unix socket. Servers based |
<P><STRONG>unixsocket:UNIXSOCKET PATH</STRONG>. Specifies the path to a Unix |
1066 |
on unix sockets, always runs on the local machine and does not |
socket. Servers based on Unix sockets, always runs on the local |
1067 |
use a port.</P> |
machine and does not use a port.</P> |
1068 |
<P><STRONG>type</STRONG> optionally specify the socket type monit should use when |
<P><STRONG>type:TYPE {TCP|UDP|TCPSSL}</STRONG>. Optionally specify the socket type |
1069 |
trying to connect to the port. The different socket types are; |
monit should use when trying to connect to the port. The |
1070 |
TCP, UDP or TCPSSL, where TCP is a regular stream based socket, |
different socket types are; TCP, UDP or TCPSSL, where TCP is a |
1071 |
UDP a datagram socket and TCPSSL specify that monit should use a |
regular stream based socket, UDP is a datagram socket and TCPSSL |
1072 |
TCP socket with SSL when connecting to the server. The default |
specify that monit should use a TCP socket with SSL when |
1073 |
socket type is TCP. If TCPSSL is used you may optionally specify |
connecting to a port. The default socket type is TCP. If TCPSSL |
1074 |
the SSL/TLS protocol to be used and the md5 sum of the server's |
is used you may optionally specify the SSL/TLS protocol to be |
1075 |
certificate. The TCPSSL options are:</P> |
used and the md5 sum of the server's certificate. The TCPSSL |
1076 |
|
options are:</P> |
1077 |
<PRE> |
<PRE> |
1078 |
TCPSSL [SSLAUTO|SSLV2|SSLV3|TLSV1] [CERTMD5 md5sum]</PRE> |
TCPSSL [SSLAUTO|SSLV2|SSLV3|TLSV1] [CERTMD5 md5sum]</PRE> |
1079 |
<P><STRONG>proto(col)</STRONG> optionally specify the protocol monit should speak |
<P><STRONG>proto(col):PROTO {protcols}</STRONG>. Optionally specify the protocol |
1080 |
when a connection is established. At the moment monit knows how |
monit should speak when a connection is established. At the |
1081 |
to speak <EM>HTTP</EM>, <EM>SMTP</EM>, <EM>FTP</EM>, <EM>POP</EM>, <EM>IMAP</EM>, <EM>NNTP</EM>, |
moment monit knows how to speak <EM>HTTP</EM>, <EM>SMTP</EM>, <EM>FTP</EM>, <EM>POP</EM>, |
1082 |
<EM>SSH</EM>, <EM>DWP</EM>, <EM>LDAP2</EM>, <EM>LDAP3</EM>, <EM>RDATE</EM> and <EM>RSYNC</EM> and if |
<EM>IMAP</EM>, <EM>NNTP</EM>, <EM>SSH</EM>, <EM>DWP</EM>, <EM>LDAP2</EM>, <EM>LDAP3</EM>, <EM>RDATE</EM> |
1083 |
you have compiled monit with ssl support, monit can also speak |
and <EM>RSYNC</EM> and if you have compiled monit with ssl support, |
1084 |
<EM>HTTPS</EM>, <EM>FTPS</EM>, <EM>POPS</EM> and <EM>IMAPS</EM>. If the server's protocol |
monit can also speak <EM>HTTPS</EM>, <EM>FTPS</EM>, <EM>POPS</EM> and <EM>IMAPS</EM>. If |
1085 |
is not found in this list, simply do not specify the protocol and |
the server's protocol is not found in this list, simply do not |
1086 |
monit will utilize a default test, including testing if it is |
specify the protocol and monit will utilize a default test, |
1087 |
possible to read and write to the port. This default test is in |
including testing if it is possible to read and write to the |
1088 |
many cases more than good enough to deduce if the server behind |
port. This default test is in most cases more than good enough to |
1089 |
the port is up or not. The protocol statement is:</P> |
deduce if the server behind the port is up or not. The protocol |
1090 |
|
statement is:</P> |
1091 |
<PRE> |
<PRE> |
1092 |
[PROTO(COL) {name} [REQUEST {"/path"}]]</PRE> |
[PROTO(COL) {name} [REQUEST {"/path"}]]</PRE> |
1093 |
<P>As you can see, you may specify a request after the protocol, at |
<P>As you can see, you may specify a request after the protocol, at |
1094 |
the moment only the HTTP protocol supports the request option. |
the moment only the HTTP protocol supports the request option. |
1095 |
See also below.</P> |
See also below for an example.</P> |
1096 |
<P><STRONG>timeout</STRONG> optionally specifies the connect and read timeout for |
<P><STRONG>timeout:with TIMEOUT x SECONDS</STRONG>. Optionally specifies the |
1097 |
the connection. If monit cannot connect to the server within this |
connect and read timeout for the connection. If monit cannot |
1098 |
time it will assume that the connection failed and execute the |
connect to the server within this time it will assume that the |
1099 |
specified action. The default timeout is 5 seconds. The timeout |
connection failed and execute the specified action. The default |
1100 |
statement is:</P> |
connect timeout is 5 seconds.</P> |
|
<PRE> |
|
|
[with TIMEOUT x SECONDS]</PRE> |
|
1101 |
<P><STRONG>action</STRONG> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
<P><STRONG>action</STRONG> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
1102 |
``UNMONITOR'':</P> |
``UNMONITOR''.</P> |
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a connection alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start myfile' or 'monit monitor myfile' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/etc/init.d/network restart'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
1103 |
<P> |
<P> |
1104 |
<H4><A NAME="examples">Examples</A></H4> |
<H4><A NAME="examples">Examples</A></H4> |
1105 |
<P>To check a port connection and receive an alert if monit cannot |
<P>To check a port connection and receive an alert if monit cannot |
1120 |
seconds the test will fail and an alert message is sent.</P> |
seconds the test will fail and an alert message is sent.</P> |
1121 |
<PRE> |
<PRE> |
1122 |
if failed port 80 with timeout 15 seconds then alert</PRE> |
if failed port 80 with timeout 15 seconds then alert</PRE> |
1123 |
<P>In case a server is listening to a unix socket the following |
<P>If a server is listening to a Unix socket the following statement |
1124 |
statement can be used:</P> |
can be used:</P> |
1125 |
<PRE> |
<PRE> |
1126 |
if failed unixsocket /var/run/mysocket then alert</PRE> |
if failed unixsocket /tmp/ssh-XXuIV3rG/agent.1486 then alert</PRE> |
1127 |
<P>A unix socket is used by some servers to conduct communication on |
<P>A Unix socket is used by some servers for (interprocess) |
1128 |
localhost only. An open unix socket is specified by a path and in |
communication on localhost only. A Unix socket is specified by a |
1129 |
the example above the path, /var/run/mysocket, specifies a unix |
path and in the example above the path, |
1130 |
socket.</P> |
/tmp/ssh-XXuIV3rG/agent.1486, specifies a Unix socket.</P> |
1131 |
<P>If your machine answers for several virtual hosts you can prefix |
<P>If your machine answers for several virtual hosts you can prefix |
1132 |
the port statement with a host-statement like so:</P> |
the port statement with a host-statement like so:</P> |
1133 |
<PRE> |
<PRE> |
1141 |
speak with the server in question to verify that the server |
speak with the server in question to verify that the server |
1142 |
works. For example, the following is used to test a http server:</P> |
works. For example, the following is used to test a http server:</P> |
1143 |
<PRE> |
<PRE> |
1144 |
if failed host www.tildeslash.com port 80 protocol http |
if failed host www.tildeslash.com port 80 proto http |
1145 |
then restart</PRE> |
then restart</PRE> |
1146 |
<P>Some protocols also support a request statement. This statement |
<P>Some protocols also support a request statement. This statement |
1147 |
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> |
1148 |
<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 |
1149 |
request statement, such as:</P> |
request statement, such as:</P> |
1150 |
<PRE> |
<PRE> |
1151 |
if failed host www.myhost.com port 80 protocol http |
if failed host www.myhost.com port 80 protocol http |
1152 |
request "/data/show.php?a=b&c=d" |
and request "/data/show.php?a=b&c=d" |
1153 |
then restart</PRE> |
then restart</PRE> |
1154 |
<P>The request must contain an URI string specifying a document from |
<P>The request must contain an URI string specifying a document from |
1155 |
the http server. The string will be url encoded by monit before |
the http server. The string will be url encoded by monit before |
1156 |
it sends the request to the http server, so it's okay to use url |
it sends the request to the http server, so it's okay to use url |
1157 |
unsafe characters in the request.</P> |
unsafe characters in the request. If the request statement isn't |
1158 |
<P>If the request statement isn't specified, the default web server |
specified, the default web server page will be requested.</P> |
1159 |
page will be requested.</P> |
<P>The <EM>TCPSSL</EM> statement can optionally test the md5 sum of the |
1160 |
<P>The <EM>TCPSSL</EM> statement accepts optionally the md5 sum of the |
server's certificate. You must state the md5 certificate string |
1161 |
server's certificate. The md5 sum is matched against the one |
you expect the server to deliver and upon a connect to the |
1162 |
delivered by the server. In case they do not match the connection |
server, the server's actual md5 sum certificate string is |
1163 |
test fails. In case the ssl version independant handshake is not |
tested. If they do not match, the connection test fails. If the |
1164 |
working properly you can force a specific ssl version, as we |
ssl version handshake does not work properly you can also force a |
1165 |
demonstrate in this example:</P> |
specific ssl version, as we demonstrate in this example:</P> |
1166 |
<PRE> |
<PRE> |
1167 |
if failed host shop.sol.no port 443 |
if failed host shop.sol.no port 443 |
1168 |
type TCPSSL SSLV3 |
type TCPSSL SSLV3 # Force monit to use ssl version 3 |
1169 |
CERTMD5 94A07F97ADFEDEDD16F053EEE6351AB1 |
# We expect the server to return this md5 certificate sum |
1170 |
protocol http |
CERTMD5 94A07F97ADFEDEDD16F053EEE6351AB1 |
1171 |
|
protocol http |
1172 |
then restart</PRE> |
then restart</PRE> |
1173 |
<P>Finally, it is of course possible to mix networked ports and unix |
<P>When a connection test is used in a check host entry, the host |
1174 |
sockets checks for a service.</P> |
name can <STRONG>not</STRONG> be used in the if-test since the host name is |
1175 |
<P>See also the example section below.</P> |
bound to the entry itself.</P> |
1176 |
<P> |
<P>E.g. this is legal:</P> |
1177 |
<HR> |
<PRE> |
1178 |
<H1><A NAME="space testing">SPACE TESTING</A></H1> |
check HOST ftp.redhat.com |
1179 |
<P>Monit supports test of devices/filesystems. You can check for |
if failed port 21 then exec |
1180 |
space usage.</P> |
"/usr/X11R6/bin/xmessage -display :0 RedHat is down as usual!"</PRE> |
1181 |
<P>Monit will check total usage => if you need to check the usage |
<P>this is not, and will lead to a parse error:</P> |
1182 |
for non-superuser available space, you must set the watermark |
<PRE> |
1183 |
appropriately (total space minus superuser reserved blocks).</P> |
check host ftp.redhat.com |
1184 |
<P>You can obtain (and set) live filesystem actual superuser reserved |
if failed HOST ftp.suse.com port 21 then ...</PRE> |
1185 |
blocks limit, uid and group for example by tune2fs utility on |
<P>For more examples, see the example section below.</P> |
|
linux. Linux has 5% blocks reserved by default. To list |
|
|
informations:</P> |
|
|
<PRE> |
|
|
[root@berry monit]# tune2fs -l /dev/hda1| grep "Reserved block" |
|
|
Reserved block count: 5219 |
|
|
Reserved blocks uid: 0 (user root) |
|
|
Reserved blocks gid: 0 (group root)</PRE> |
|
|
<P>Solaris has by default 10% blocks reserved. You can use tunefs |
|
|
on solaris to change it on live filesystem.</P> |
|
|
<P>The full syntax for the space testing statement is:</P> |
|
|
<DL> |
|
|
<DT><STRONG><A NAME="item_IF_SPACE_operator_value_unit_THEN_action">IF SPACE operator value unit THEN action</A></STRONG><BR> |
|
|
<DD> |
|
|
</DL> |
|
|
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
|
|
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
|
|
``equal'', ``notequal'' in human readable form (if not specified, |
|
|
default is EQUAL).</P> |
|
|
<P><EM>unit</EM> is a choice of ``B'',``KB'',``MB'',``GB'', ``%'' or long |
|
|
alternatives ``byte'', ``kilobyte'', ``megabyte'', ``gigabyte'', |
|
|
``percent''.</P> |
|
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
|
|
``UNMONITOR'':</P> |
|
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a resource alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start datafs' or 'monit monitor datafs' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
|
<P> |
|
|
<HR> |
|
|
<H1><A NAME="inode testing">INODE TESTING</A></H1> |
|
|
<P>Monit supports test of devices and filesystems. You can check for |
|
|
inodes usage if supported by the filesystem.</P> |
|
|
<P>In the case that the device becomes unavailable, monit will |
|
|
call start/stop methods whenever defined if it is running in |
|
|
active mode. In the case that it is running in passive mode or |
|
|
start/stop methods were not defined, it will just send failure |
|
|
alert.</P> |
|
|
<P>Full syntax of inode testing statement:</P> |
|
|
<DL> |
|
|
<DT><STRONG><A NAME="item_INODE">IF <CODE>INODE(S)</CODE> operator value [unit] THEN action</A></STRONG><BR> |
|
|
<DD> |
|
|
</DL> |
|
|
<P><EM>operator</EM> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
|
|
``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'', |
|
|
``equal'', ``notequal'' in human readable form (if not specified, |
|
|
default is EQUAL).</P> |
|
|
<P><EM>unit</EM> is optional. If not specified, the value is an absolute |
|
|
count of inodes. You can use the ``%'' character or the longer |
|
|
alternative ``percent'' as a unit.</P> |
|
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
|
|
``UNMONITOR'':</P> |
|
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a resource alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start datafs' or 'monit monitor datafs' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
|
<P> |
|
|
<HR> |
|
|
<H1><A NAME="permission testing">PERMISSION TESTING</A></H1> |
|
|
<P>Monit can watch file, directory or device permission.</P> |
|
|
<P>Full syntax is:</P> |
|
|
<DL> |
|
|
<DT><STRONG><A NAME="item_PERM">IF FAILED <CODE>PERM(ISSION)</CODE> octalnumber THEN action</A></STRONG><BR> |
|
|
<DD> |
|
|
</DL> |
|
|
<P><EM>octalnumber</EM> defines appropriate file, directory or device |
|
|
permissions.</P> |
|
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
|
|
``UNMONITOR'':</P> |
|
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a permission alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start myfile' or 'monit monitor myfile' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/sbin/ifconfig eth0 down'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
|
<P>The web interface will show a permission warning in the case that |
|
|
it failed.</P> |
|
|
<P>We recommend to use UNMONITOR action in the permission statement. The |
|
|
rationale for this feature is security and that monit does not |
|
|
start a possible cracked program or script. Example:</P> |
|
|
<PRE> |
|
|
check file myfile with path "/path/to/myfile" |
|
|
if failed permission 700 then unmonitor</PRE> |
|
|
<P>It will just stop service monitoring. In the case that some other |
|
|
service depends on myfile service, unmonitor event will be send |
|
|
to it and all its dependants as well.</P> |
|
|
<P> |
|
|
<HR> |
|
|
<H1><A NAME="uid testing">UID TESTING</A></H1> |
|
|
<P>Monit can watch file, directory or device owner user id.</P> |
|
|
<P>Full syntax is:</P> |
|
|
<DL> |
|
|
<DT><STRONG><A NAME="item_IF_FAILED_UID_user_THEN_action">IF FAILED UID user THEN action</A></STRONG><BR> |
|
|
<DD> |
|
|
</DL> |
|
|
<P><EM>user</EM> defines appropriate file, directory or device |
|
|
owner user id either in numeric or string form.</P> |
|
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
|
|
``UNMONITOR'':</P> |
|
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a uid alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start myfile' or 'monit monitor myfile' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/sbin/ifconfig eth0 down'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
|
<P>The web interface will show a uid warning in the case that it |
|
|
failed.</P> |
|
|
<P>We recommend to use UNMONITOR action in the uid statement. The |
|
|
rationale for this feature is security and that monit does not |
|
|
start a possible cracked program or script. Example:</P> |
|
|
<PRE> |
|
|
check file myfile with path "/path/to/myfile" |
|
|
if failed uid root then unmonitor</PRE> |
|
|
<P>It will just stop service monitoring. In the case that some other |
|
|
service depends on myfile service, unmonitor event will be send |
|
|
to it and all its dependants as well.</P> |
|
|
<P> |
|
|
<HR> |
|
|
<H1><A NAME="gid testing">GID TESTING</A></H1> |
|
|
<P>Monit can watch file, directory or device owner group id.</P> |
|
|
<P>Full syntax is:</P> |
|
|
<DL> |
|
|
<DT><STRONG><A NAME="item_IF_FAILED_GID_user_THEN_action">IF FAILED GID user THEN action</A></STRONG><BR> |
|
|
<DD> |
|
|
</DL> |
|
|
<P><EM>user</EM> defines appropriate file, directory or device |
|
|
owner group id either in numeric or string form.</P> |
|
|
<P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP'', ``EXEC'' or |
|
|
``UNMONITOR'':</P> |
|
|
<UL> |
|
|
<LI> |
|
|
ALERT sends the user a gid alert. |
|
|
<P></P> |
|
|
<LI> |
|
|
RESTART restarts the service. |
|
|
<P></P> |
|
|
<LI> |
|
|
STOP stops the service. If monit stops a service it will |
|
|
not be checked by monit anymore nor restarted again later. You |
|
|
must explicit start it again from the web interface or from the |
|
|
console, like: 'monit start myfile' or 'monit monitor myfile' |
|
|
if you want the monit daemon to monitor the service again. |
|
|
<P></P> |
|
|
<LI> |
|
|
EXEC may be used to execute an arbitrary program. If you choose |
|
|
this action you must state the program to be executed. For |
|
|
instance; exec ``/sbin/ifconfig eth0 down'' |
|
|
<P></P> |
|
|
<LI> |
|
|
UNMONITOR will disable monitoring of the service - it will not be |
|
|
checked by monit anymore nor restarted again later. The chain of |
|
|
all services which depends on this service will be unmonitored |
|
|
before this service monitoring will be stopped. You can enable |
|
|
monitoring again either via console 'monitor' command, via web |
|
|
interface or use 'start' command, which will enable the |
|
|
monitoring too. |
|
|
<P></P></UL> |
|
|
<P>The web interface will show a gid warning in the case that it |
|
|
failed.</P> |
|
|
<P>We recommend to use UNMONITOR action in the uid statement. The |
|
|
rationale for this feature is security and that monit does not |
|
|
start a possible cracked program or script. Example:</P> |
|
|
<PRE> |
|
|
check file myfile with path "/path/to/myfile" |
|
|
if failed gid root then unmonitor</PRE> |
|
|
<P>It will just stop service monitoring. In the case that some other |
|
|
service depends on myfile service, unmonitor event will be send |
|
|
to it and all its dependants as well.</P> |
|
1186 |
<P> |
<P> |
1187 |
<HR> |
<HR> |
1188 |
<H1><A NAME="monit httpd">MONIT HTTPD</A></H1> |
<H1><A NAME="monit httpd">MONIT HTTPD</A></H1> |
1189 |
<P>If specified in the control file, monit will start a monit daemon |
<P>If specified in the control file, monit will start a monit daemon |
1190 |
with http support. From a Browser you can then start and stop |
with http support. From a Browser you can then start and stop |
1191 |
services as well as view the status of each service. Also, if |
services, disable or enable service monitoring as well as view |
1192 |
monit logs to its own file, you can view the content of this |
the status of each service. Also, if monit logs to its own file, |
1193 |
logfile in a Browser.</P> |
you can view the content of this logfile in a Browser.</P> |
1194 |
<P>The control file statement for starting a monit daemon with http |
<P>The control file statement for starting a monit daemon with http |
1195 |
support is a global set-statement:</P> |
support is a global set-statement:</P> |
1196 |
<DL> |
<DL> |
1198 |
<DD> |
<DD> |
1199 |
</DL> |
</DL> |
1200 |
<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 |
1201 |
the daemon from a browser.</P> |
the daemon from a browser. The port number, in this case 2812, |
1202 |
<P>The port number, in this case 2812, can be any number that you |
can be any number that you are allowed to bind to.</P> |
1203 |
are allowed to bind to.</P> |
<P>If you have compiled monit with openssl, you can also start the |
1204 |
<P>If you have compiled monit with openssl support, you can also |
httpd server with ssl support, using the following expression:</P> |
|
start the httpd server with ssl support, using the following |
|
|
expression:</P> |
|
1205 |
<PRE> |
<PRE> |
1206 |
set httpd port 2812 |
set httpd port 2812 |
1207 |
ssl enable |
ssl enable |
1208 |
pemfile /etc/certs/monit.pem</PRE> |
pemfile /etc/certs/monit.pem</PRE> |
1209 |
<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 |
1210 |
the monit web server over an ssl encrypted connection.</P> |
the monit web server over an ssl encrypted connection.</P> |
1211 |
<P>The pemfile, in the example above, holds the private key and the |
<P>The pemfile, in the example above, holds both the server's |
1212 |
certificate. This file should be stored on a safe place on the |
private key and certificate. This file should be stored in a safe |
1213 |
filesystem and should have strict permissions, that is, no more |
place on the filesystem and should have strict permissions, that |
1214 |
than 0700. For more information on how to generate this file, |
is, no more than 0700.</P> |
|
please consult README.ssl</P> |
|
1215 |
<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 |
1216 |
use the CLIENTPEMFILE statement. In that case a connecting |
use the CLIENTPEMFILE statement. In this case, a connecting |
1217 |
client has to have a sufficient key and certificate in order to |
client has to provided a certificate known by monit in order to |
1218 |
connect. This file also needs to have all necessary CA |
connect. This file also needs to have all necessary CA |
1219 |
certificates. A configuration could look like:</P> |
certificates. A configuration could look like:</P> |
1220 |
<PRE> |
<PRE> |
1221 |
set httpd port 2812 |
set httpd port 2812 |
1222 |
ssl enable |
ssl enable |
1223 |
pemfile /etc/certs/monit.pem |
pemfile /etc/certs/monit.pem |
1224 |
clientpemfile /etc/certs/monit-client.pem</PRE> |
clientpemfile /etc/certs/monit-client.pem</PRE> |
1225 |
<P>By default self signed certificates are not allowed. In case you need |
<P>By default self signed client certificates are not allowed. If |
1226 |
to use them it has to be allowed explicitly with the |
you want to use a self signed certificate from a client it has to |
1227 |
ALLOWSELFCERTIFICATION statement.</P> |
be allowed explicitly with the ALLOWSELFCERTIFICATION statement.</P> |
1228 |
|
<P>For more information on how to use monit with SSL and for more |
1229 |
|
information about certificates and generating pem files, please |
1230 |
|
consult the README.SSL file accompanying the software.</P> |
1231 |
<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 |
1232 |
one host addresses you can specify the bind address either as an |
one host addresses you can specify the bind address either as an |
1233 |
IP number string or as a hostname. In the following example we |
IP number string or as a hostname. In the following example we |
1238 |
<P>or</P> |
<P>or</P> |
1239 |
<PRE> |
<PRE> |
1240 |
set httpd port 2812 and use the address localhost</PRE> |
set httpd port 2812 and use the address localhost</PRE> |
|
<P>or with ssl</P> |
|
|
<PRE> |
|
|
set httpd port 2812 |
|
|
ssl enable |
|
|
address localhost |
|
|
pemfile /var/certs/monit.pem</PRE> |
|
1241 |
<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 |
1242 |
accept connections on any/all local addresses.</P> |
accept connections on any/all local addresses.</P> |
1243 |
<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 |
1248 |
automatically refreshed with the same poll time set for the monit |
automatically refreshed with the same poll time set for the monit |
1249 |
daemon.</P> |
daemon.</P> |
1250 |
<P><STRONG>Note:</STRONG></P> |
<P><STRONG>Note:</STRONG></P> |
1251 |
<P>You <EM>must</EM> start a monit daemon with http support if you want to |
<P>We strongly recommend that you start monit with http support (and |
1252 |
be able to use the following console commands.</P> |
bind the server to localhost, only, unless you are behind a |
1253 |
|
firewall). The built-in web-server is small and does not use |
1254 |
|
much resources, and more <EM>importantly</EM>, monit can use the http |
1255 |
|
server for interprocess communication between a monit client and |
1256 |
|
a monit daemon.</P> |
1257 |
|
<P>For instance, you <EM>must</EM> start a monit daemon with http support |
1258 |
|
if you want to be able to use the following console |
1259 |
|
commands. (That is; most of the available console commands).</P> |
1260 |
<PRE> |
<PRE> |
1261 |
'monit stop' |
'monit stop all' |
1262 |
'monit start service' |
'monit start all' |
1263 |
'monit stop service' |
'monit stop service' |
1264 |
|
'monit start service' |
1265 |
'monit restart service' |
'monit restart service' |
1266 |
'monit monitor service' |
'monit monitor service' |
1267 |
'monit unmonitor service' |
'monit unmonitor service' |
1268 |
'monit -g groupname start' |
'monit -g groupname stop all' |
1269 |
'monit -g groupname stop' |
'monit -g groupname start all' |
1270 |
'monit -g groupname restart' |
'monit -g groupname restart all' |
1271 |
'monit -g groupname monitor' |
'monit -g groupname monitor all' |
1272 |
'monit -g groupname unmonitor'</PRE> |
'monit -g groupname unmonitor all'</PRE> |
1273 |
<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 |
1274 |
deamon (via the HTTP protocol) to execute the above commands. |
deamon (via the HTTP protocol) to execute the above commands. |
1275 |
That is, the daemon is requested to start and stop the services. |
That is, the daemon is requested to start and stop the services. |
1278 |
from a service when you start it.</P> |
from a service when you start it.</P> |
1279 |
<P> |
<P> |
1280 |
<H2><A NAME="monit httpd authentication">Monit HTTPD Authentication</A></H2> |
<H2><A NAME="monit httpd authentication">Monit HTTPD Authentication</A></H2> |
1281 |
<P>monit supports two types of autenthication schemas for connecting |
<P>monit supports two types of authentication schema's for connecting |
1282 |
to the httpd server. Both schemas can be used together or by |
to the httpd server, (three, if you count SSL client certificate |
1283 |
itself. You <STRONG>must</STRONG> choose at least one.</P> |
validation). Both schema's can be used together or by itself. You |
1284 |
<P><STRONG>Host allow list</STRONG></P> |
<STRONG>must</STRONG> choose at least one.</P> |
1285 |
|
<P> |
1286 |
|
<H4><A NAME="host allow list">Host allow list</A></H4> |
1287 |
<P>The http server maintains an access-control list of hosts allowed |
<P>The http server maintains an access-control list of hosts allowed |
1288 |
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 |
1289 |
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 |
1290 |
allowed. If you specify a host that does not resolve, monit will |
allowed. If you specify a hostname that does not resolve, monit |
1291 |
write an error message in the console and not start.</P> |
will write an error message in the console and not start.</P> |
1292 |
<P>The http server will query a nameserver to check any hosts |
<P>The http server will query a nameserver to check any hosts |
1293 |
connecting to the server. If a host (client) is trying to connect |
connecting to the server. If a host (client) is trying to connect |
1294 |
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 |
1300 |
allow localhost |
allow localhost |
1301 |
allow my.other.work.machine.com |
allow my.other.work.machine.com |
1302 |
allow 10.1.1.1</PRE> |
allow 10.1.1.1</PRE> |
1303 |
<P><STRONG>Basic Authentication</STRONG></P> |
<P> |
1304 |
|
<H4><A NAME="basic authentication">Basic Authentication</A></H4> |
1305 |
<P>This authentication schema is HTTP specific and described in more |
<P>This authentication schema is HTTP specific and described in more |
1306 |
detail in RFC 2617.</P> |
detail in RFC 2617.</P> |
1307 |
<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 |
1315 |
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 |
1316 |
use Basic Authentication since <STRONG>all</STRONG> http data, including Basic |
use Basic Authentication since <STRONG>all</STRONG> http data, including Basic |
1317 |
Authentication headers will be encrypted.</P> |
Authentication headers will be encrypted.</P> |
1318 |
<P>monit will use Basic Authentication if an allow statement contains |
<P>monit will use Basic Authentication if an allow statement |
1319 |
a username and password separated with a single ':' character, |
contains a username and a password separated with a single ':' |
1320 |
like so; <EM>allow username:password</EM>. The username and password |
character, like so; <EM>allow username:password</EM>. The username and |
1321 |
must be written in clear-text. Only one username and password |
password must be written in clear-text. Only one username and |
1322 |
pair is supported.</P> |
password pair is supported.</P> |
1323 |
<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 |
1324 |
clients from the listed hosts will be allowed to connect to the |
clients from the listed hosts will be allowed to connect to the |
1325 |
monit http server and each client will be asked to provide a |
monit http server and each client will be asked to provide a |
1326 |
username and password.</P> |
username and a password.</P> |
1327 |
<P>Example:</P> |
<P>Example:</P> |
1328 |
<PRE> |
<PRE> |
1329 |
set httpd port 2812 |
set httpd port 2812 |
1330 |
allow localhost |
allow localhost |
|
allow my.other.work.machine.com |
|
1331 |
allow 10.1.1.1 |
allow 10.1.1.1 |
1332 |
allow hauk:monit</PRE> |
allow hauk:monit</PRE> |
1333 |
<P>If you only want to use Basic Authentication, then just provide |
<P>If you only want to use Basic Authentication, then just provide |
1337 |
allow hauk:monit</PRE> |
allow hauk:monit</PRE> |
1338 |
<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 |
1339 |
access permission for the control file (~/.monitrc) to only |
access permission for the control file (~/.monitrc) to only |
1340 |
readable and writeable for the user running monit, because the |
readable and writable for the user running monit, because the |
1341 |
password is written in clear-text. (Use this command, /bin/chmod |
password is written in clear-text. (Use this command, /bin/chmod |
1342 |
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 |
1343 |
complain and exit if the control file is readable by others.</P> |
complain and exit if the control file is readable by others.</P> |
1344 |
<P> |
<P> |
1345 |
<HR> |
<HR> |
1346 |
<H1><A NAME="dependency checking">DEPENDENCY CHECKING</A></H1> |
<H1><A NAME="dependency tree">DEPENDENCY TREE</A></H1> |
1347 |
<P>If specified in the control file, monit can do dependency |
<P>If specified in the control file, monit can do dependency |
1348 |
checking before starting, stopping, monitoring or unmonitoring |
checking before start, stop, monitoring or unmonitoring of |
1349 |
services. The syntax for the depend statement is simply:</P> |
services. The dependency statement may be used within any service |
1350 |
|
entries in the monit control file.</P> |
1351 |
|
<P>The syntax for the depend statement is simply:</P> |
1352 |
<DL> |
<DL> |
1353 |
<DT><STRONG><A NAME="item_DEPENDS_on_service%5B%2C_service_%5B%2C%2E%2E%2E%5">DEPENDS on service[, service [,...]]</A></STRONG><BR> |
<DT><STRONG><A NAME="item_DEPENDS_on_service%5B%2C_service_%5B%2C%2E%2E%2E%5">DEPENDS on service[, service [,...]]</A></STRONG><BR> |
1354 |
<DD> |
<DD> |
1355 |
</DL> |
</DL> |
1356 |
<P>Where <STRONG>service</STRONG> is a service entry name, for instance <STRONG>apache</STRONG> |
<P>Where <STRONG>service</STRONG> is a service entry name, for instance <STRONG>apache</STRONG> |
1357 |
or <STRONG>datafs</STRONG>.</P> |
or <STRONG>datafs</STRONG>.</P> |
1358 |
<P>You may add more than one service name of any type (device, |
<P>You may add more than one service name of any type or use more |
1359 |
directory, file or process) or use more than one depend statement |
than one depend statement in an entry.</P> |
1360 |
in an entry.</P> |
<P>Services specified in a <EM>depend</EM> statement will be checked |
1361 |
<P>Services specified in a <EM>depends</EM> statement will be checked |
during stop/start/monitor/unmonitor operations. If a service is |
1362 |
during stop/start/monitor/unmonitor operations. If a service |
stopped or unmonitored it will stop/unmonitor any services that |
1363 |
is stopped or unmonitored it will stop/unmonitor any services |
depends on itself. Likewise, if a service is started, it will |
1364 |
that depends on itself. Likewise, if a service is started, it |
first stop any services that depends on itself and after it is |
1365 |
will first stop any services that depends on itself and after |
started, start all depending services again. If the service is to |
1366 |
it is started, start all depending services again. If the |
be monitored (enable monitoring), all services which this service |
1367 |
service is to be monitored (enable monitoring), all services |
depends on will be monitored before enabling monitoring of this |
1368 |
which this service depends on will be monitored before enabling |
service.</P> |
1369 |
monitoring of this service.</P> |
<P>Here is an example where we set up an apache service entry to |
1370 |
|
depend on the underlying apache binary. If the binary should |
1371 |
|
change an alert is sent and apache is not monitored anymore. The |
1372 |
|
rationale is security and that monit should not execute a |
1373 |
|
possibly cracked apache binary.</P> |
1374 |
|
<PRE> |
1375 |
|
(1) check process apache |
1376 |
|
(2) with pidfile "/usr/local/apache/logs/httpd.pid" |
1377 |
|
(3) ... |
1378 |
|
(4) depends on httpd |
1379 |
|
(5) |
1380 |
|
(6) check file httpd with path /usr/local/apache/bin/httpd |
1381 |
|
(7) if failed checksum then unmonitor |
1382 |
|
(8) alert foo@bar.baz</PRE> |
1383 |
|
<P>The first entry is the process entry for apache shown before |
1384 |
|
(abbreviated for clarity). The fourth line sets up a dependency |
1385 |
|
between this entry and the service entry named httpd in line 6. A |
1386 |
|
depend tree works as follows, if an action is conducted in a |
1387 |
|
lower branch it will propagate upward in the tree and for every |
1388 |
|
dependent entry execute the same action. In this case, if the |
1389 |
|
checksum should fail in line 7 then an unmonitor action is |
1390 |
|
executed and the apache binary is not checked anymore. But since |
1391 |
|
the apache process entry depends on the httpd entry this entry |
1392 |
|
will also execute the unmonitor action. In short, if the checksum |
1393 |
|
test for the httpd binary file should fail, both the check file |
1394 |
|
httpd entry and the check process apache entry is set in |
1395 |
|
un-monitoring mode.</P> |
1396 |
|
<P>A dependency tree is a general construct and can be used between |
1397 |
|
all types of service entries and span many levels and propagate |
1398 |
|
any supported action (except the exec action which will not |
1399 |
|
propagate upward in a dependency tree for obvious reasons). Here |
1400 |
|
is another example, based on a different perspective, but with a |
1401 |
|
depend tree as the baseline:</P> |
1402 |
<P>Consider the following common server setup:</P> |
<P>Consider the following common server setup:</P> |
1403 |
<PRE> |
<PRE> |
1404 |
WEB-SERVER -> APPLICATION-SERVER -> DATABASE -> FILESYSTEM |
WEB-SERVER -> APPLICATION-SERVER -> DATABASE -> FILESYSTEM |
1406 |
<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 |
1407 |
application server to run before the web-server starts and the |
application server to run before the web-server starts and the |
1408 |
application server depends on the database server and the |
application server depends on the database server and the |
1409 |
database depends on filesystem to be mounted before it starts. |
database depends on the file-system to be mounted before it |
1410 |
See also the example section below for examples using the depend |
starts. See also the example section below for examples using |
1411 |
statement.</P> |
the depend statement.</P> |
1412 |
<P>Here we describe how monit will function with the above |
<P>Here we describe how monit will function with the above |
1413 |
dependencies:</P> |
dependencies:</P> |
1414 |
<DL> |
<DL> |
1419 |
<P></P> |
<P></P> |
1420 |
<DT><STRONG><A NAME="item_If_all_servers_are_running">If all servers are running</A></STRONG><BR> |
<DT><STRONG><A NAME="item_If_all_servers_are_running">If all servers are running</A></STRONG><BR> |
1421 |
<DD> |
<DD> |
1422 |
When you run 'monit stop' this is the stop order: <EM>a</EM>, <EM>b</EM>, |
When you run 'monit stop all' this is the stop order: <EM>a</EM>, <EM>b</EM>, |
1423 |
<EM>c</EM>, <EM>d</EM>. If you run 'monit stop d' then <EM>a</EM>, <EM>b</EM> and <EM>c</EM> |
<EM>c</EM>, <EM>d</EM>. If you run 'monit stop d' then <EM>a</EM>, <EM>b</EM> and <EM>c</EM> |
1424 |
are stopped because they depend on <EM>d</EM> and finally <EM>d</EM> is |
are also stopped because they depend on <EM>d</EM> and finally <EM>d</EM> is |
1425 |
stopped. |
stopped. |
1426 |
<P></P> |
<P></P> |
1427 |
<DT><STRONG><A NAME="item_If_a_does_not_run">If <EM>a</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> |
1446 |
<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> |
<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> |
1447 |
<DD> |
<DD> |
1448 |
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. |
1449 |
<P>When monit starts it will check for any such loops and complain |
<P>When monit starts it will check for such loops and complain and |
1450 |
and exit if a loop was found. It will also exit with a complaint |
exit if a loop was found. It will also exit with a complaint if a |
1451 |
if a depend statement was used that does not point to any service |
depend statement was used that does not point to a service in the |
1452 |
in the controlfile.</P> |
control file.</P> |
1453 |
<P></P></DL> |
<P></P></DL> |
1454 |
<P> |
<P> |
1455 |
<HR> |
<HR> |
1472 |
and may contain whitespace (and quoted digits are treated as a |
and may contain whitespace (and quoted digits are treated as a |
1473 |
string). An unquoted string is any whitespace-delimited token, |
string). An unquoted string is any whitespace-delimited token, |
1474 |
containing characters and/or numbers.</P> |
containing characters and/or numbers.</P> |
1475 |
<P>Each service entry consists of the keywords `check', followed by |
<P>On a semantic level, the control file consists of two types of |
1476 |
a type of service. There are currently four types of services |
entries:</P> |
1477 |
supported:</P> |
<OL> |
1478 |
<P>1.) device |
<LI><STRONG>Global set-statements</STRONG><BR> |
1479 |
2.) directory |
|
1480 |
3.) file |
A global set-statement starts with the keyword <EM>set</EM> and the |
1481 |
4.) process</P> |
item to configure. |
1482 |
<P>Unique descriptive name for the service follows service type |
<P></P> |
1483 |
specification. It is used by monit to refer this service |
<LI><STRONG>One or more service entry statements.</STRONG><BR> |
1484 |
internally and in all interactions with user.</P> |
|
1485 |
<P>Name is followed by `path' keyword which is followed depending on |
Each service entry consists of the keywords `check', followed by |
1486 |
the type of service:</P> |
the service type. Each entry requires a <unique> descriptive |
1487 |
<P>1.) device |
name. This name is used by monit to refer to the service |
1488 |
By a path to the device block special file, mountpoint, file |
internally and in all interactions with the user. |
1489 |
or directory which is part of the filesystem. It is recommended |
<P></P></OL> |
1490 |
to use block special file directly (for example /dev/hda1 on |
<P>Currently, five types of check statements are supported:</P> |
1491 |
Linux or /dev/dsk/c0t0d0s1 on Solaris, etc.) If you use |
<OL> |
1492 |
mountpoint (for example /data), be carefull, because if the |
<LI><STRONG><A NAME="item_CHECK_PROCESS_%3Cunique_name%3E_PIDFILE_%3Cpath%3E">CHECK PROCESS <unique name> PIDFILE <path></A></STRONG><BR> |
1493 |
device is dismounted it still exists but it is part of superior |
|
1494 |
filesystem.</P> |
<path> is the absolute path to the program's pidfile. If the |
1495 |
<PRE> |
pidfile does not exist or does not contain the pid number of a |
1496 |
In the case that the device becomes unavailable, monit will |
running process, monit will call the entry's start method if |
1497 |
call start/stop methods whenever defined if it is running in |
defined, If monit runs in passive mode or the start methods is |
1498 |
active mode. In the case that it is running in passive mode or |
not defined, monit will just send alerts on errors. |
1499 |
start/stop methods were not defined, it will just send failure |
<P></P> |
1500 |
alert.</PRE> |
<LI><STRONG><A NAME="item_CHECK_FILE_%3Cunique_name%3E_PATH_%3Cpath%3E">CHECK FILE <unique name> PATH <path></A></STRONG><BR> |
1501 |
<P>2.) directory |
|
1502 |
By a path to the directory (surprise :)</P> |
<path> is the absolute path to the file. If the file does not |
1503 |
<PRE> |
exist or disappeared, monit will call the entry's start method if |
1504 |
In the case that the directory doesn't exist any more |
defined, if <path> does not point to a regular file type (for |
1505 |
monit will call start/stop methods whenever defined if it is |
instance a directory), monit will disable monitoring of this |
1506 |
running in active mode. In the case that it is running in |
entry. If monit runs in passive mode or the start methods is not |
1507 |
passive mode or start/stop methods were not defined, it will |
defined, monit will just send alerts on errors. |
1508 |
just send failure alert.</PRE> |
<P></P> |
1509 |
<P>3.) file |
<LI><STRONG><A NAME="item_CHECK_DEVICE_%3Cunique_name%3E_PATH_%3Cpath%3E">CHECK DEVICE <unique name> PATH <path></A></STRONG><BR> |
1510 |
By a path to the file.</P> |
|
1511 |
<PRE> |
<path> is the path to the device block special file, mount point, |
1512 |
In the case that the file doesn't exist any more |
file or a directory which is part of a filesystem. It is |
1513 |
monit will call start/stop methods whenever defined if it is |
recommended to use a block special file directly (for example |
1514 |
running in active mode. In the case that it is running in |
/dev/hda1 on Linux or /dev/dsk/c0t0d0s1 on Solaris, etc.) If you |
1515 |
passive mode or start/stop methods were not defined, it will |
use a mount point (for example /data), be careful, because if the |
1516 |
just send failure alert.</PRE> |
device is unmounted the test will still be true becasue the mount |
1517 |
<P>4.) process |
point exist. |
1518 |
By a path to the program's pidfile. For this type of service you |
<P>If the device becomes unavailable, monit will call the entry's |
1519 |
can use keyword `pidfile' as predecesor of pidfile path instead |
start method if defined. if <path> does not point to a device, |
1520 |
of `path' keyword (for backward compatibility).</P> |
monit will disable monitoring of this entry. If monit runs in |
1521 |
<P>A check entry can have a number of optional statements. Each type |
passive mode or the start methods is not defined, monit will just |
1522 |
of service (device, directory, file, process) supports subset of |
send alerts on errors.</P> |
1523 |
these options, complete list follows:</P> |
<P></P> |
1524 |
<PRE> |
<LI><STRONG><A NAME="item_CHECK_DIRECTORY_%3Cunique_name%3E_PATH_%3Cpath%3E">CHECK DIRECTORY <unique name> PATH <path></A></STRONG><BR> |
1525 |
check device service1 with path /dev/hdb1 |
|
1526 |
start |
<path> is the absolute path to the directory. If the directory |
1527 |
stop |
does not exist or disappeared, monit will call the entry's start |
1528 |
timeout |
method if defined, if <path> does not point to a directory, monit |
1529 |
every |
will disable monitoring of this entry. If monit runs in passive |
1530 |
alert |
mode or the start methods is not defined, monit will just send |
1531 |
mode |
alerts on errors. |
1532 |
group |
<P></P> |
1533 |
depend |
<LI><STRONG><A NAME="item_CHECK_HOST_%3Cunique_host_address%3E">CHECK HOST <unique host address></A></STRONG><BR> |
1534 |
inode |
|
1535 |
space |
The host address can be specified as a hostname string or as an |
1536 |
permission |
ip-address string on a dotted decimal format. Such as, |
1537 |
uid |
tildeslash.com or ``64.87.72.95'' |
1538 |
gid</PRE> |
<P></P></OL> |
|
<PRE> |
|
|
check directory service2 with path /mydir |
|
|
start |
|
|
stop |
|
|
timeout |
|
|
every |
|
|
alert |
|
|
mode |
|
|
group |
|
|
depend |
|
|
timestamp |
|
|
permission |
|
|
uid |
|
|
gid</PRE> |
|
|
<PRE> |
|
|
check file service3 with path /mydir/myfile |
|
|
start |
|
|
stop |
|
|
timeout |
|
|
every |
|
|
alert |
|
|
mode |
|
|
group |
|
|
depend |
|
|
checksum |
|
|
timestamp |
|
|
permission |
|
|
uid |
|
|
gid</PRE> |
|
|
<PRE> |
|
|
check [process] service4 with {pidfile|path} /var/run/myproc.pid |
|
|
start |
|
|
stop |
|
|
host |
|
|
unixsocket |
|
|
resource |
|
|
timeout |
|
|
every |
|
|
alert |
|
|
mode |
|
|
group |
|
|
depend</PRE> |
|
|
<P>These statements are described below and in the example section.</P> |
|
1539 |
<P>You can use noise keywords like 'if', `and', `with(in)', `has', |
<P>You can use noise keywords like 'if', `and', `with(in)', `has', |
1540 |
`using', 'use', 'on(ly)', `usage' and `program(s)' anywhere in |
`using', 'use', 'on(ly)', `usage' and `program(s)' anywhere in an |
1541 |
an entry to make it resemble English. They're ignored, but can |
entry to make it resemble English. They're ignored, but can make |
1542 |
make entries much easier to read at a glance. The punctuation |
entries much easier to read at a glance. The punctuation |
1543 |
characters ';' ',' and '=' are also ignored. Keywords are case |
characters ';' ',' and '=' are also ignored. Keywords are case |
1544 |
insensitive.</P> |
insensitive.</P> |
1545 |
<PRE> |
<PRE> |
1546 |
Here are the legal global keywords:</PRE> |
Here are the legal global keywords:</PRE> |
1547 |
<PRE> |
<PRE> |
1548 |
Keyword Function |
Keyword Function |
1549 |
----------------------------------------------------------- |
---------------------------------------------------------------- |
1550 |
set daemon Set a background poll interval in seconds |
set daemon Set a background poll interval in seconds. |
1551 |
set init Set monit to run from init |
set init Set monit to run from init. monit will not |
1552 |
|
transform itself into a daemon process. |
1553 |
set logfile Name of a file to dump error- and status- |
set logfile Name of a file to dump error- and status- |
1554 |
messages to. If syslog is specified as the |
messages to. If syslog is specified as the |
1555 |
file, monit will utilize the syslog daemon |
file, monit will utilize the syslog daemon |
1557 |
followed by 'facility <facility>' where |
followed by 'facility <facility>' where |
1558 |
facility is 'log_local0' - 'log_local7' or |
facility is 'log_local0' - 'log_local7' or |
1559 |
'log_daemon'. If no facility is specified, |
'log_daemon'. If no facility is specified, |
1560 |
LOG_USER is used.</PRE> |
LOG_USER is used. |
|
<PRE> |
|
1561 |
set mailserver The mailserver used for sending alert |
set mailserver The mailserver used for sending alert |
1562 |
notifications. If the mailserver is not |
notifications. If the mailserver is not |
1563 |
defined, monit will try to use 'localhost' |
defined, monit will try to use 'localhost' |
1565 |
set mail-format Set a global mail format for all alert |
set mail-format Set a global mail format for all alert |
1566 |
messages emitted by monit. |
messages emitted by monit. |
1567 |
set pidfile Explicit set the location of the monit lock |
set pidfile Explicit set the location of the monit lock |
1568 |
file. E.g. set pidfile /run/monit.pid. |
file. E.g. set pidfile /var/run/xyzmonit.pid. |
1569 |
set statefile Explicit set the location of file monit |
set statefile Explicit set the location of the file monit |
1570 |
will write state data to. If not set the |
will write state data to. If not set, the |
1571 |
default is $HOME/.monit.state. |
default is $HOME/.monit.state. |
1572 |
set httpd port Activates monit http server at the given |
set httpd port Activates monit http server at the given |
1573 |
portnumber. |
portnumber. |
1574 |
ssl enable Enables ssl support for the httpd server. |
ssl enable Enables ssl support for the httpd server. |
1575 |
It requires the use of the pemfile statement. |
Requires the use of the pemfile statement. |
1576 |
ssl disable Disables ssl support for the httpd server. |
ssl disable Disables ssl support for the httpd server. |
1577 |
It is equal to omitting any ssl statement. |
It is equal to omitting any ssl statement. |
1578 |
pemfile Set the pemfile to be used with ssl. |
pemfile Set the pemfile to be used with ssl. |
1579 |
clientpemfile Set the pemfile to be used when client's |
clientpemfile Set the pemfile to be used when client |
1580 |
certificates should be checked too. |
certificates should be checked by monit. |
1581 |
address If specified, the http server will only |
address If specified, the http server will only |
1582 |
accept connect requests to this addresses |
accept connect requests to this addresses |
1583 |
This statement is an optional part of the |
This statement is an optional part of the |
1592 |
Here are the legal service entry keywords:</PRE> |
Here are the legal service entry keywords:</PRE> |
1593 |
<PRE> |
<PRE> |
1594 |
Keyword Function |
Keyword Function |
1595 |
------------------------------------------------------------ |
---------------------------------------------------------------- |
1596 |
check Starts an entry and must be followed by type |
check Starts an entry and must be followed by the type |
1597 |
of monitored service {device|directory|file| |
of monitored service {device|directory|file|host |
1598 |
process} and descriptive name for the service. |
process} and a descriptive name for the service. |
1599 |
pidfile Specify the process pidfile. Every |
pidfile Specify the process pidfile. Every |
1600 |
process must create a pidfile with its |
process must create a pidfile with its |
1601 |
current process id. This statement is possible |
current process id. This statement should only |
1602 |
to use with process monitoring type only (for |
be used in a process service entry. |
|
backward compatibility). You can use path |
|
|
statement with process monitoring type as well |
|
|
(see bellow). |
|
1603 |
path Must be followed by a path to the block |
path Must be followed by a path to the block |
1604 |
special file for filesystem (device), regular |
special file for filesystem (device), regular |
1605 |
file, directory or process's pidfile. |
file, directory or a process's pidfile. |
1606 |
group Specify a groupname for a service entry. |
group Specify a groupname for a service entry. |
1607 |
start The program for starting the specified |
start The program used to start the specified |
1608 |
service. Full path is required. This |
service. Full path is required. This |
1609 |
statement is optional. |
statement is optional, but recommended. |
1610 |
stop The program for stopping the specified |
stop The program used to stop the specified |
1611 |
service. Full path is required. This |
service. Full path is required. This |
1612 |
statement is optional. |
statement is optional, but recommended. |
1613 |
uid and gid Either optional part of a start, stop or exec |
uid and gid These keywords are either 1) an optional part of |
1614 |
statement (then it may be used to specify a user |
a start, stop or exec statement. They may be |
1615 |
id and a group id the program should be started |
used to specify a user id and a group id the |
1616 |
as) or standalone statement of file service |
program (process) should switch to upon start. |
1617 |
check. The uid and gid may be specified as a |
This feature can only be used if the superuser |
1618 |
name or as a number. The first form of this |
is running monit. 2) uid and gid may also be |
1619 |
extension may only be used if the super-user |
used as standalone statements in a file service |
1620 |
is running monit. |
entry to test a file's uid and gid attributes. |
1621 |
host The hostname or IP address to test the port |
host The hostname or IP address to test the port |
1622 |
at. This keyword can only be used together |
at. This keyword can only be used together |
1623 |
with a port statement. |
with a port statement or in the check host |
1624 |
|
statement. |
1625 |
port Specify a TCP/IP service port number which |
port Specify a TCP/IP service port number which |
1626 |
the program is listening on. This statement |
a process is listening on. This statement |
1627 |
is also optional. If this statement is not |
is also optional. If this statement is not |
1628 |
prefixed with a host-statement, localhost is |
prefixed with a host-statement, localhost is |
1629 |
used as the hostname to test the port at. |
used as the hostname to test the port at. |
1630 |
type Specifies the type of socket monit should |
type Specifies the socket type monit should use when |
1631 |
use when testing a connection to the port. |
testing a connection to a port. If the type |
1632 |
If the type keyword is omitted, tcp is |
keyword is omitted, tcp is used. This keyword |
1633 |
used. This keyword must be followed by |
must be followed by either tcp, udp or tcpssl. |
|
either tcp or udp. |
|
1634 |
tcp Specifies that monit should use a TCP |
tcp Specifies that monit should use a TCP |
1635 |
socket type (stream) when testing the port. |
socket type (stream) when testing a port. |
1636 |
tcpssl Specifies that monit should use a TCP |
tcpssl Specifies that monit should use a TCP socket |
1637 |
socket type (stream) which is embeds a ssl |
type (stream) and the secure socket layer (ssl) |
1638 |
connection when testing the port. |
when testing a port connection. |
1639 |
udp Specifies that monit should use a UDP socket |
udp Specifies that monit should use a UDP socket |
1640 |
type (datagram) when testing the port. |
type (datagram) when testing a port. |
1641 |
certmd5 The md5 sum of a certificate a ssl forged |
certmd5 The md5 sum of a certificate a ssl forged |
1642 |
server has to deliver. |
server has to deliver. |
1643 |
proto(col) This keyword specifies the type of service |
proto(col) This keyword specifies the type of service |
1649 |
ault test which in most cases are good enough. |
ault test which in most cases are good enough. |
1650 |
request Specifies a server request and must come |
request Specifies a server request and must come |
1651 |
after the protocol keyword mentioned above. |
after the protocol keyword mentioned above. |
1652 |
- for http it can contain an URI and an |
- for http it can contain an URL and an |
1653 |
optional query string. |
optional query string. |
1654 |
- other protocols does not support this |
- other protocols does not support this |
1655 |
statement yet |
statement yet |
1656 |
unix(socket) Specifies a unix socket file and used like |
unix(socket) Specifies a Unix socket file and used like |
1657 |
the port statement above to test a Unix |
the port statement above to test a Unix |
1658 |
domain network socket connection. |
domain network socket connection. |
1659 |
timeout x sec. Define a network port connection timeout. Must |
timeout x sec. Define a network port connection timeout. Must |
1660 |
be followed by a number in seconds and the |
be followed by a number in seconds and the |
1661 |
keyword, seconds. |
keyword, seconds. |
1662 |
timeout Define service timeout. Must be followed by |
timeout Define a service timeout. Must be followed by |
1663 |
two digits. The first digit is max number of |
two digits. The first digit is max number of |
1664 |
restarts for the service. The second digit |
restarts for the service. The second digit |
1665 |
is the cycle interval to test restarts. |
is the cycle interval to test restarts. |
1666 |
This statement is optional |
This statement is optional. |
1667 |
alert Specifies an email address for notification |
alert Specifies an email address for notification |
1668 |
if timeout, start, restart, checksum, resource, |
if a service event occurs. Alert can also |
|
stop, connection, size, permission, uid, gid, |
|
|
unmonitor or timestamp occurs. Alert can also |
|
1669 |
be postfixed, to only send a message for |
be postfixed, to only send a message for |
1670 |
certain events. See the examples above. More |
certain events. See the examples above. More |
1671 |
than one alert statement is allowed in an |
than one alert statement is allowed in an |
1674 |
unmonitor and various test statements. The exec statement is |
unmonitor and various test statements. The exec statement is |
1675 |
exec special in that it requires a following string |
exec special in that it requires a following string |
1676 |
specifying the program to be execute. You may |
specifying the program to be execute. You may |
1677 |
also specify an UID and GID to the exec |
also specify an UID and GID for the exec |
1678 |
statement. The program executed will then run |
statement. The program executed will then run |
1679 |
using the specified user id and group id. |
using the specified user id and group id. |
1680 |
mail-format Specifies a mail format for an alert message |
mail-format Specifies a mail format for an alert message |
1681 |
This statement is an optional part of the |
This statement is an optional part of the |
1682 |
alert statement. |
alert statement. |
1683 |
checksum Specify that monit should verify a checksum |
checksum Specify that monit should compute and monitor a |
1684 |
for associated file. |
file's md5 checksum. May only be used in a check |
1685 |
More than one checksum statement are allowed. |
file entry. |
1686 |
expect Specifies a checksum string (md5) monit |
expect Specifies a md5 checksum string monit should |
1687 |
should use when testing the checksum. This |
expect when testing the checksum. This statement |
1688 |
statement is an optional part of the |
is an optional part of the checksum statement. |
1689 |
checksum statement. |
timestamp Specifies an expected timestamp for a file |
1690 |
timestamp Specifies expected timestamp for associated file |
or directory. More than one timestamp statement |
1691 |
or directory and optional action. More than one |
are allowed. May only be used in a check file or |
1692 |
timeout statement are allowed. |
check directory entry. |
1693 |
changed Part of a time statement and used as an operator |
changed Part of a timestamp statement and used as an |
1694 |
to simply test for a timestamp change. |
operator to simply test for a timestamp change. |
1695 |
every Validate this entry only at every n poll |
every Validate this entry only at every n poll cycle. |
1696 |
cycle. Usefull in daemon mode when the |
Useful in daemon mode when the cycle is short |
1697 |
poll-cycle is short and the service takes |
and a service takes some time to start. |
|
some time to start. |
|
1698 |
mode Must be followed either by the keyword active, |
mode Must be followed either by the keyword active, |
1699 |
passive or manual. If active, monit will restart |
passive or manual. If active, monit will restart |
1700 |
the service if it is not running (this is the |
the service if it is not running (this is the |
1701 |
default behaviour). If passive, monit will not |
default behavior). If passive, monit will not |
1702 |
(re)start the service if it is not running - it |
(re)start the service if it is not running - it |
1703 |
will only monitor and send alerts (resource |
will only monitor and send alerts (resource |
1704 |
related restart and stop options are ignored |
related restart and stop options are ignored |
1710 |
with "%", optionally a maximum number of cycles |
with "%", optionally a maximum number of cycles |
1711 |
and an action. This statement is used to check |
and an action. This statement is used to check |
1712 |
the cpu usage in percent of a process with it's |
the cpu usage in percent of a process with it's |
1713 |
children over a number of cylces. If the |
children over a number of cycles. If the |
1714 |
compare expression matches then the action |
compare expression matches then the specified |
1715 |
restart, alert or stop is activated. |
action is executed. |
1716 |
mem The equivalent to the cpu token for memory of a |
mem The equivalent to the cpu token for memory of a |
1717 |
process (w/o children!). This token must be |
process (w/o children!). This token must be |
1718 |
followed by a compare operator a number with |
followed by a compare operator a number with |
1721 |
of cycles and an action. |
of cycles and an action. |
1722 |
loadavg Must be followed by [1min,5min,15min] in (), a |
loadavg Must be followed by [1min,5min,15min] in (), a |
1723 |
compare operator, a number, optionally a maximum |
compare operator, a number, optionally a maximum |
1724 |
number of cycles and an action. |
number of cycles and an action. This statement |
1725 |
This statement is used to check the system load |
is used to check the system load average over a |
1726 |
average over a number of cylces. If the compare |
number of cycles. If the compare expression |
1727 |
expression matches then the action start, alert |
matches then the specified action is executed. |
1728 |
or stop is activated. |
children This is the number of child processes spawn by a |
|
children This is the number of child processes of a |
|
1729 |
process. The syntax is the same as above. |
process. The syntax is the same as above. |
1730 |
totalmem The equivalent to memory for memory of a |
totalmem The equivalent of mem, except totalmem is an |
1731 |
process and it's child processes. The syntax |
aggregation of memory, not only used by a |
1732 |
is the same as above. |
process but also by all it's child |
1733 |
|
processes. The syntax is the same as above. |
1734 |
space Must be followed by a compare operator, a |
space Must be followed by a compare operator, a |
1735 |
number, unit {B|KB|MB|GB|%|byte|kilobyte| |
number, unit {B|KB|MB|GB|%|byte|kilobyte| |
1736 |
megabyte|gigabyte|percent} and action. |
megabyte|gigabyte|percent} and an action. |
1737 |
inode(s) Must be followed by a compare operator, integer |
inode(s) Must be followed by a compare operator, integer |
1738 |
number, optionaly by percent sign (if not, the |
number, optionally by percent sign (if not, the |
1739 |
limit is absolute) and action (required). |
limit is absolute) and an action. |
1740 |
perm(ission) Must be followed by an octal number describing |
perm(ission) Must be followed by an octal number describing |
1741 |
permissions. |
the permissions. |
1742 |
size Must be followed by a compare operator, a |
size Must be followed by a compare operator, a |
1743 |
number, unit {B|KB|MB|GB|byte|kilobyte| |
number, unit {B|KB|MB|GB|byte|kilobyte| |
1744 |
megabyte|gigabyte} and action. |
megabyte|gigabyte} and an action. |
1745 |
depends (on) Must be followed by the name of a service this |
depends (on) Must be followed by the name of a service this |
1746 |
service depends on to run before it starts.</PRE> |
service depends on.</PRE> |
1747 |
<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> |
1748 |
<P><EM>if</EM>, <EM>then</EM>, <EM>else</EM>, <EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, |
<P><EM>if</EM>, <EM>then</EM>, <EM>else</EM>, <EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, |
1749 |
<EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>, <EM>ssl</EM>, <EM>enable</EM>, <EM>disable</EM>, |
<EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>, <EM>ssl</EM>, <EM>enable</EM>, <EM>disable</EM>, |
1759 |
<EM>children</EM>, <EM>loadavg</EM>, <EM>timestamp</EM>, <EM>changed</EM>, <EM>second(s)</EM>, |
<EM>children</EM>, <EM>loadavg</EM>, <EM>timestamp</EM>, <EM>changed</EM>, <EM>second(s)</EM>, |
1760 |
<EM>minute(s)</EM>, <EM>hour(s)</EM>, <EM>day(s)</EM>, <EM>space</EM>, <EM>inode</EM>, |
<EM>minute(s)</EM>, <EM>hour(s)</EM>, <EM>day(s)</EM>, <EM>space</EM>, <EM>inode</EM>, |
1761 |
<EM>perm(ission)</EM>, <EM>process</EM>, <EM>file</EM>, <EM>directory</EM>, <EM>device</EM>, |
<EM>perm(ission)</EM>, <EM>process</EM>, <EM>file</EM>, <EM>directory</EM>, <EM>device</EM>, |
1762 |
<EM>size</EM>, <EM>unmonitor</EM>, <rdate>, <rsync> and <EM>failed</EM></P> |
<EM>size</EM>, <EM>unmonitor</EM>, <EM>rdate</EM>, <EM>rsync</EM> and <EM>failed</EM></P> |
1763 |
<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 |
1764 |
monit:</P> |
monit:</P> |
1765 |
<P><EM>is</EM>, <EM>are</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>, <EM>using</EM>, |
<P><EM>is</EM>, <EM>as</EM>, <EM>are</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>, |
1766 |
<EM>use</EM>, <EM>the</EM>, <EM>sum</EM>, <EM>program(s)</EM>, <EM>cycle(s)</EM>, <EM>than</EM>, |
<EM>using</EM>, <EM>use</EM>, <EM>the</EM>, <EM>sum</EM>, <EM>program(s)</EM>, <EM>than</EM>, <EM>for</EM>, |
1767 |
<EM>for</EM>, <EM>usage</EM>, <EM>was</EM>.</P> |
<EM>usage</EM>, <EM>was</EM>.</P> |
1768 |
<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, |
1769 |
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 |
1770 |
first line must specify an interpreter for the |
first line must specify an interpreter for the |
1774 |
<PRE> |
<PRE> |
1775 |
start="/bin/bash -c 'echo $$ > pidfile; exec program'" |
start="/bin/bash -c 'echo $$ > pidfile; exec program'" |
1776 |
stop="/bin/bash -c 'kill -s SIGTERM `cat pidfile`'"</PRE> |
stop="/bin/bash -c 'kill -s SIGTERM `cat pidfile`'"</PRE> |
|
<P>When a program is started by monit</P> |
|
1777 |
<P> |
<P> |
1778 |
<H2><A NAME="configuration examples">CONFIGURATION EXAMPLES</A></H2> |
<H2><A NAME="configuration examples">CONFIGURATION EXAMPLES</A></H2> |
1779 |
<P>The simplest form is just the check statement. In this example we |
<P>The simplest form is just the check statement. In this example we |
1784 |
statement:</P> |
statement:</P> |
1785 |
<PRE> |
<PRE> |
1786 |
check process resin with pidfile /usr/local/resin/srun.pid |
check process resin with pidfile /usr/local/resin/srun.pid |
1787 |
start program = "/usr/local/resin/bin/srun.sh start"</PRE> |
start program = "/usr/local/resin/bin/srun.sh start"</PRE> |
1788 |
<P>Here's a more advanced example for monitoring an apache |
<P>Here's a more advanced example for monitoring an apache |
1789 |
web-server listening on the default portnumber for HTTP and |
web-server listening on the default portnumber for HTTP and |
1790 |
HTTPS. In this example monit will restart apache if it's not |
HTTPS. In this example monit will restart apache if it's not |
1796 |
sent).</P> |
sent).</P> |
1797 |
<PRE> |
<PRE> |
1798 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1799 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1800 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1801 |
if failed port 80 then restart |
if failed port 80 then restart |
1802 |
if failed port 443 with timeout 15 seconds then restart</PRE> |
if failed port 443 with timeout 15 seconds then restart</PRE> |
1803 |
<P>This example demonstrate how you can run a program as a specified |
<P>This example demonstrate how you can run a program as a specified |
1804 |
user (uid) and with a specified group (gid). Many daemon programs |
user (uid) and with a specified group (gid). Many daemon programs |
1805 |
will do the uid and gid switch by themself, but for those |
will do the uid and gid switch by themself, but for those |
1812 |
gid.</P> |
gid.</P> |
1813 |
<PRE> |
<PRE> |
1814 |
check tomcat with pidfile /var/run/tomcat.pid |
check tomcat with pidfile /var/run/tomcat.pid |
1815 |
start program = "/etc/init.d/tomcat start" |
start program = "/etc/init.d/tomcat start" |
1816 |
as uid nobody and gid nobody |
as uid nobody and gid nobody |
1817 |
stop program = "/etc/init.d/tomcat stop" |
stop program = "/etc/init.d/tomcat stop" |
1818 |
# You can also use id numbers instead and write: |
# You can also use id numbers instead and write: |
1819 |
as uid 99 and with gid 99 |
as uid 99 and with gid 99 |
1820 |
if failed port 8080 then alert</PRE> |
if failed port 8080 then alert</PRE> |
1821 |
<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 |
1822 |
'named' service is running and also use timeout and alert:</P> |
name-server is running and also use timeout and alert:</P> |
1823 |
<PRE> |
<PRE> |
1824 |
check process named with pidfile /var/run/named.pid |
check process named with pidfile /var/run/named.pid |
1825 |
start program = "/etc/init.d/named start" |
start program = "/etc/init.d/named start" |
1826 |
stop program = "/etc/init.d/named stop" |
stop program = "/etc/init.d/named stop" |
1827 |
if failed port 53 use type udp then restart |
if failed port 53 use type udp then restart |
1828 |
if 3 restarts within 5 cycles then timeout |
if 3 restarts within 5 cycles then timeout |
1829 |
alert bofh@norid.no</PRE> |
alert bofh@norid.no</PRE> |
1830 |
<P>The following example illustrate how to check if the service |
<P>The following example illustrate how to check if the service |
1831 |
'sophie' is answering connections on its unix domain socket:</P> |
'sophie' is answering connections on its Unix domain socket:</P> |
1832 |
<PRE> |
<PRE> |
1833 |
check process sophie with pidfile /var/run/sophie.pid |
check process sophie with pidfile /var/run/sophie.pid |
1834 |
start program = "/etc/init.d/sophie start" |
start program = "/etc/init.d/sophie start" |
1835 |
stop program = "/etc/init.d/sophie stop" |
stop program = "/etc/init.d/sophie stop" |
1836 |
if failed unix /var/run/sophie then restart</PRE> |
if failed unix /var/run/sophie then restart</PRE> |
1837 |
<P>In this example we check an apache web-server running on |
<P>In this example we check an apache web-server running on |
1838 |
localhost that answers for several IP-based virtual hosts or |
localhost that answers for several IP-based virtual hosts or |
1839 |
vhosts, hence the host statement before port:</P> |
vhosts, hence the host statement before port:</P> |
1840 |
<PRE> |
<PRE> |
1841 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1842 |
start program = "/etc/init.d/httpd start" |
start "/etc/init.d/httpd start" |
1843 |
stop program = "/etc/init.d/httpd stop" |
stop "/etc/init.d/httpd stop" |
1844 |
if failed host www.sol.no port 80 then alert |
if failed host www.sol.no port 80 then alert |
1845 |
if failed host shop.sol.no port 443 then alert |
if failed host shop.sol.no port 443 then alert |
1846 |
if failed host chat.sol.no port 80 then alert |
if failed host chat.sol.no port 80 then alert |
1847 |
if failed host www.tildeslash.com port 80 then alert</PRE> |
if failed host www.tildeslash.com port 80 then alert</PRE> |
1848 |
<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 |
1849 |
checksum for the underlying apache binary used by the start and |
checksum for the underlying apache binary used by the start and |
1850 |
stop programs. In the case that the chaksum will fail, the |
stop programs. If the the checksum test should fail, monitoring |
1851 |
monitoring will be disabled to prevent compromited binary |
will be disabled to prevent possibly starting a compromised |
1852 |
execution:</P> |
binary:</P> |
1853 |
<PRE> |
<PRE> |
1854 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1855 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1856 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1857 |
if failed host www.tildeslash.com port 80 then restart |
if failed host www.tildeslash.com port 80 then restart |
1858 |
depends on apache_bin</PRE> |
depends on apache_bin</PRE> |
1859 |
<PRE> |
<PRE> |
1860 |
check file apache_bin with path /usr/local/apache/bin/httpd |
check file apache_bin with path /usr/local/apache/bin/httpd |
1861 |
if failed checksum then unmonitor</PRE> |
if failed checksum then unmonitor |
1862 |
|
alert foo@bar.baz</PRE> |
1863 |
<P>Some servers are slow starters, like for example Java based |
<P>Some servers are slow starters, like for example Java based |
1864 |
Application Servers. So if we want to keep the poll-cycle low |
Application Servers. So if we want to keep the poll-cycle low |
1865 |
(i.e. < 60 seconds) but allow some services to take its time to |
(i.e. < 60 seconds) but allow some services to take its time to |
1866 |
start, the <STRONG>every</STRONG> statement is handy:</P> |
start, the <STRONG>every</STRONG> statement is handy:</P> |
1867 |
<PRE> |
<PRE> |
1868 |
check process dynamo with pidfile /etc/dynamo.pid |
check process dynamo with pidfile /etc/dynamo.pid |
1869 |
start program = "/etc/init.d/dynamo start" |
start program = "/etc/init.d/dynamo start" |
1870 |
stop program = "/etc/init.d/dynamo stop" |
stop program = "/etc/init.d/dynamo stop" |
1871 |
if failed port 8840 then alert |
if failed port 8840 then alert |
1872 |
every 2 cycle</PRE> |
every 2 cycles</PRE> |
1873 |
<P>Here is an example where we group together two database entries. |
<P>Here is an example where we group together two database entries |
1874 |
The mode statement is also illustrated in the first entry and |
so you can manage them together, e.g.; 'monit -g database start |
1875 |
have the effect that monit will not try to (re)start this service |
all'. The mode statement is also illustrated in the first entry |
1876 |
if it is not running:</P> |
and have the effect that monit will not try to (re)start this |
1877 |
|
service if it is not running:</P> |
1878 |
<PRE> |
<PRE> |
1879 |
check process sybase with pidfile /var/run/sybase.pid |
check process sybase with pidfile /var/run/sybase.pid |
1880 |
start program = "/etc/init.d/sybase start" |
start = "/etc/init.d/sybase start" |
1881 |
stop program = "/etc/init.d/sybase stop" |
stop = "/etc/init.d/sybase stop" |
1882 |
mode passive |
mode passive |
1883 |
group database</PRE> |
group database</PRE> |
1884 |
<PRE> |
<PRE> |
1885 |
check process oracle with pidfile /var/run/oracle.pid |
check process oracle with pidfile /var/run/oracle.pid |
1886 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1887 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1888 |
mode active # Not necessary really, since this is the default |
mode active # Not necessary really, since it's the default |
1889 |
if failed port 9001 then restart |
if failed port 9001 then restart |
1890 |
alert bofh@foo.bar |
alert bofh@foo.bar |
1891 |
group database</PRE> |
group database</PRE> |
1892 |
<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 |
1893 |
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 |
1894 |
child processes raises beyond 60% for over two cycles. It is |
child processes raises beyond 60% for over two cycles. Apache is |
1895 |
restarted when the CPU usage if over 80% for five cycles, the |
restarted if the CPU usage is over 80% for five cycles or the |
1896 |
memory usage over 100Mb for five cycles or if the machines load |
memory usage over 100Mb for five cycles or if the machines load |
1897 |
average is beyond 10 for 8 cycles:</P> |
average is more than 10 for 8 cycles:</P> |
1898 |
<PRE> |
<PRE> |
1899 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1900 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1901 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1902 |
if cpu > 60% for 2 cycles then alert |
if cpu > 60% for 2 cycles then alert |
1903 |
if cpu > 80% for 5 cycles then restart |
if cpu > 80% for 5 cycles then restart |
1904 |
if mem > 100 MB for 5 cycles then stop |
if mem > 100 MB for 5 cycles then stop |
1905 |
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> |
1906 |
<P>This examples demonstrate the timestamp statement with exec and |
<P>This examples demonstrate the timestamp statement with exec and |
1907 |
how you may restart apache if it's configuration file was |
how you may restart apache if it's configuration file was |
1908 |
changed.</P> |
changed.</P> |
1909 |
<PRE> |
<PRE> |
1910 |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
1911 |
if timestamp was changed then exec "/etc/init.d/httpd graceful"</PRE> |
if timestamp was changed |
1912 |
|
then exec "/etc/init.d/httpd graceful"</PRE> |
1913 |
<P>In this example we demonstrate usage of the extended alert |
<P>In this example we demonstrate usage of the extended alert |
1914 |
statement and file check dependency:</P> |
statement and a file check dependency:</P> |
1915 |
<PRE> |
<PRE> |
1916 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1917 |
start program = "/etc/init.d/httpd start" |
start = "/etc/init.d/httpd start" |
1918 |
stop program = "/etc/init.d/httpd stop" |
stop = "/etc/init.d/httpd stop" |
1919 |
if failed host www.tildeslash.com port 80 then restart |
if failed host www.tildeslash.com port 80 then restart |
1920 |
alert admin@bar on {restart, timeout} |
alert admin@bar on {restart, timeout} |
1921 |
with mail-format { |
with mail-format { |
1922 |
from: bofh@$HOST |
from: bofh@$HOST |
1923 |
subject: apache $EVENT |
subject: apache $EVENT |
1924 |
message: This event occurred on $HOST at $DATE.</PRE> |
message: This event occurred on $HOST at $DATE. |
|
<PRE> |
|
1925 |
Your faithful employee, |
Your faithful employee, |
1926 |
monit |
monit |
1927 |
} |
} |
1928 |
if 3 restarts within 5 cycles then timeout |
if 3 restarts within 5 cycles then timeout |
1929 |
depend httpd_bin |
depend httpd_bin |
1930 |
group apache</PRE> |
group apache</PRE> |
1931 |
<PRE> |
<PRE> |
1932 |
check file httpd_bin with path /usr/local/apache/bin/httpd |
check file httpd_bin with path /usr/local/apache/bin/httpd |
1933 |
if failed checksum and expect 8f7f419955cefa0b33a2ba316cba3659 |
if failed checksum |
1934 |
then unmonitor |
and expect 8f7f419955cefa0b33a2ba316cba3659 |
1935 |
if failed permission 755 then unmonitor |
then unmonitor |
1936 |
if failed uid root then unmonitor |
if failed permission 755 then unmonitor |
1937 |
if failed gid root then unmonitor |
if failed uid root then unmonitor |
1938 |
if size changed then alert |
if failed gid root then unmonitor |
1939 |
if timestamp changed then alert |
if timestamp changed then alert |
1940 |
alert security@bar on {checksum, size, timestamp, permission, |
alert security@bar on {checksum, timestamp, |
1941 |
uid, gid, unmonitor} with mail-format |
permission, uid, gid, unmonitor} |
1942 |
{subject: Alaaarrm! on $HOST} |
with mail-format {subject: Alaaarrm! on $HOST} |
1943 |
group apache</PRE> |
group apache</PRE> |
1944 |
<P>In this example, we demonstrate usage of the depend statement. In |
<P>In this example, we demonstrate usage of the depend statement. In |
1945 |
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 |
1946 |
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, |
1947 |
apache must be restarted as well.</P> |
apache must be restarted as well.</P> |
1948 |
<PRE> |
<PRE> |
1949 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1950 |
start program = "/etc/init.d/httpd start" |
start = "/etc/init.d/httpd start" |
1951 |
stop program = "/etc/init.d/httpd stop" |
stop = "/etc/init.d/httpd stop" |
1952 |
depends on oracle</PRE> |
depends on oracle</PRE> |
|
<PRE> |
|
|
check process oracle with pidfile /var/run/oracle.pid |
|
|
start program = "/etc/init.d/oracle start" |
|
|
stop program = "/etc/init.d/oracle stop" |
|
|
if failed port 9001 then restart</PRE> |
|
|
<P>In the next example, we have a standard three tier setup with |
|
|
apache, an application server and a back end database server. |
|
|
Dependencies are setup so should oracle be restarted then both |
|
|
apache and the weblogic application server are also restarted.</P> |
|
|
<PRE> |
|
|
check process apache with pidfile /var/run/httpd.pid |
|
|
start program = "/etc/init.d/httpd start" |
|
|
stop program = "/etc/init.d/httpd stop" |
|
|
depends on weblogic</PRE> |
|
|
<PRE> |
|
|
check process weblogic with pidfile /var/run/weblogic.pid |
|
|
start program = "/etc/init.d/weblogic start" |
|
|
stop program = "/etc/init.d/weblogic stop" |
|
|
depends on oracle</PRE> |
|
1953 |
<PRE> |
<PRE> |
1954 |
check process oracle with pidfile /var/run/oracle.pid |
check process oracle with pidfile /var/run/oracle.pid |
1955 |
start program = "/etc/init.d/oracle start" |
start = "/etc/init.d/oracle start" |
1956 |
stop program = "/etc/init.d/oracle stop" |
stop = "/etc/init.d/oracle stop" |
1957 |
if failed port 9001 then restart</PRE> |
if failed port 9001 then restart</PRE> |
1958 |
<P>Next, we have 2 services oracle-import and oracle-export that |
<P>Next, we have 2 services, oracle-import and oracle-export that |
1959 |
need to be restarted if oracle is restarted, but are independent |
need to be restarted if oracle is restarted, but are independent |
1960 |
of each other.</P> |
of each other.</P> |
1961 |
<PRE> |
<PRE> |
1962 |
check process oracle with pidfile /var/run/oracle.pid |
check process oracle with pidfile /var/run/oracle.pid |
1963 |
start program = "/etc/init.d/oracle start" |
start = "/etc/init.d/oracle start" |
1964 |
stop program = "/etc/init.d/oracle stop" |
stop = "/etc/init.d/oracle stop" |
1965 |
if failed port 9001 then restart</PRE> |
if failed port 9001 then restart</PRE> |
1966 |
<PRE> |
<PRE> |
1967 |
check process oracle-import with pidfile /var/run/oracle-import.pid |
check process oracle-import |
1968 |
start program = "/etc/init.d/oracle-import start" |
with pidfile /var/run/oracle-import.pid |
1969 |
stop program = "/etc/init.d/oracle-import stop" |
start = "/etc/init.d/oracle-import start" |
1970 |
depends on oracle</PRE> |
stop = "/etc/init.d/oracle-import stop" |
1971 |
<PRE> |
depends on oracle</PRE> |
1972 |
check process oracle-export with pidfile /var/run/oracle-export.pid |
<PRE> |
1973 |
start program = "/etc/init.d/oracle-export start" |
check process oracle-export |
1974 |
stop program = "/etc/init.d/oracle-export stop" |
with pidfile /var/run/oracle-export.pid |
1975 |
depends on oracle</PRE> |
start = "/etc/init.d/oracle-export start" |
1976 |
|
stop = "/etc/init.d/oracle-export stop" |
1977 |
|
depends on oracle</PRE> |
1978 |
<P>Finally an example with all statements:</P> |
<P>Finally an example with all statements:</P> |
1979 |
<PRE> |
<PRE> |
1980 |
check process apache with pidfile /var/run/httpd.pid |
check process apache with pidfile /var/run/httpd.pid |
1981 |
group server |
start program = "/etc/init.d/httpd start" |
1982 |
start program = "/etc/init.d/httpd start" |
stop program = "/etc/init.d/httpd stop" |
1983 |
stop program = "/etc/init.d/httpd stop" |
if 3 restarts within 5 cycles then timeout |
1984 |
if failed host www.sol.no port 80 type tcp protocol http |
if failed host www.sol.no port 80 protocol http |
1985 |
then restart |
and use the request "/login.cgi" |
1986 |
if failed host kvasir.sol.no port 80 type tcp protocol http |
then alert |
1987 |
and use the request "/login.cgi" |
if failed host shop.sol.no port 443 type tcpssl |
1988 |
then alert |
protocol http and with timeout 15 seconds |
1989 |
if failed host shop.sol.no port 443 type tcpssl proto http |
then restart |
1990 |
and with timeout 15 seconds |
if cpu is greater than 60% for 2 cycles then alert |
1991 |
then restart |
if cpu > 80% for 5 cycles then restart |
1992 |
if cpu is greater than 60% for 2 cycles then alert |
if totalmem > 100 MB then stop |
1993 |
if cpu > 80% for 5 cycles then restart |
if children > 200 then alert |
1994 |
if mem > 100 MB then stop |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
1995 |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
every 2 cycles |
1996 |
every 2 cycles |
mode active |
1997 |
mode active |
depends on weblogic |
1998 |
depends on weblogic |
depends on httpd.pid |
1999 |
depends on httpd.pid |
depends on httpd.conf |
2000 |
depends on httpd.conf |
depends on httpd_bin |
2001 |
depends on httpd_bin |
depends on datafs |
2002 |
depends on datafs |
group server</PRE> |
|
if 3 restarts within 5 cycles then timeout</PRE> |
|
2003 |
<PRE> |
<PRE> |
2004 |
check file httpd.pid with path /usr/local/apache/logs/httpd.pid |
check file httpd.pid with path /usr/local/apache/logs/httpd.pid |
2005 |
group server |
group server |
2006 |
if timestamp > 7 days then restart |
if timestamp > 7 days then restart |
2007 |
every 2 cycles |
every 2 cycles |
2008 |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
2009 |
depends on datafs</PRE> |
depends on datafs</PRE> |
2010 |
<PRE> |
<PRE> |
2011 |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
check file httpd.conf with path /usr/local/apache/conf/httpd.conf |
2012 |
group server |
group server |
2013 |
if timestamp was changed then restart |
if timestamp was changed then restart |
2014 |
every 2 cycles |
every 2 cycles |
2015 |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
2016 |
depends on datafs</PRE> |
depends on datafs</PRE> |
2017 |
<PRE> |
<PRE> |
2018 |
check file httpd_bin with path /usr/local/apache/bin/httpd |
check file httpd_bin with path /usr/local/apache/bin/httpd |
2019 |
group server |
group server |
2020 |
if failed checksum and expect the sum |
if failed checksum and expect the sum |
2021 |
8f7f419955cefa0b33a2ba316cba3659 the unmonitor |
8f7f419955cefa0b33a2ba316cba3659 then unmonitor |
2022 |
if failed permission 755 then unmonitor |
if failed permission 755 then unmonitor |
2023 |
if failed uid root then unmonitor |
if failed uid root then unmonitor |
2024 |
if failed gid root then unmonitor |
if failed gid root then unmonitor |
2025 |
if size changed then alert |
if size changed then alert |
2026 |
if timestamp changed then alert |
if timestamp changed then alert |
2027 |
every 2 cycles |
every 2 cycles |
2028 |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
alert bofh@bar with mail-format {from: monit@foo.bar.no} |
2029 |
alert foo@bar on { checksum, size, timestamp, uid, gid } |
alert foo@bar on { checksum, size, timestamp, uid, gid } |
2030 |
depends on datafs</PRE> |
depends on datafs</PRE> |
2031 |
<PRE> |
<PRE> |
2032 |
check device datafs with path /dev/sdb1 |
check device datafs with path /dev/sdb1 |
2033 |
group server |
group server |
2034 |
start program = "/bin/mount /data" |
start program = "/bin/mount /data" |
2035 |
stop program = "/bin/umount /data" |
stop program = "/bin/umount /data" |
2036 |
if failed permission 660 then unmonitor |
if failed permission 660 then unmonitor |
2037 |
if failed uid root then unmonitor |
if failed uid root then unmonitor |
2038 |
if failed gid disk then unmonitor |
if failed gid disk then unmonitor |
2039 |
if space usage > 80 % then alert |
if space usage > 80 % then alert |
2040 |
if space usage > 94 % then stop |
if space usage > 94 % then stop |
2041 |
if inode usage > 80 % then alert |
if inode usage > 80 % then alert |
2042 |
if inode usage > 94 % then stop |
if inode usage > 94 % then stop |
2043 |
alert root@localhost</PRE> |
alert root@localhost</PRE> |
2044 |
<P>Note; only the <STRONG>check</STRONG> and <STRONG>pidfile statement</STRONG> are mandatory, |
<PRE> |
2045 |
the other statements are optional and the order of the optional |
check host ftp.redhat.com |
2046 |
statements is not important.</P> |
if failed port 21 protocol ftp |
2047 |
|
then exec "/usr/X11R6/bin/xmessage -display |
2048 |
|
:0 ftp connection failed" |
2049 |
|
alert hauk@tildeslash.com</PRE> |
2050 |
|
<P>Note; only the <STRONG>check</STRONG> and <STRONG>pidfile or path statement</STRONG> are |
2051 |
|
mandatory, the other statements are optional and the order of the |
2052 |
|
optional statements is not important.</P> |
2053 |
<P> |
<P> |
2054 |
<H2><A NAME="monit with heartbeat">Monit with Heartbeat</A></H2> |
<H2><A NAME="monit with heartbeat">Monit with Heartbeat</A></H2> |
2055 |
<P>The first thing to do is to install and configure <EM>heartbeat</EM> |
<P>You can download <EM>heartbeat</EM> from |
2056 |
<A HREF="http://www.linux-ha.org/download/.">http://www.linux-ha.org/download/.</A> It can be useful to have a |
<A HREF="http://www.linux-ha.org/download/.">http://www.linux-ha.org/download/.</A> It might be useful to have a |
2057 |
look at The Heartbeat Getting Started Guide at: |
look at The Heartbeat Getting Started Guide at: |
2058 |
<A HREF="http://www.linux-ha.org/GettingStarted.html">http://www.linux-ha.org/GettingStarted.html</A></P> |
<A HREF="http://www.linux-ha.org/GettingStarted.html">http://www.linux-ha.org/GettingStarted.html</A></P> |
2059 |
<P><STRONG>Starting up a Node</STRONG></P> |
<P><STRONG>Starting up a Node</STRONG></P> |
2060 |
<P>This is the normal start sequence for a cluster-node. With this |
<P>This is the normal start sequence for a cluster-node. With this |
2061 |
sequence, there should be no error-case, which is not handled |
sequence, there should be no error-case, which is not handled |
2062 |
either by heartbeat or monit. For example, if monit dies, initd |
either by heartbeat or by monit. For example, if monit dies, |
2063 |
restarts it. If heatbeat dies, monit restarts it. If the node |
initd restarts it. If heatbeat dies, monit restarts it. If the |
2064 |
dies, the heartbeat instance on the other node detects it and |
node dies, the heartbeat instance on the other node detects it |
2065 |
restart the services there.</P> |
and restart the services there.</P> |
2066 |
<PRE> |
<OL> |
2067 |
1) initd starts monit with group local |
<LI><STRONG><A NAME="item_initd_starts_monit_with_group_local">initd starts monit with group local</A></STRONG><BR> |
2068 |
2) monit starts heartbeat in local group |
|
2069 |
3) heartbeat requests monit to start the node group |
<LI><STRONG><A NAME="item_monit_starts_heartbeat_in_local_group">monit starts heartbeat in local group</A></STRONG><BR> |
2070 |
4) monit starts the node group</PRE> |
|
2071 |
<P><STRONG>Monit <EM>/etc/monitrc</EM></STRONG></P> |
<LI><STRONG><A NAME="item_heartbeat_requests_monit_to_start_the_node_group">heartbeat requests monit to start the node group</A></STRONG><BR> |
2072 |
<P>This example describe a cluster with 2 nodes. Services running on |
|
2073 |
Node 1 are in the group <EM>node1</EM> and Node 2 services are in the |
<LI><STRONG><A NAME="item_monit_starts_the_node_group">monit starts the node group</A></STRONG><BR> |
2074 |
group <EM>node2</EM>.</P> |
|
2075 |
|
</OL> |
2076 |
|
<P><STRONG>Monit: <EM>/etc/monitrc</EM></STRONG></P> |
2077 |
|
<P>This example describes a cluster with 2 nodes. Services running |
2078 |
|
on Node 1 are in the group <EM>node1</EM> and Node 2 services are in |
2079 |
|
the <EM>node2</EM> group.</P> |
2080 |
<P>The local group entries are mode <EM>active</EM>, the node group |
<P>The local group entries are mode <EM>active</EM>, the node group |
2081 |
entries are mode <EM>manual</EM> and controlled by heartbeat.</P> |
entries are mode <EM>manual</EM> and controlled by heartbeat.</P> |
2082 |
<PRE> |
<PRE> |
2083 |
# |
# |
2084 |
# local services on every host |
# local services on both hosts |
2085 |
# |
#</PRE> |
2086 |
|
<PRE> |
2087 |
check process heartbeat with pidfile /var/run/heartbeat.pid |
check process heartbeat with pidfile /var/run/heartbeat.pid |
2088 |
start program = "/etc/init.d/heartbeat start" |
start program = "/etc/init.d/heartbeat start" |
2089 |
stop program = "/etc/init.d/heartbeat start" |
stop program = "/etc/init.d/heartbeat start" |
2135 |
alert foo@bar |
alert foo@bar |
2136 |
mode manual |
mode manual |
2137 |
group node2</PRE> |
group node2</PRE> |
2138 |
<P><STRONG>initd <EM>/etc/inittab</EM></STRONG></P> |
<P><STRONG>initd: <EM>/etc/inittab</EM></STRONG></P> |
2139 |
<P>Monit is started on both nodes with initd. You will need to add |
<P>Monit is started on both nodes with initd. You will need to add |
2140 |
an entry in <EM>/etc/inittab</EM> to start monit with the same local |
an entry in <EM>/etc/inittab</EM> to start monit with the same local |
2141 |
group heartbeat is member of.</P> |
group heartbeat is member of.</P> |
2142 |
<PRE> |
<PRE> |
2143 |
#/etc/inittab |
#/etc/inittab |
2144 |
mo:2345:respawn:/usr/local/bin/monit -i -d 10 -c /etc/monitrc -g local</PRE> |
mo:2345:respawn:/usr/local/bin/monit -i -d 10 -c /etc/monitrc -g local</PRE> |
2145 |
<P><STRONG>heartbeat <EM>/etc/ha.d/haresources</EM></STRONG></P> |
<P><STRONG>heartbeat: <EM>/etc/ha.d/haresources</EM></STRONG></P> |
2146 |
<P>When heartbeat starts, heartbeat look up the node entry and start |
<P>When heartbeat starts, heartbeat looks up the node entry and |
2147 |
the script <EM>/etc/init.d/monit-node1</EM> or |
start the script <EM>/etc/init.d/monit-node1</EM> or |
2148 |
<EM>/etc/init.d/monit-node2</EM>. The script calls monit to start the |
<EM>/etc/init.d/monit-node2</EM>. The script calls monit to start the |
2149 |
specific group per node.</P> |
specific group per node.</P> |
2150 |
<PRE> |
<PRE> |
2161 |
start() |
start() |
2162 |
{ |
{ |
2163 |
echo -n $"Starting $prog:" |
echo -n $"Starting $prog:" |
2164 |
$prog start |
$prog start all |
2165 |
echo |
echo |
2166 |
}</PRE> |
}</PRE> |
2167 |
<PRE> |
<PRE> |
2168 |
stop() |
stop() |
2169 |
{ |
{ |
2170 |
echo -n $"Stopping $prog:" |
echo -n $"Stopping $prog:" |
2171 |
$prog stop |
$prog stop all |
2172 |
echo |
echo |
2173 |
} |
} |
2174 |
</PRE> |
</PRE> |
2189 |
<H1><A NAME="files">FILES</A></H1> |
<H1><A NAME="files">FILES</A></H1> |
2190 |
<P><EM>~/.monitrc</EM> |
<P><EM>~/.monitrc</EM> |
2191 |
Default run control file</P> |
Default run control file</P> |
|
<P><EM>./monitrc</EM> |
|
|
If the control file is not found in the default |
|
|
location, and the current working directory |
|
|
contains a <EM>monitrc</EM> file, this file is used |
|
|
instead.</P> |
|
2192 |
<P><EM>/etc/monitrc</EM> |
<P><EM>/etc/monitrc</EM> |
2193 |
If the control file is not found in either of the |
If the control file is not found in the default location and |
2194 |
previous two locations, and /etc contains a |
/etc contains a <EM>monitrc</EM> file, this file will be used |
2195 |
<EM>monitrc</EM> file, this file will be used instead.</P> |
instead.</P> |
2196 |
|
<P><EM>./monitrc</EM> |
2197 |
|
If the control file is not found in either of the previous two |
2198 |
|
locations, and the current working directory contains a |
2199 |
|
<EM>monitrc</EM> file, this file is used instead.</P> |
2200 |
<P><EM>~/.monitrc.pid</EM> |
<P><EM>~/.monitrc.pid</EM> |
2201 |
Lock file to help prevent concurrent runs (non-root |
Lock file to help prevent concurrent runs (non-root |
2202 |
mode).</P> |
mode).</P> |
2215 |
the -s switch when monit is started.</P> |
the -s switch when monit is started.</P> |
2216 |
<P> |
<P> |
2217 |
<HR> |
<HR> |
2218 |
|
<H1><A NAME="environment">ENVIRONMENT</A></H1> |
2219 |
|
<P>No environment variables are used by monit. However, when monit |
2220 |
|
execute a script or a program monit will set several environment |
2221 |
|
variables which can be utilized by the executable. The following |
2222 |
|
and <EM>only</EM> the following environment variables are available:</P> |
2223 |
|
<DL> |
2224 |
|
<DT><STRONG><A NAME="item_MONIT_EVENT">MONIT_EVENT</A></STRONG><BR> |
2225 |
|
<DD> |
2226 |
|
The event that occured on the service |
2227 |
|
<P></P> |
2228 |
|
<DT><STRONG><A NAME="item_MONIT_SERVICE">MONIT_SERVICE</A></STRONG><BR> |
2229 |
|
<DD> |
2230 |
|
The name of the service (from monitrc) on which the event occured. |
2231 |
|
<P></P> |
2232 |
|
<DT><STRONG><A NAME="item_MONIT_DATE">MONIT_DATE</A></STRONG><BR> |
2233 |
|
<DD> |
2234 |
|
The time and date (rfc 822 style) the event occured |
2235 |
|
<P></P> |
2236 |
|
<DT><STRONG><A NAME="item_MONIT_HOST">MONIT_HOST</A></STRONG><BR> |
2237 |
|
<DD> |
2238 |
|
The host the event occured on |
2239 |
|
<P></P></DL> |
2240 |
|
<P>The following environment variables are only available for |
2241 |
|
process service entries:</P> |
2242 |
|
<DL> |
2243 |
|
<DT><STRONG><A NAME="item_MONIT_PROCESS_PID">MONIT_PROCESS_PID</A></STRONG><BR> |
2244 |
|
<DD> |
2245 |
|
The process pid. This may be 0 if the process was (re)started, |
2246 |
|
<P></P> |
2247 |
|
<DT><STRONG><A NAME="item_MONIT_PROCESS_MEMORY">MONIT_PROCESS_MEMORY</A></STRONG><BR> |
2248 |
|
<DD> |
2249 |
|
Process memory. This may be 0 if the process was (re)started, |
2250 |
|
<P></P> |
2251 |
|
<DT><STRONG><A NAME="item_MONIT_PROCESS_CHILDREN">MONIT_PROCESS_CHILDREN</A></STRONG><BR> |
2252 |
|
<DD> |
2253 |
|
Process children. This may be 0 if the process was (re)started, |
2254 |
|
<P></P> |
2255 |
|
<DT><STRONG><A NAME="item_MONIT_PROCESS_CPU_PERCENT">MONIT_PROCESS_CPU_PERCENT</A></STRONG><BR> |
2256 |
|
<DD> |
2257 |
|
Process cpu%. This may be 0 if the process was (re)started, |
2258 |
|
<P></P></DL> |
2259 |
|
<P>In addition the following spartan PATH environment variable is |
2260 |
|
available:</P> |
2261 |
|
<DL> |
2262 |
|
<DT><STRONG><A NAME="item_PATH%3D%2Fbin%3A%2Fusr%2Fbin%3A%2Fsbin%3A%2Fusr%2F">PATH=/bin:/usr/bin:/sbin:/usr/sbin</A></STRONG><BR> |
2263 |
|
<DD> |
2264 |
|
</DL> |
2265 |
|
<P>Scripts or programs that depends on other environment variables |
2266 |
|
or on a more verbose PATH must provide means to set these |
2267 |
|
variables by them self.</P> |
2268 |
|
<P> |
2269 |
|
<HR> |
2270 |
<H1><A NAME="signals">SIGNALS</A></H1> |
<H1><A NAME="signals">SIGNALS</A></H1> |
2271 |
<P>If a monit daemon is running, SIGUSR1 wakes it up from its sleep |
<P>If a monit daemon is running, SIGUSR1 wakes it up from its sleep |
2272 |
phase and forces a poll of all services. SIGTERM and SIGINT will |
phase and forces a poll of all services. SIGTERM and SIGINT will |
2282 |
<HR> |
<HR> |
2283 |
<H1><A NAME="notes">NOTES</A></H1> |
<H1><A NAME="notes">NOTES</A></H1> |
2284 |
<P>This is a very silent program. Use the -v switch if you want to |
<P>This is a very silent program. Use the -v switch if you want to |
2285 |
see what monit is doing, and tail -f the logfile.</P> |
see what monit is doing, and tail -f the logfile. Optionally for |
2286 |
|
testing purposes you can start monit with the -Iv switch. Monit |
2287 |
|
will then print debug information to the console, to stop monit |
2288 |
|
in this mode, simply press CTRL^C (i.e. SIGINT) in the same |
2289 |
|
console.</P> |
2290 |
<P>The syntax (and parser) of the control file is inspired by Eric |
<P>The syntax (and parser) of the control file is inspired by Eric |
2291 |
S. Raymond et al. excellent fetchmail program. Some portions of |
S. Raymond et al. excellent fetchmail program. Some portions of |
2292 |
this man page does also receive inspiration from the same |
this man page does also receive inspiration from the same |