~ubuntu-branches/ubuntu/vivid/monit/vivid-proposed

« back to all changes in this revision

Viewing changes to monit.1

  • Committer: Package Import Robot
  • Author(s): Sergey B Kirpichev
  • Date: 2014-12-28 17:32:53 UTC
  • mfrom: (1.1.25)
  • Revision ID: package-import@ubuntu.com-20141228173253-mxmq0pc92jzcyjv2
Tags: 1:5.11-1
* Imported Upstream version 5.11
* Refresh patches
* Comment for rsyslog plugin (Closes: #771322).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
 
1
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
2
2
.\"
3
3
.\" Standard preamble:
4
4
.\" ========================================================================
38
38
.    ds PI \(*p
39
39
.    ds L" ``
40
40
.    ds R" ''
41
 
.    ds C`
42
 
.    ds C'
43
41
'br\}
44
42
.\"
45
43
.\" Escape single quotes in literal strings from groff's Unicode transform.
50
48
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51
49
.\" entries marked with X<> in POD.  Of course, you'll have to process the
52
50
.\" output yourself in some meaningful fashion.
53
 
.\"
54
 
.\" Avoid warning from groff about undefined register 'F'.
55
 
.de IX
56
 
..
57
 
.nr rF 0
58
 
.if \n(.g .if rF .nr rF 1
59
 
.if (\n(rF:(\n(.g==0)) \{
60
 
.    if \nF \{
61
 
.        de IX
62
 
.        tm Index:\\$1\t\\n%\t"\\$2"
63
 
..
64
 
.        if !\nF==2 \{
65
 
.            nr % 0
66
 
.            nr F 2
67
 
.        \}
68
 
.    \}
69
 
.\}
70
 
.rr rF
 
51
.ie \nF \{\
 
52
.    de IX
 
53
.    tm Index:\\$1\t\\n%\t"\\$2"
 
54
..
 
55
.    nr % 0
 
56
.    rr F
 
57
.\}
 
58
.el \{\
 
59
.    de IX
 
60
..
 
61
.\}
71
62
.\"
72
63
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73
64
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
133
124
.\" ========================================================================
134
125
.\"
135
126
.IX Title "MONIT 1"
136
 
.TH MONIT 1 "www.mmonit.com" "October 29. 2014" "User Commands"
 
127
.TH MONIT 1 "www.mmonit.com" "December 22. 2014" "User Commands"
137
128
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138
129
.\" way too many mistakes in technical documents.
139
130
.if n .ad l
145
136
\&\fBmonit\fR [options] {arguments}
146
137
.SH "DESCRIPTION"
147
138
.IX Header "DESCRIPTION"
148
 
\&\fBmonit\fR is a utility for managing and monitoring processes,
149
 
programs, files, directories and filesystems on a Unix system.
150
 
Monit conducts automatic maintenance and repair and can execute
151
 
meaningful causal actions in error situations. E.g. Monit can
152
 
start a process if it does not run, restart a process if it does
153
 
not respond and stop a process if it uses too much resources. You
154
 
can use Monit to monitor files, directories and filesystems for
155
 
changes, such as timestamps changes, checksum changes or size
156
 
changes.
 
139
\&\fBMonit\fR is a utility for managing and monitoring processes, programs,
 
140
files, directories and filesystems on a Unix system. Monit conducts
 
141
automatic maintenance and repair and can execute meaningful causal
 
142
actions in error situations. E.g. Monit can start a process if it does
 
143
not run, restart a process if it does not respond and stop a process if
 
144
it uses too much resources. You can use Monit to monitor files,
 
145
directories and filesystems for changes, such as timestamps changes,
 
146
checksum changes or size changes.
157
147
.PP
158
 
Monit is controlled via an easy to configure control file based
159
 
on a free-format, token-oriented syntax. Monit logs to syslog or
160
 
to its own log file and notifies you about error conditions via
161
 
customizable alert messages. Monit can perform various \s-1TCP/IP\s0
162
 
network checks, protocol checks and can utilize \s-1SSL\s0 for such
163
 
checks. Monit provides a http(s) interface and you may use a
164
 
browser to access the Monit program.
 
148
Monit is controlled via an easy to configure control file based on a
 
149
free-format, token-oriented syntax. Monit logs to syslog or to its own
 
150
log file and notifies you about error conditions via customizable alert
 
151
messages. Monit can perform various \s-1TCP/IP\s0 network checks, protocol
 
152
checks and can utilize \s-1SSL\s0 for such checks. Monit provides a http(s)
 
153
interface and you may use a browser to access the Monit program.
165
154
.SH "WHAT TO MONITOR?"
166
155
.IX Header "WHAT TO MONITOR?"
167
 
You can use Monit to monitor daemon \fBprocesses\fR or similar
168
 
programs running on localhost. Monit is particularly useful for
169
 
monitoring daemon processes, such as those started at system boot
170
 
time from /etc/init.d/. For instance sendmail, sshd, apache and
171
 
mysql. In contrast to many other monitoring systems, Monit can act if
172
 
an error situation should occur, e.g.; if sendmail is not
173
 
running, monit can start sendmail again automatically or if
174
 
apache is using too many resources (e.g. if a DoS attack is in
175
 
progress) Monit can stop or restart apache and send you an alert
176
 
message. Monit can also monitor process characteristics, such as
 
156
You can use Monit to monitor daemon \fBprocesses\fR or similar programs
 
157
running on localhost. Monit is particularly useful for monitoring
 
158
daemon processes, such as those started at system boot time. For
 
159
instance sendmail, sshd, apache and mysql. In contrast to many other
 
160
monitoring systems, Monit can act if an error situation should occur,
 
161
e.g.; if sendmail is not running, monit can start sendmail again
 
162
automatically or if apache is using too many resources (e.g. if a DoS
 
163
attack is in progress) Monit can stop or restart apache and send you an
 
164
alert message. Monit can also monitor process characteristics, such as
177
165
how much memory or cpu cycles a process is using.
178
166
.PP
179
167
You can also use Monit to monitor \fBfiles\fR, \fBdirectories\fR and
180
 
\&\fBfilesystems\fR on localhost. Monit can monitor these items for
181
 
changes, such as timestamps changes, checksum changes or size
182
 
changes. This is also useful for security reasons \- you can
183
 
monitor the md5 or sha1 checksum of files that should not change
184
 
and get an alert or perform an action if they should change.
 
168
\&\fBfilesystems\fR on localhost. Monit can monitor these items for changes,
 
169
such as timestamps changes, checksum changes or size changes. This is
 
170
also useful for security reasons \- you can monitor the md5 or sha1
 
171
checksum of files that should not change and get an alert or perform an
 
172
action if they should change.
185
173
.PP
186
 
Monit can monitor \fBnetwork connections\fR to various servers,
187
 
either on localhost or on remote hosts. \s-1TCP, UDP\s0 and Unix Domain
188
 
Sockets are supported. Network test can be performed on a
189
 
protocol level; Monit has built-in tests for the main Internet
190
 
protocols, such as \s-1HTTP, SMTP\s0 etc. Even if a protocol is not
191
 
supported you can still test the server because you can configure
192
 
Monit to send any data and test the response from the server.
 
174
Monit can monitor \fBnetwork connections\fR to various servers, either on
 
175
localhost or on remote hosts. \s-1TCP\s0, \s-1UDP\s0 and Unix Domain Sockets are
 
176
supported. Network test can be performed on a protocol level; Monit has
 
177
built-in tests for the main Internet protocols, such as \s-1HTTP\s0, \s-1SMTP\s0 etc.
 
178
Even if a protocol is not supported you can still test the server
 
179
because you can configure Monit to send any data and test the response
 
180
from the server.
193
181
.PP
194
182
Monit can be used to test \fBprograms\fR or scripts at certain
195
183
times, much like cron, but in addition, you can test the exit
196
184
value of a program and perform an action or send an alert if the
197
 
exit value indicate an error. This means that you can use Monit
 
185
exit value indicates an error. This means that you can use Monit
198
186
to perform any type of check you can write a script for.
199
187
.PP
200
188
Finally, Monit can be used to monitor general \fBsystem\fR resources
201
 
on localhost such as overall \s-1CPU\s0 usage, Memory and Load Average.
 
189
on localhost such as overall \s-1CPU\s0 usage, Memory and System Load.
202
190
.SH "GENERAL OPERATION"
203
191
.IX Header "GENERAL OPERATION"
204
192
The behavior of Monit is controlled by command-line options
220
208
file for syntax errors:
221
209
.PP
222
210
.Vb 2
223
 
\& $ monit \-t 
 
211
\& $ monit \-t
224
212
\& $ Control file syntax OK
225
213
.Ve
226
214
.PP
228
216
console, including the line number in the control file from where
229
217
the error was found.
230
218
.PP
231
 
Once you have a working Monit control file you can start Monit
232
 
from the console, like so:
 
219
Once you have a working Monit control file, simply start Monit from the
 
220
console, like so:
233
221
.PP
234
222
.Vb 1
235
223
\& $ monit
239
227
switches, but for simplicity it is recommended that you put these
240
228
in the control file.
241
229
.PP
242
 
If all goes well, Monit will now detach from the terminal and run
243
 
as a background process, i.e. as a daemon process. As a daemon,
244
 
Monit runs in cycles; It monitor services, then goes to sleep for
245
 
a configured period, then wakes up and start monitoring again in
246
 
an endless loop.
 
230
Monit will detach from the terminal and run as a background process,
 
231
i.e. as a daemon process. As a daemon, Monit runs in cycles; It monitor
 
232
services, then goes to sleep for a configured period, then wakes up and
 
233
start monitoring again in an endless loop.
247
234
.SS "Options"
248
235
.IX Subsection "Options"
249
236
The following options are recognized by Monit. However, it is
280
267
   Print Monit's unique \s-1ID\s0
281
268
.PP
282
269
\&\fB\-r\fR
283
 
   Reset Monit's unique \s-1ID.\s0 Use with caution
 
270
   Reset Monit's unique \s-1ID\s0. Use with caution
284
271
.PP
285
272
\&\fB\-t\fR
286
273
   Run syntax check for the control file
292
279
   Very verbose mode, same as \-v plus log stack-trace on error
293
280
.PP
294
281
\&\fB\-H\fR \fI[filename]\fR
295
 
   Print \s-1MD5\s0 and \s-1SHA1\s0 hashes of the file or of stdin if the 
 
282
   Print \s-1MD5\s0 and \s-1SHA1\s0 hashes of the file or of stdin if the
296
283
   filename is omitted; Monit will exit afterwards
297
284
.PP
298
285
\&\fB\-V\fR
383
370
.SH "THE MONIT CONTROL FILE"
384
371
.IX Header "THE MONIT CONTROL FILE"
385
372
Monit is configured and controlled via a control file called
386
 
\&\fImonitrc\fR. The default location for this file is ~/.monitrc. If
387
 
this file does not exist, Monit will try /etc/monitrc, then
388
 
\&\f(CW@sysconfdir\fR@/monitrc and finally ./monitrc. The value of
389
 
\&\f(CW@sysconfdir\fR@ is given at configure time as ./configure
390
 
\&\-\-sysconfdir. For instance, using  \fI./configure \-\-sysconfdir
391
 
/var/monit/etc\fR will make Monit search for \fImonitrc\fR in
 
373
\&\fImonitrc\fR. The default location for this file is ~/.monitrc. If this
 
374
file does not exist, Monit will try /etc/monitrc, then
 
375
\&\f(CW@sysconfdir\fR@/monitrc and finally ./monitrc. If you build Monit from
 
376
source, the value of \f(CW@sysconfdir\fR@ can be given at configure time as
 
377
\&./configure \-\-sysconfdir. For instance, using \fI./configure
 
378
\&\-\-sysconfdir /var/monit/etc\fR will make Monit search for \fImonitrc\fR in
392
379
\&\fI/var/monit/etc\fR
393
380
.PP
394
 
To protect the security of your control file and passwords the
395
 
control file must have permissions \fIno more than 0700\fR
 
381
To protect the security of your control file and passwords the control
 
382
file must have read-write permissions \fIno more than 0700\fR
396
383
(u=xrw,g=,o=); Monit will complain and exit otherwise.
397
384
.PP
398
385
When there is a conflict between the command-line arguments and
399
 
the arguments in this file, the command-line arguments take
 
386
the arguments in this file, the command-line arguments takes
400
387
precedence.
401
388
.PP
402
389
Monit uses its own Domain Specific Language (\s-1DSL\s0); The control
403
390
file consists of a series of service entries and global option
404
 
statements in a free-format, token-oriented syntax.
405
 
.PP
406
 
Comments begin with a '#' and extend through the end of the line.
407
 
.PP
408
 
Otherwise the file consists of a series of service entries or
 
391
statements.
 
392
.PP
 
393
Comments begin with a \f(CW\*(Aq#\*(Aq\fR and extend through the end of the
 
394
line. Otherwise the file consists of a series of service entries or
409
395
global option statements in a free-format, token-oriented syntax.
410
396
.PP
411
 
You can use noise keywords like 'if', 'and', 'with(in)', 'has',
412
 
\&'us(ing|e)', 'on(ly)', 'then', 'for', 'of'  anywhere in an
413
 
entry to make it resemble English. They're ignored, but can make
414
 
entries much easier to read at a glance.  Keywords are case
 
397
You can use noise keywords like \f(CW\*(Aqif\*(Aq\fR, \f(CW\*(Aqand\*(Aq\fR, \f(CW\*(Aqwith(in)\*(Aq\fR,
 
398
\&\f(CW\*(Aqhas\*(Aq\fR, \f(CW\*(Aqus(ing|e)\*(Aq\fR, \f(CW\*(Aqon(ly)\*(Aq\fR, \f(CW\*(Aqthen\*(Aq\fR, \f(CW\*(Aqfor\*(Aq\fR, \f(CW\*(Aqof\*(Aq\fR
 
399
anywhere in an entry to make it resemble English. They're ignored, but
 
400
can make entries much easier to read at a glance. Keywords are case
415
401
insensitive.
416
402
.PP
417
403
There are three kinds of tokens: \fIgrammar\fR, \fInumbers\fR (i.e.
425
411
entries:
426
412
.IP "1. Global set-statements" 4
427
413
.IX Item "1. Global set-statements"
428
 
A global set-statement starts with the keyword \fIset\fR and the
 
414
A global set-statement starts with the keyword \f(CW\*(C`set\*(C'\fR and the
429
415
item to configure.
430
416
.IP "2. Global include-statement" 4
431
417
.IX Item "2. Global include-statement"
432
 
The include statement consists of the keyword \fIinclude\fR and
433
 
a glob string.
434
 
.IP "2. One or more service entry statements." 4
435
 
.IX Item "2. One or more service entry statements."
436
 
Each service entry consists of the keywords \fIcheck\fR, followed by
437
 
the service type. Each entry requires a \fBunique\fR descriptive
438
 
name, which may be freely chosen. This name is used by monit
439
 
to refer to the service internally and in all interactions
440
 
with the user.
 
418
The include statement consists of the keyword \f(CW\*(C`include\*(C'\fR and a glob
 
419
string. This statement is used to include configure directives from
 
420
separate files.
 
421
.IP "3. One or more service entry statements." 4
 
422
.IX Item "3. One or more service entry statements."
 
423
Each service entry consists of the keywords \f(CW\*(C`check\*(C'\fR, followed by the
 
424
service type. Each entry requires a \fBunique\fR descriptive name, which
 
425
may be freely chosen. This name is used by Monit to refer to the
 
426
service internally and in all interactions with the user.
441
427
.PP
442
 
Currently, eight types of check statements are supported:
443
 
.IP "1. \s-1CHECK PROCESS\s0 <unique name> <\s-1PIDFILE\s0 <path> | \s-1MATCHING\s0 <regex>>" 4
 
428
Currently, nine types of check statements are supported:
 
429
.IP "1. \s-1CHECK\s0 \s-1PROCESS\s0 <unique name> <\s-1PIDFILE\s0 <path> | \s-1MATCHING\s0 <regex>>" 4
444
430
.IX Item "1. CHECK PROCESS <unique name> <PIDFILE <path> | MATCHING <regex>>"
445
 
<path> is the absolute path to the program's pidfile. If the
446
 
pidfile does not exist or does not contain the pid number of a
447
 
running process, Monit will call the entry's start method if
448
 
defined.
449
 
<regex> is alternative process specification using pattern matching
450
 
to process name (command line) from process table instead of pidfile.
451
 
The first match is used so this form of check is useful for unique
452
 
pattern matching \- the pidfile should be used where possible as it
453
 
defines expected pid exactly (pattern matching won't be useful for
454
 
Apache in most cases or for processes which start child processes using
455
 
fork/clone as the child will match the same pattern temporarily).
456
 
The pattern can be obtained using \fImonit procmatch \*(L".*\*(R"\fR \s-1CLI\s0 command
457
 
which lists all processes visible to Monit or using the \fIps\fR utility.
458
 
The \*(L"procmatch\*(R" \s-1CLI\s0 command can be used to test your pattern as well.
459
 
If Monit runs in passive mode or the start methods is not defined,
460
 
Monit will just send alerts on errors.
461
 
.IP "2. \s-1CHECK FILE\s0 <unique name> \s-1PATH\s0 <path>" 4
 
431
<path> is the absolute path to the program's pid-file. A pid-file is a
 
432
file, containing a Process's unique \s-1ID\s0. If the pid-file does not exist
 
433
or does not contain the \s-1PID\s0 number of a running process, Monit will
 
434
call the entry's start method if defined.
 
435
.Sp
 
436
<regex> is an alternative to using \s-1PID\s0 files and uses process name
 
437
pattern matching to find the process to monitor. The first match is
 
438
used so this form of check is most useful if the process name is
 
439
unique. Pid-file should be used where possible as it defines expected
 
440
pid exactly (pattern matching won't be useful for processes which start
 
441
a child process using fork/clone as the child will match the same
 
442
pattern temporarily). You can test if a process match a pattern from
 
443
the command-line using \f(CW\*(C`monit procmatch "regex\-pattern"\*(C'\fR. This will
 
444
lists all processes matching or not, the regex-pattern.
 
445
.IP "2. \s-1CHECK\s0 \s-1FILE\s0 <unique name> \s-1PATH\s0 <path>" 4
462
446
.IX Item "2. CHECK FILE <unique name> PATH <path>"
463
 
<path> is the absolute path to the file. If the file does not
464
 
exist or disappeared, Monit will call the entry's start method if
465
 
defined, if <path> does not point to a regular file type (for
466
 
instance a directory), Monit will disable monitoring of this
467
 
entry. If Monit runs in passive mode or the start methods is not
468
 
defined, Monit will just send alerts on errors.
469
 
.IP "3. \s-1CHECK FIFO\s0 <unique name> \s-1PATH\s0 <path>" 4
 
447
<path> is the absolute path to the file. If the file does not exist,
 
448
Monit will call the entry's start method if defined, if <path> does not
 
449
point to a regular file type (for instance a directory), Monit will
 
450
disable monitoring of this entry. If Monit runs in passive mode or the
 
451
start methods is not defined, Monit will just send an alert on error.
 
452
.IP "3. \s-1CHECK\s0 \s-1FIFO\s0 <unique name> \s-1PATH\s0 <path>" 4
470
453
.IX Item "3. CHECK FIFO <unique name> PATH <path>"
471
 
<path> is the absolute path to the fifo. If the fifo does not
472
 
exist or disappeared, Monit will call the entry's start method if
473
 
defined, if <path> does not point to a fifo type (for
474
 
instance a directory), Monit will disable monitoring of this
475
 
entry. If Monit runs in passive mode or the start methods is not
476
 
defined, Monit will just send alerts on errors.
477
 
.IP "4. \s-1CHECK FILESYSTEM\s0 <unique name> \s-1PATH\s0 <path>" 4
 
454
<path> is the absolute path to the fifo. If the fifo does not exist,
 
455
Monit will call the entry's start method if defined, if <path> does not
 
456
point to a fifo type (for instance a directory), Monit will disable
 
457
monitoring of this entry. If Monit runs in passive mode or the start
 
458
methods is not defined, Monit will just send an alert on error.
 
459
.IP "4. \s-1CHECK\s0 \s-1FILESYSTEM\s0 <unique name> \s-1PATH\s0 <path>" 4
478
460
.IX Item "4. CHECK FILESYSTEM <unique name> PATH <path>"
479
 
<path> is the path to the filesystem block special device, mount point,
480
 
file or a directory which is part of a filesystem. It is
481
 
recommended to use a block special file directly (for example
482
 
/dev/hda1 on Linux or /dev/dsk/c0t0d0s1 on Solaris, etc.) If you
483
 
use a mount point (for example /data), be careful, because if the
484
 
filesystem is unmounted the test will still be true because the mount
485
 
point exist.
 
461
<path> is the path to the device/disk, mount point, file or a directory
 
462
which is part of a filesystem. It is recommended to use a block special
 
463
file directly (for example /dev/hda1 on Linux or /dev/dsk/c0t0d0s1 on
 
464
Solaris, etc.) If you use a mount point (for example /data), note if
 
465
the filesystem is unmounted the test will still be true because the
 
466
mount point exist.
486
467
.Sp
487
468
If the filesystem becomes unavailable, Monit will call the entry's
488
469
start method if defined. if <path> does not point to a filesystem,
489
 
Monit will disable monitoring of this entry. If Monit runs in
490
 
passive mode or the start methods is not defined, Monit will just
491
 
send alerts on errors.
492
 
.IP "5. \s-1CHECK DIRECTORY\s0 <unique name> \s-1PATH\s0 <path>" 4
 
470
Monit will disable monitoring of this entry. If Monit runs in passive
 
471
mode or the start methods is not defined, Monit will just send an alert
 
472
on error.
 
473
.IP "5. \s-1CHECK\s0 \s-1DIRECTORY\s0 <unique name> \s-1PATH\s0 <path>" 4
493
474
.IX Item "5. CHECK DIRECTORY <unique name> PATH <path>"
494
 
<path> is the absolute path to the directory. If the directory
495
 
does not exist or disappeared, Monit will call the entry's start
496
 
method if defined, if <path> does not point to a directory, monit
497
 
will disable monitoring of this entry. If Monit runs in passive
498
 
mode or the start methods is not defined, Monit will just send
499
 
alerts on errors.
500
 
.IP "6. \s-1CHECK HOST\s0 <unique name> \s-1ADDRESS\s0 <host address>" 4
 
475
<path> is the absolute path to the directory. If the directory does not
 
476
exist, Monit will call the entry's start method if defined. If <path>
 
477
does not point to a directory, monit will disable monitoring of this
 
478
entry. If Monit runs in passive mode or the start methods is not
 
479
defined, Monit will just send an alert on error.
 
480
.IP "6. \s-1CHECK\s0 \s-1HOST\s0 <unique name> \s-1ADDRESS\s0 <host address>" 4
501
481
.IX Item "6. CHECK HOST <unique name> ADDRESS <host address>"
502
482
The host address can be specified as a hostname string or as an
503
 
ip-address string on a dotted decimal format. Such as,
 
483
IP-address string on a dotted decimal format. Such as,
504
484
tildeslash.com or \*(L"64.87.72.95\*(R".
505
 
.IP "7. \s-1CHECK SYSTEM\s0 <unique name>" 4
 
485
.IP "7. \s-1CHECK\s0 \s-1SYSTEM\s0 <unique name>" 4
506
486
.IX Item "7. CHECK SYSTEM <unique name>"
507
 
The system name is usually hostname, but any descriptive name can be
508
 
used. You can use the variable \f(CW$HOST\fR as the name, which will expand to
509
 
the hostname. This test allows one to check general system resources
510
 
such as \s-1CPU\s0 usage (percent of time spent in user, system and wait),
511
 
total memory usage or load average. The unique name is used as the
512
 
system hostname in mail alerts and when M/Monit is configured, then
513
 
also as initial name of the host entry in M/Monit.
514
 
.IP "8. \s-1CHECK PROGRAM\s0 <unique name> \s-1PATH\s0 <executable file> [\s-1TIMEOUT\s0 <number> \s-1SECONDS\s0]" 4
 
487
The \fIunique name\fR is usually the local host name, but any descriptive
 
488
name can be used. If you use the variable \f(CW$HOST\fR as the name, it will
 
489
expand to the hostname. This check allows one to monitor general system
 
490
resources such as \s-1CPU\s0 usage, total memory usage or load average. The
 
491
\&\fIunique name\fR is used as the system hostname in mail alerts and as
 
492
the initial name of the host entry in M/Monit.
 
493
.IP "8. \s-1CHECK\s0 \s-1PROGRAM\s0 <unique name> \s-1PATH\s0 <executable file> [\s-1TIMEOUT\s0 <number> \s-1SECONDS\s0]" 4
515
494
.IX Item "8. CHECK PROGRAM <unique name> PATH <executable file> [TIMEOUT <number> SECONDS]"
516
 
<path> is the absolute path to the executable program or script.
517
 
The \fIstatus\fR test allows one to check the program's exit status. If
518
 
program will not finish within <number> seconds, Monit will terminate
519
 
it. The default program timeout is 600 seconds (5 minutes). The output
520
 
of the program is recorded (up to 1kB).
 
495
<path> is the absolute path to the executable program or script. The
 
496
status test allows one to check the
 
497
program's exit status. If the program does not finish executing within
 
498
<number> seconds, Monit will terminate it. The default program timeout
 
499
is 300 seconds (5 minutes). The output of the program is recorded and
 
500
made available in the User Interface and in alerts (up to 1kB).
 
501
.IP "9. \s-1CHECK\s0 \s-1NETWORK\s0 <unique name> <\s-1ADDRESS\s0 <ipaddress> | \s-1INTERFACE\s0 <name>>" 4
 
502
.IX Item "9. CHECK NETWORK <unique name> <ADDRESS <ipaddress> | INTERFACE <name>>"
 
503
<ipaddress> is the IPv4 or IPv6 address of the monitored network interface. It
 
504
is also possible to use interface name, such as \*(L"eth0\*(R" on Linux.
521
505
.SH "LOGGING"
522
506
.IX Header "LOGGING"
523
507
Monit will log status and error messages to a log file. Use the
524
508
\&\fIset logfile\fR statement in the monitrc control file. To setup
525
509
Monit to log to its own logfile, use e.g. \fIset logfile
526
510
/var/log/monit.log\fR. If \fBsyslog\fR is given as a value for the
527
 
\&\fI\-l\fR command-line switch (or the keyword \fIset logfile syslog\fR
 
511
\&\f(CW\*(C`\-l\*(C'\fR command-line switch (or the keyword \fIset logfile syslog\fR
528
512
is found in the control file) Monit will use the \fBsyslog\fR system
529
513
daemon to log messages with a priority assigned to each message
530
514
based on the context. To turn off logging, simply do not set the
546
530
given poll interval, wakes up and start monitoring again in an
547
531
endless cycle.
548
532
.PP
549
 
Alternatively, you can use the \fI\-d\fR command line switch to set
 
533
Alternatively, you can use the \f(CW\*(C`\-d\*(C'\fR command line switch to set
550
534
the poll interval, but it is strongly recommended to set the poll
551
535
interval in your \fI~/.monitrc\fR file, by using \fIset daemon\fR.
552
536
.PP
553
537
Monit will then always start in daemon mode. If you do not use
554
538
this statement and do not start monit with the \-d option, Monit
555
539
will just run through the service checks once and then exit. This
556
 
may be useful in some situations, but Monit is primarily designed
 
540
might be useful in some situations, but Monit is primarily designed
557
541
to run as a daemon process.
558
542
.PP
559
 
Calling monit with a Monit daemon running in the background sends
 
543
Calling \f(CW\*(C`monit\*(C'\fR with a Monit daemon running in the background sends
560
544
a wake-up signal to the daemon, forcing it to check services
561
 
immediately. Calling monit with the quit argument will kill a
 
545
immediately. Calling \f(CW\*(C`monit\*(C'\fR with the quit argument will kill a
562
546
running Monit daemon process instead of waking it up.
563
547
.SH "INIT SUPPORT"
564
548
.IX Header "INIT SUPPORT"
565
 
The \fIset init\fR statement prevents Monit from transforming itself
566
 
into a daemon process. Instead Monit will run as a foreground
567
 
process. (You should still use set daemon to specify the poll
568
 
cycle).
569
 
.PP
570
 
This is required to run Monit from init. Using init to start
571
 
Monit is probably the best way to run Monit if you want to be
572
 
certain that you always have a running Monit daemon on your
573
 
system. Another option is to run Monit from crontab. In any case,
574
 
you should make sure that the control file does not have any
575
 
syntax errors before you start Monit from init or crontab.
576
 
.PP
577
 
To setup Monit to run from init, you can either use the set init
578
 
statement in Monit's control file or use the \-I option from the
579
 
command line. Here is what you must add to /etc/inittab:
 
549
The \f(CW\*(C`set init\*(C'\fR statement prevents Monit from transforming itself into
 
550
a daemon process. Instead Monit will run as a foreground process. (You
 
551
should still use \f(CW\*(C`set daemon\*(C'\fR to specify the poll cycle).
 
552
.PP
 
553
This is required to run Monit from init. Using init to start Monit is
 
554
probably the best way to run Monit if you want to be certain that you
 
555
always have a running Monit daemon on your system. Another option is to
 
556
run Monit from crontab. In any case, you should make sure that the
 
557
control file does not have any syntax errors before you start Monit
 
558
from init or crontab (use \f(CW\*(C`monit \-t\*(C'\fR to check).
 
559
.PP
 
560
To setup Monit to run from init, you can either use the \f(CW\*(C`set init\*(C'\fR
 
561
statement in Monit's control file or use the \f(CW\*(C`\-I\*(C'\fR option from the
 
562
command line. Here is what you must add to \f(CW\*(C`/etc/inittab\*(C'\fR:
580
563
.PP
581
564
.Vb 2
582
565
\&  # Run Monit in standard run\-levels
596
579
\&  kill \-1 1
597
580
.Ve
598
581
.PP
599
 
If Monit is used to monitor services that are also started at
600
 
boot time (e.g. services started via \s-1SYSV\s0 init rc scripts or via
601
 
inittab) then, in some cases, a race condition could occur. That
602
 
is; if a service is slow to start, Monit can assume that the
603
 
service is not running and possibly try to start it and raise an
604
 
alert, while, in fact the service is already about to start or
605
 
already in its startup sequence. Please see the \s-1FAQ\s0 for a
606
 
solution to this problem.
 
582
If Monit is used to monitor services that are also started at boot time
 
583
(e.g. services started via \s-1SYSV\s0 init rc scripts or via inittab) then,
 
584
in some cases, a race condition could occur. That is; if a service is
 
585
slow to start, Monit can assume that the service is not running and
 
586
possibly try to start it and raise an alert, while, in fact the service
 
587
is already about to start or already in its startup sequence. Please
 
588
see the \s-1FAQ\s0 for a solution to this problem. The short version is to
 
589
start Monit on a higher run-level after system processes.
607
590
.SH "INCLUDE FILES"
608
591
.IX Header "INCLUDE FILES"
609
 
The Monit control file, \fImonitrc\fR, can include additional
610
 
configuration files. This feature helps one to maintain a certain
611
 
structure or to place repeating settings into one file. Include
612
 
statements can be placed at virtually any spot. The syntax is the
613
 
following:
 
592
The Monit control file, \f(CW\*(C`monitrc\*(C'\fR, can include additional
 
593
configuration files. This feature helps one to organize configuration
 
594
into separate files instead of having everything in one file, if you
 
595
like this kind of thing. Include statements can be placed at virtually
 
596
any place in \f(CW\*(C`monitrc\*(C'\fR though the convention is at the bottom. The
 
597
syntax is the following:
614
598
.PP
615
599
.Vb 1
616
600
\&  include globstring
617
601
.Ve
618
602
.PP
619
 
The globstring is any kind of string as defined in \fIglob\fR\|(7). Thus,
 
603
The globstring is any kind of string as defined in \f(CWglob(7)\fR. Thus,
620
604
you can refer to a single file or you can load several files at
621
605
once. If you want to use whitespace in your string the globstring
622
 
need to be embedded into quotes (') or double quotes ("). If the
 
606
needs to be embedded into quotes (') or double quotes ("). If the
623
607
globstring matches a directory instead of a file, it is silently
624
608
ignored.
625
609
.PP
626
 
Any \fIinclude\fR statements in included files are parsed as in the
 
610
Any \fIinclude\fR statements in an included file are parsed as in the
627
611
main control file.
628
612
.PP
629
 
If the globstring matches several results, the files are included
630
 
in a non sorted manner. If you need to rely on a certain order,
631
 
you might need to use single \fIinclude\fR statements.
 
613
If the globstring matches several results, the files are included in a
 
614
non sorted manner. If you need to rely on a certain order, you should
 
615
avoid wild-card globbing and instead specify the full path of files
 
616
included.
632
617
.PP
633
618
An example,
634
619
.PP
640
625
files in \fI/etc/monit.d\fR that ends with the prefix \fI.cfg\fR.
641
626
.SH "MONIT HTTPD"
642
627
.IX Header "MONIT HTTPD"
643
 
If specified in the control file, Monit will start a Monit daemon
644
 
with http support. From a Browser you can then start and stop
645
 
services, disable or enable service monitoring as well as view
646
 
the status of each service. Also, if Monit logs to its own file,
647
 
you can view the content of this logfile in a Browser.
648
 
.PP
649
 
The status page displayed by the Monit web server is automatically
650
 
refreshed with the same poll time set for the monit daemon.
651
 
.PP
652
 
The Monit web interface is required for \s-1CLI\s0 interface operation, as
653
 
all \s-1CLI\s0 commands (such as \*(L"monit status\*(R") are handled by the web
654
 
interface.
 
628
If specified in the control file, Monit will start with http support.
 
629
From a Browser you can then start and stop services, disable or enable
 
630
service monitoring as well as view the status of each service. Also, if
 
631
Monit logs to its own file, you can view the content of this logfile in
 
632
a Browser.
 
633
.PP
 
634
Note that \s-1HTTP\s0 support is required for almost all Monit \s-1CLI\s0 interface
 
635
operation, as \s-1CLI\s0 commands (such as \*(L"monit status\*(R") are handled by
 
636
communicating with the Monit background process via the the \s-1HTTP\s0
 
637
interface. So basically you should have this enable, though you can
 
638
bind the \s-1HTTP\s0 interface to localhost only so Monit is not accessible
 
639
from the outside.
655
640
.PP
656
641
Syntax:
657
 
.IP "\s-1SET HTTPD PORT\s0 <number> \s-1ALLOW\s0 <user:password | IP-address | IP\-range>+ [\s-1ADDRESS\s0 <hostname | IP\-address>] [\s-1SSL\s0 <\s-1ENABLE\s0 | \s-1DISABLE\s0>] [\s-1PEMFILE\s0 <path>] [\s-1CLIENTPEMFILE\s0 <path>] [\s-1ALLOWSELFCERTIFICATION\s0] [\s-1SIGNATURE\s0 <\s-1ENABLE\s0 | \s-1DISABLE\s0>]" 4
658
 
.IX Item "SET HTTPD PORT <number> ALLOW <user:password | IP-address | IP-range>+ [ADDRESS <hostname | IP-address>] [SSL <ENABLE | DISABLE>] [PEMFILE <path>] [CLIENTPEMFILE <path>] [ALLOWSELFCERTIFICATION] [SIGNATURE <ENABLE | DISABLE>]"
 
642
.PP
 
643
.Vb 7
 
644
\&  SET HTTPD PORT <number> [ADDRESS <hostname | IP\-address>]
 
645
\&      [SSL <ENABLE | DISABLE>]
 
646
\&      [PEMFILE <path>]
 
647
\&      [CLIENTPEMFILE <path>]
 
648
\&      [ALLOWSELFCERTIFICATION]
 
649
\&      [SIGNATURE <ENABLE | DISABLE>]
 
650
\&      ALLOW <user:password | IP\-address | IP\-range>+
 
651
.Ve
659
652
.PP
660
653
Example:
661
654
.PP
662
655
.Vb 2
663
656
\& set httpd port 2812
664
 
\&     allow myuser:mypassword
 
657
\&     allow username:password
665
658
.Ve
666
659
.PP
667
 
And you can use \fIhttp://localhost:2812/\fR to access the Monit web
668
 
interface from a browser.
669
 
.PP
670
 
\&\fI\s-1PORT\s0\fR option sets the port where Monit should listen. Monit uses
671
 
usually port 2812.
672
 
.PP
673
 
\&\fI\s-1ADDRESS\s0\fR option allows one to make Monit listen on specific interface
674
 
only. For example if you \fBdon't\fR want to expose Monit web interface
675
 
on external network, bind it to localhost only. Monit will accept
676
 
connections on any address by default (if \s-1ADDRESS\s0 option is missing).
 
660
You can now use <http://localhost:2812/> to
 
661
access Monit's web interface from a browser, after you have entered
 
662
username and password as credentials.
 
663
.PP
 
664
\&\fB\s-1PORT\s0\fR set the port Monit should bind to and listen on. Monit is
 
665
usually setup on port 2812.
 
666
.PP
 
667
\&\fB\s-1ADDRESS\s0\fR make Monit listen on a specific interface only. For example
 
668
if you \fIdon't\fR want to expose Monit's web interface to the network,
 
669
bind it to localhost only. Monit will accept connections on any address
 
670
by default (if \s-1ADDRESS\s0 option is missing).
677
671
.PP
678
672
For example to limit the web interface to localhost only:
679
673
.PP
681
675
\& set httpd
682
676
\&     port 2812
683
677
\&     use address 127.0.0.1
684
 
\&     allow myuser:mypassword
 
678
\&     allow username:password
685
679
.Ve
686
680
.PP
687
 
\&\fI\s-1SSL\s0\fR allows one to enable \s-1SSL\s0 for Monit web interface. Only \s-1TLS\s0 methods
688
 
are supported. The \fI\s-1PEMFILE\s0\fR option holds both the server's private key
689
 
and certificate. This file should be stored in a safe place on the
690
 
filesystem and should have strict permissions, no more than 0700.
691
 
Please see \s-1README.SSL\s0 file accompanying the software to get more
692
 
information about certificates and generating pem files.
 
681
\&\fB\s-1SSL\s0\fR enable \s-1TLS\s0 for Monit's web interface. The \fI\s-1PEMFILE\s0\fR option
 
682
holds both the server's private key and certificate. This file should
 
683
be stored in a safe place on the filesystem and should have strict
 
684
permissions, no more than 0700.
693
685
.PP
694
686
For example:
695
687
.PP
701
693
\&     allow myuser:mypassword
702
694
.Ve
703
695
.PP
704
 
You can use \fIhttps://localhost:2812/\fR to access the Monit web
705
 
server over a \s-1SSL\s0 encrypted connection.
 
696
You can now use <https://localhost:2812/> to
 
697
access the Monit web server over a \s-1TLS\s0 encrypted connection.
706
698
.PP
707
 
OpenSSL \s-1FIPS\s0 is supported, to enable \s-1FIPS\s0 mode (provided your OpenSSL
 
699
OpenSSL \s-1FIPS\s0 is supported. To enable \s-1FIPS\s0 mode (provided your OpenSSL
708
700
library supports it), add this statement to Monit control file:
709
701
.PP
710
702
.Vb 1
711
703
\& SET FIPS
712
704
.Ve
713
705
.PP
714
 
\&\fI\s-1CLIENTPEMFILE\s0\fR, \fI\s-1ALLOWSELFCERTIFICATION\s0\fR options allow to set
715
 
client certificate based authentication. A connecting client has
716
 
to provide a certificate known to Monit in order to connect. This
717
 
file also needs to have all necessary \s-1CA\s0 certificates. By default
718
 
self-signed client certificates are \fBnot\fR allowed. If you want to
719
 
use a self signed certificate from a client it has to be allowed
720
 
explicitly with the \fI\s-1ALLOWSELFCERTIFICATION\s0\fR statement.
 
706
\&\fB\s-1CLIENTPEMFILE\s0\fR client certificate based authentication. A connecting
 
707
client has to provide a certificate known to Monit in order to connect.
 
708
This file also needs to have all necessary \s-1CA\s0 certificates. By default
 
709
self-signed client certificates are \fBnot\fR allowed. If you want to use
 
710
a self signed certificate from a client it has to be allowed explicitly
 
711
with the \fB\s-1ALLOWSELFCERTIFICATION\s0\fR statement.
721
712
.PP
722
713
For example:
723
714
.PP
729
720
\&     clientpemfile /etc/certs/monit\-client.pem
730
721
.Ve
731
722
.PP
732
 
\&\fI\s-1SIGNATURE\s0\fR option can be used to hide Monit version from the
733
 
\&\s-1HTTP\s0 response header and error pages.  For example:
 
723
\&\fB\s-1SIGNATURE\s0\fR can be used to hide Monit version from the
 
724
\&\s-1HTTP\s0 response header and error pages. For example:
734
725
.PP
735
726
.Vb 4
736
727
\&  set httpd
740
731
.Ve
741
732
.SS "Authentication"
742
733
.IX Subsection "Authentication"
743
 
Monit web interface access is controlled primarily controlled via the
744
 
\&\fB\s-1ALLOW\s0\fR option.
 
734
Access to the Monit web interface is controlled primarily via the
 
735
\&\fB\s-1ALLOW\s0\fR option which is used to specify authentication and authorize
 
736
only specific clients to connect.
745
737
.PP
746
738
If the Monit command line interface is being used, at least one
747
739
cleartext password is necessary (see bellow), otherwise the Monit
748
740
command line interface will not be able to connect to the Monit
749
741
web interface.
750
742
.PP
751
 
Clients trying to connect to the server but supply the wrong
752
 
username and/or password are logged with their ip-address.
 
743
Clients trying to connect to Monit, but submit a wrong username and/or
 
744
password are logged with their IP-address.
753
745
.PP
754
746
\fIClient certificates\fR
755
747
.IX Subsection "Client certificates"
756
748
.PP
757
 
See the \fI\s-1CLIENTPEMFILE\s0\fR option above.
 
749
This authentication method is a strong authentication mechanism and
 
750
employ \s-1HTTPS\s0 client certificates to verify the authenticity of a
 
751
connecting client. Clients must posses a Public Key Certificate known
 
752
by Monit. The client must connect to Monit over \s-1SSL\s0 and Monit ask the
 
753
client to send its certificate. Upon receiving the certificate Monit
 
754
compares the certificate to certificates located in the
 
755
\&\fI\s-1CLIENTPEMFILE\s0\fR file. Access is granted if the client certificate is
 
756
in this file. See \fI\s-1CLIENTPEMFILE\s0\fR above for details.
758
757
.PP
759
758
\fIHost and network allow list\fR
760
759
.IX Subsection "Host and network allow list"
761
760
.PP
762
 
The http server maintains an access-control list of hosts and
763
 
networks allowed to connect to the server. You can add as many
764
 
hosts as you want to, but only hosts with a valid domain name or
765
 
its \s-1IP\s0 address are allowed. Networks require a network \s-1IP\s0 and a
766
 
netmask to be accepted.
 
761
Monit maintains an access-control list of hosts and networks allowed to
 
762
connect. You can add as many hosts as you want to, but only hosts with
 
763
a valid domain name or its \s-1IP\s0 address are allowed.
767
764
.PP
768
 
The http server will query a name server to check any hosts
769
 
connecting to the server. If a host (client) is trying to connect
770
 
to the server, but cannot be found in the access list or cannot
771
 
be resolved, the server will shutdown the connection to the
 
765
Monit will query a name server to check any hosts trying to connect. If
 
766
a host (client) is trying to connect, but cannot be found in the access
 
767
list or cannot be resolved, Monit will shutdown the connection to the
772
768
client promptly.
773
769
.PP
774
770
Control file example:
782
778
\&      allow 10.0.0.0/8
783
779
.Ve
784
780
.PP
785
 
Clients, not mentioned in the allow list, trying to connect to
786
 
the server are logged with their ip-address.
 
781
Clients, not mentioned in the allow list, trying to connect to Monit
 
782
will be denied access and are logged with their IP-address.
787
783
.PP
788
784
\fIBasic Authentication\fR
789
785
.IX Subsection "Basic Authentication"
790
786
.PP
791
 
Monit supports Basic Authentication schema described in \s-1RFC 2617.\s0
 
787
Monit supports Basic Authentication as described in \s-1RFC\s0 2617.
792
788
.PP
793
789
In short; a server challenge a client (e.g. a Browser) to send
794
 
authentication information (username and password) and if
795
 
accepted, the server will allow the client access to the
796
 
requested document.
 
790
authentication information (username and password) and if accepted, the
 
791
server will allow the client access to the requested document.
797
792
.PP
798
 
The biggest weakness with Basic Authentication is that the
799
 
username and password is sent in clear-text (i.e. base64 encoded)
800
 
over the network. It is therefor recommended that you do not use
801
 
this authentication method unless you run the Monit http server
802
 
with \fIssl\fR support. With ssl support it is completely safe to
803
 
use Basic Authentication since \fBall\fR http data, including Basic
 
793
The biggest weakness with Basic Authentication is that username and
 
794
password is sent in clear-text over the network (i.e. base64 encoded).
 
795
It is therefor recommended that you do not use this authentication
 
796
method unless you run Monit with \fIssl\fR support. With ssl, it is safe
 
797
to use Basic Authentication since \fIall\fR http data, including Basic
804
798
Authentication headers will be encrypted.
805
799
.PP
806
800
Cleartext user and password
807
801
.IX Subsection "Cleartext user and password"
808
802
.PP
809
 
Monit will use Basic Authentication if an allow statement
810
 
contains a username and a password separated with a single ':'
811
 
character.  Special characters can be used but the password has
812
 
to be quoted.
 
803
Monit will use Basic Authentication if an allow statement contains a
 
804
username and a password separated with a single ':' character. Special
 
805
characters can be used, but for non-alphanumerics the password has to
 
806
be quoted.
813
807
.PP
814
808
Syntax:
815
809
.PP
820
814
\s-1PAM\s0
821
815
.IX Subsection "PAM"
822
816
.PP
823
 
\&\s-1PAM\s0 is supported on platforms which provide \s-1PAM \s0(such as Linux,
824
 
Mac \s-1OS X,\s0 FreeBSD, NetBSD).
 
817
\&\s-1PAM\s0 is supported on platforms which provide \s-1PAM\s0 (such as Linux,
 
818
Mac \s-1OS\s0 X, FreeBSD, NetBSD).
825
819
.PP
826
820
Syntax:
827
821
.PP
829
823
\& ALLOW @<group>
830
824
.Ve
831
825
.PP
832
 
where \fIgroup\fR is the group name allowed to access Monit web
833
 
interface. Monit uses \s-1PAM\s0 service called \fImonit\fR for \s-1PAM\s0
834
 
authentication, see \s-1PAM\s0 manual page for detailed instructions
 
826
where \f(CW\*(C`group\*(C'\fR is the group name allowed to access Monit's web
 
827
interface. Monit uses a \s-1PAM\s0 service called \fImonit\fR for \s-1PAM\s0
 
828
authentication, see the \s-1PAM\s0 manual page for detailed instructions on
835
829
how to set the \s-1PAM\s0 service and \s-1PAM\s0 authentication plugins.
836
830
.PP
837
 
Sample \s-1PAM\s0 service for Monit on Mac \s-1OS X \s0(store as
 
831
Sample \s-1PAM\s0 service for Monit on Mac \s-1OS\s0 X (store as
838
832
\&\*(L"/etc/pam.d/monit\*(R" file):
839
833
.PP
840
834
.Vb 5
845
839
\&  account    required       pam_permit.so
846
840
.Ve
847
841
.PP
848
 
And monitrc setting which allows only group admin authenticated
849
 
via \s-1PAM\s0 to access the web interface:
 
842
And monitrc config which only allows group \f(CW\*(C`admin\*(C'\fR authenticated via
 
843
\&\s-1PAM\s0 to access the web interface:
850
844
.PP
851
845
.Vb 3
852
846
\&  set httpd
857
851
htpasswd file
858
852
.IX Subsection "htpasswd file"
859
853
.PP
860
 
Alternatively you can use files in \*(L"htpasswd\*(R" format (one
861
 
user:passwd entry per line), like so: \fIallow
862
 
[cleartext|crypt|md5] /path [users]\fR. By default cleartext
863
 
passwords are read. In case the passwords are digested it is
864
 
necessary to specify the cryptographic method. If you do not want
865
 
all users in the password file to have access to Monit you can
866
 
specify only those users that should have access, in the allow
867
 
statement. Otherwise all users are added.
 
854
Alternatively you can use files in \f(CW\*(C`htpasswd\*(C'\fR format (one
 
855
\&\fIuser:passwd\fR entry per line), like so: \fIallow [cleartext|crypt|md5]
 
856
/path [users]\fR. By default cleartext passwords are read. In case the
 
857
passwords are digested it is necessary to specify the cryptographic
 
858
method. If you do not want all users in the password file to have
 
859
access to Monit you can specify only those users that should have
 
860
access, in the allow statement. Otherwise all users are added.
868
861
.PP
869
862
Example1:
870
863
.PP
885
878
\&  set httpd port 2812
886
879
\&      allow localhost
887
880
\&      allow 10.1.1.1
888
 
\&      allow hauk:"password"
 
881
\&      allow hauk:"passw@rd"
889
882
.Ve
890
883
.PP
891
884
If you only want to use Basic Authentication, then just provide
914
907
access rights.
915
908
.SH "ALERT MESSAGES"
916
909
.IX Header "ALERT MESSAGES"
917
 
Monit will raise an event in the following situations:
 
910
Monit will raise an alert in the following situations:
918
911
.PP
919
912
.Vb 10
920
913
\& o A service does not exist (e.g. process is not running)
934
927
\& o A process\*(Aq PID changed out of Monit\*(Aqs control
935
928
\& o A process\*(Aq PPID changed out of Monit control
936
929
\& o Too many service recovery attempts failed
937
 
\& o A file content test found a match 
 
930
\& o A file content test found a match
938
931
\& o Filesystem flags changed
939
932
\& o A service action was performed by administrator
 
933
\& o A network link failed
 
934
\& o A network link capacity changed
 
935
\& o A network link saturation failed
 
936
\& o A network link upload/download rate failed
940
937
\& o Monit was started, stopped or reloaded
941
938
.Ve
942
939
.PP
943
 
To get an alert via e\-mail, set the alert target using global \fIset alert\fR
944
 
statement (for all services) or using \fIalert\fR statement in the context
945
 
of the service entry (for single service).
 
940
To get an alert via e\-mail, set the alert target using the global \f(CW\*(C`set
 
941
alert\*(C'\fR statement (for all services) or the \f(CW\*(C`alert\*(C'\fR statement in the
 
942
context of a service entry (for a single service).
946
943
.SS "Setting an alert recipient"
947
944
.IX Subsection "Setting an alert recipient"
948
 
If an event occurred, Monit will send an alert. There are two kinds of alert
949
 
statement: global and local.
 
945
If an event occurs, Monit will send an alert. There are two kinds of
 
946
alert statement: global and local.
950
947
.PP
951
948
Global syntax:
952
 
.IP "\s-1SET ALERT\s0 mail-address [[\s-1NOT\s0] {event, ...}] [\s-1REMINDER\s0 cycles]" 4
953
 
.IX Item "SET ALERT mail-address [[NOT] {event, ...}] [REMINDER cycles]"
 
949
.PP
 
950
.Vb 1
 
951
\& SET ALERT mail\-address [[NOT] {event, ...}] [REMINDER cycles]
 
952
.Ve
954
953
.PP
955
954
Example:
956
955
.PP
958
957
\& set alert foo@bar
959
958
.Ve
960
959
.PP
961
 
will send a default email to the address foo@bar whenever any event occurred on
962
 
any service.
 
960
will send a default email to the address foo@bar whenever any event
 
961
occurs on any service.
963
962
.PP
964
963
If you want to send alert messages to more email addresses, add a
965
 
\&\fIset alert 'email'\fR statement for each address.
966
 
.PP
967
 
It is also possible to use the local alert statement in the context of some service
968
 
to enable alert for the given service only:
969
 
.IP "\s-1ALERT\s0 mail-address [[\s-1NOT\s0] {event, ...}] [\s-1REMINDER\s0 cycles]" 4
970
 
.IX Item "ALERT mail-address [[NOT] {event, ...}] [REMINDER cycles]"
971
 
.PP
972
 
Example:
 
964
\&\f(CW\*(C`set alert \*(Aqemail\*(Aq\*(C'\fR statement for each address.
 
965
.PP
 
966
It is also possible to use the local alert statement in the context of
 
967
a service check to enable alert for the given service only:
 
968
.PP
 
969
.Vb 1
 
970
\& ALERT mail\-address [[NOT] {event, ...}] [REMINDER cycles]
 
971
.Ve
 
972
.PP
 
973
Local alert example:
973
974
.PP
974
975
.Vb 4
975
976
\& check host myhost with address 1.2.3.4
976
 
\&     if failed port 25 protocol http then alert
 
977
\&     if failed port 3306 protocol mysql then alert
977
978
\&     if failed port 80 protocol http then alert
978
 
\&     alert foo@bar
 
979
\&     alert foo@baz # Local service alert
979
980
.Ve
980
981
.PP
981
 
You can combine global and local alert statements. In the case of conflict, the local
982
 
alert has precedence and overrides the global statement.
 
982
You can combine global and local alert statements. If there is a
 
983
conflict, the local alert has precedence and overrides the global
 
984
statement.
983
985
.PP
984
986
\fISetting an event filter\fR
985
987
.IX Subsection "Setting an event filter"
986
988
.PP
987
 
If you only want an alert message sent for certain events, then list them in
988
 
the \fI{event, ...}\fR block, e.g.:
 
989
If you only want an alert message sent for certain events, list
 
990
them in an \f(CW\*(C`{event, ...}\*(C'\fR block, e.g.:
989
991
.PP
990
992
.Vb 1
991
993
\& set alert foo@bar only on { timeout, nonexist }
992
994
.Ve
993
995
.PP
994
 
You can also set exclude list (negate the list) to send alerts for all events
995
 
except those which are listed, by prepending the list with the word \fInot\fR.
996
 
For example to receive all alerts except notification about Monit program start
997
 
or stop:
 
996
The event list can also be negated to send alerts for all events
 
997
\&\fIexcept\fR those which are listed, by prepending the list with the word
 
998
\&\f(CW\*(C`not\*(C'\fR. For example, to receive all alerts except notification about
 
999
Monit program start and stop:
998
1000
.PP
999
1001
.Vb 1
1000
1002
\& set alert foo@bar but not on { instance }
1001
1003
.Ve
1002
1004
.PP
1003
 
List of all possible event types (value from the first column can be used in
1004
 
the event filter:
 
1005
Here is a list of all possible event types emitted by Monit. Values
 
1006
from the first column can be used in the event filter list mentioned
 
1007
above:
1005
1008
.PP
1006
1009
.Vb 10
1007
 
\& Event:     | Failure state:            | Success state:              
 
1010
\& Event:     | Failure state:              | Success state:
1008
1011
\& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
1009
 
\& ACTION     | "Action done"             | "Action done"               
1010
 
\& CHECKSUM   | "Checksum failed"         | "Checksum succeeded"        
1011
 
\& CONNECTION | "Connection failed"       | "Connection succeeded"      
1012
 
\& CONTENT    | "Content failed",         | "Content succeeded"
1013
 
\& DATA       | "Data access error"       | "Data access succeeded"     
1014
 
\& EXEC       | "Execution failed"        | "Execution succeeded"       
1015
 
\& FSFLAGS    | "Filesystem flags failed" | "Filesystem flags succeeded"
1016
 
\& GID        | "GID failed"              | "GID succeeded"             
1017
 
\& ICMP       | "Ping failed"             | "Ping succeeded"
1018
 
\& INSTANCE   | "Monit instance changed"  | "Monit instance changed not"
1019
 
\& INVALID    | "Invalid type"            | "Type succeeded"            
1020
 
\& NONEXIST   | "Does not exist"          | "Exists"                    
1021
 
\& PERMISSION | "Permission failed"       | "Permission succeeded"      
1022
 
\& PID        | "PID failed"              | "PID succeeded"
1023
 
\& PPID       | "PPID failed"             | "PPID succeeded"
1024
 
\& RESOURCE   | "Resource limit matched"  | "Resource limit succeeded"  
1025
 
\& SIZE       | "Size failed"             | "Size succeeded"            
1026
 
\& STATUS     | "Status failed"           | "Status succeeded"            
1027
 
\& TIMEOUT    | "Timeout"                 | "Timeout recovery"          
1028
 
\& TIMESTAMP  | "Timestamp failed"        | "Timestamp succeeded"       
1029
 
\& UID        | "UID failed"              | "UID succeeded"             
1030
 
\& UPTIME     | "Uptime failed"           | "Uptime succeeded"
 
1012
\& action     | "Action done"               | "Action done"
 
1013
\& checksum   | "Checksum failed"           | "Checksum succeeded"
 
1014
\& bytein     | "Download bytes exceeded"   | "Download bytes ok"
 
1015
\& byteout    | "Upload bytes exceeded"     | "Upload bytes ok"
 
1016
\& connection | "Connection failed"         | "Connection succeeded"
 
1017
\& content    | "Content failed",           | "Content succeeded"
 
1018
\& data       | "Data access error"         | "Data access succeeded"
 
1019
\& exec       | "Execution failed"          | "Execution succeeded"
 
1020
\& fsflags    | "Filesystem flags failed"   | "Filesystem flags succeeded"
 
1021
\& gid        | "GID failed"                | "GID succeeded"
 
1022
\& icmp       | "Ping failed"               | "Ping succeeded"
 
1023
\& instance   | "Monit instance changed"    | "Monit instance changed not"
 
1024
\& invalid    | "Invalid type"              | "Type succeeded"
 
1025
\& link       | "Link down"                 | "Link up"
 
1026
\& nonexist   | "Does not exist"            | "Exists"
 
1027
\& packetin   | "Download packets exceeded" | "Download packets ok"
 
1028
\& packetout  | "Upload packets exceeded"   | "Upload packets ok"
 
1029
\& permission | "Permission failed"         | "Permission succeeded"
 
1030
\& pid        | "PID failed"                | "PID succeeded"
 
1031
\& ppid       | "PPID failed"               | "PPID succeeded"
 
1032
\& resource   | "Resource limit matched"    | "Resource limit succeeded"
 
1033
\& saturation | "Saturation exceeded"       | "Saturation ok"
 
1034
\& size       | "Size failed"               | "Size succeeded"
 
1035
\& speed      | "Speed failed"              | "Speed ok"
 
1036
\& status     | "Status failed"             | "Status succeeded"
 
1037
\& timeout    | "Timeout"                   | "Timeout recovery"
 
1038
\& timestamp  | "Timestamp failed"          | "Timestamp succeeded"
 
1039
\& uid        | "UID failed"                | "UID succeeded"
 
1040
\& uptime     | "Uptime failed"             | "Uptime succeeded"
1031
1041
.Ve
1032
1042
.PP
1033
 
Each alert recipient can have its own filter, for example:
 
1043
Each alert recipient can have it's own filter, for example:
1034
1044
.PP
1035
1045
.Vb 3
1036
1046
\& set alert foo@bar { nonexist, timeout, resource, icmp, connection }
1041
1051
\fISetting an error reminder\fR
1042
1052
.IX Subsection "Setting an error reminder"
1043
1053
.PP
1044
 
Monit by default sends just \fBone\fR notification if a service failed
1045
 
and another notification when it recovered. If you want to be notified
1046
 
that the service is still failed, you can use the reminder option in
1047
 
the alert statement:
1048
 
.IP "\s-1SET ALERT\s0 mail-address [\s-1WITH\s0] \s-1REMINDER\s0 [\s-1ON\s0] number [\s-1CYCLES\s0]" 4
1049
 
.IX Item "SET ALERT mail-address [WITH] REMINDER [ON] number [CYCLES]"
1050
 
.PP
1051
 
For example if you want to be notified each tenth cycle if a
1052
 
service remains in a failed state, you can use:
1053
 
.PP
1054
 
.Vb 1
1055
 
\&  alert foo@bar with reminder on 10 cycles
 
1054
Monit by default sends just \fIone\fR notification if a service failed and
 
1055
another when/if it recover. If you want to be notified that the service
 
1056
is still in a failed state, you can use the reminder option in the
 
1057
alert statement:
 
1058
.PP
 
1059
.Vb 1
 
1060
\& SET ALERT mail\-address [WITH] REMINDER [ON] number [CYCLES]
 
1061
.Ve
 
1062
.PP
 
1063
For example if you want to be notified each tenth cycle if a service
 
1064
remains in a failed state, you can use:
 
1065
.PP
 
1066
.Vb 1
 
1067
\& alert foo@bar with reminder on 10 cycles
1056
1068
.Ve
1057
1069
.PP
1058
1070
Likewise if you want to be notified on each failed cycle, you can
1063
1075
.Ve
1064
1076
.SS "Disabling alerts for some service"
1065
1077
.IX Subsection "Disabling alerts for some service"
1066
 
To suppress alerts for some user and service, add the \s-1NOALERT\s0 statement in the
1067
 
context of the service which show not generate alerts:
1068
 
.IP "\s-1NOALERT\s0 mail-address" 4
1069
 
.IX Item "NOALERT mail-address"
 
1078
To suppress alerts for some user and service, add the \f(CW\*(C`noalert\*(C'\fR
 
1079
statement in the context of a service check.
 
1080
.PP
 
1081
.Vb 1
 
1082
\& NOALERT mail\-address
 
1083
.Ve
1070
1084
.PP
1071
1085
Example (send all alerts to foo@bar except for service p3):
1072
1086
.PP
1082
1096
.Ve
1083
1097
.SS "Message format"
1084
1098
.IX Subsection "Message format"
1085
 
Monit provides a default message format. You can set custom message
1086
 
format using \fIset mail-format\fR statement:
1087
 
.IP "\s-1SET\s0 MAIL-FORMAT {mail\-format}" 4
1088
 
.IX Item "SET MAIL-FORMAT {mail-format}"
 
1099
The alert message format can be modified by using the \f(CW\*(C`set
 
1100
mail\-format\*(C'\fR statement:
 
1101
.PP
 
1102
.Vb 1
 
1103
\& SET MAIL\-FORMAT {mail\-format}
 
1104
.Ve
1089
1105
.PP
1090
1106
Example:
1091
1107
.PP
1100
1116
\& }
1101
1117
.Ve
1102
1118
.PP
1103
 
The \fIfrom:\fR option is the sender email address.
 
1119
The \fIfrom:\fR option is the sender's email address. That is, the email
 
1120
address Monit will pretend it is sending alerts from. It does not have
 
1121
to be a real email-address only a proper formated address.
1104
1122
.PP
1105
1123
The \fIreply-to:\fR option can be used to set the reply-to mail header.
1106
1124
.PP
1107
 
The \fIsubject:\fR option allows one to set message subject and must be on
1108
 
only \fIone\fR line.
 
1125
The \fIsubject:\fR option sets the message subject and must be on only
 
1126
\&\fIone\fR line.
1109
1127
.PP
1110
1128
The \fImessage:\fR option sets the mail body. This option should always
1111
1129
be the last in a mail-format statement. The mail body can be as long
1112
 
as needed, but must \fBnot\fR contain the '}' character.
 
1130
as needed, but must \fInot\fR contain the block-closing '}' character.
1113
1131
.PP
1114
 
You can set only the option which you want to override. For example
1115
 
to change sender address only:
 
1132
You need not use all options, only the option which you want to
 
1133
override. For example to globally change the senders address only:
1116
1134
.PP
1117
1135
.Vb 1
1118
1136
\& set mail\-format { from: bofh@foo.bar }
1119
1137
.Ve
1120
1138
.PP
1121
 
The subject and body may contain \f(CW$XYZ\fR variables, which are expanded
1122
 
by Monit:
 
1139
The subject and body may contain \f(CW$NAME\fR variables, which are expanded by
 
1140
Monit. Here is a list of variables that can be used when composing an
 
1141
alert message.
1123
1142
.IP "\(bu" 4
1124
1143
\&\fI\f(CI$EVENT\fI\fR
1125
1144
.Sp
1126
 
.Vb 1
1127
 
\& A string describing the event that occurred.
1128
 
.Ve
 
1145
A string describing the event that occurred.
1129
1146
.IP "\(bu" 4
1130
1147
\&\fI\f(CI$SERVICE\fI\fR
1131
1148
.Sp
1132
 
.Vb 1
1133
 
\& The service name
1134
 
.Ve
 
1149
The service name
1135
1150
.IP "\(bu" 4
1136
1151
\&\fI\f(CI$DATE\fI\fR
1137
1152
.Sp
1138
 
.Vb 1
1139
 
\& The current time and date (RFC 822 date style).
1140
 
.Ve
 
1153
The current time and date (\s-1RFC\s0 822 date style).
1141
1154
.IP "\(bu" 4
1142
1155
\&\fI\f(CI$HOST\fI\fR
1143
1156
.Sp
1144
 
.Vb 1
1145
 
\& The name of the host Monit is running on
1146
 
.Ve
 
1157
The name of the host Monit is running on
1147
1158
.IP "\(bu" 4
1148
1159
\&\fI\f(CI$ACTION\fI\fR
1149
1160
.Sp
1150
 
.Vb 1
1151
 
\& The name of the action which was done by Monit.
1152
 
.Ve
 
1161
The name of the action which was done by Monit.
1153
1162
.IP "\(bu" 4
1154
1163
\&\fI\f(CI$DESCRIPTION\fI\fR
1155
1164
.Sp
1156
 
.Vb 1
1157
 
\& The description of the error condition
1158
 
.Ve
 
1165
The description of the error condition
1159
1166
.SS "Setting a mail server for alert delivery"
1160
1167
.IX Subsection "Setting a mail server for alert delivery"
1161
1168
The mail server Monit should use to send alert messages is
1162
 
defined with a \fIset mailserver\fR statement:
 
1169
defined with a \f(CW\*(C`set mailserver\*(C'\fR statement:
1163
1170
.PP
1164
 
.Vb 3
1165
 
\& SET MAILSERVER <hostname|ip\-address [PORT number] [USERNAME string] [PASSWORD string] [using SSLAUTO|SSLV2|SSLV3|TLSV1|TLSV11|TLSV12] [CERTMD5 checksum]>, ...
1166
 
\&                [with TIMEOUT X SECONDS]
1167
 
\&                [using HOSTNAME hostname]
 
1171
.Vb 5
 
1172
\& SET MAILSERVER <hostname|ip\-address [PORT number] [USERNAME string]
 
1173
\& [PASSWORD string] [using SSLAUTO|SSLV2|SSLV3|TLSV1|TLSV11|TLSV12]
 
1174
\& [CERTMD5 checksum]>, ...
 
1175
\&   [with TIMEOUT X SECONDS]
 
1176
\&   [using HOSTNAME hostname]
1168
1177
.Ve
1169
1178
.PP
1170
 
Multiple mailservers can be set using a comma separated list. If
 
1179
Multiple mailservers can be set by using a comma separated list. If
1171
1180
Monit cannot connect to the first server, it will try the next in
1172
 
the list.
 
1181
the list and so on.
1173
1182
.PP
1174
1183
The port statement allows one to override the default \s-1SMTP\s0 port
1175
 
(465 for \s-1SSL,\s0 or 25 for \s-1TLS\s0 and non secure connection).
 
1184
(465 for \s-1SSL\s0, or 25 for \s-1TLS\s0 and non secure connection).
1176
1185
.PP
1177
 
Monit supports \s-1AUTH PLAIN\s0 and \s-1AUTH LOGIN\s0 for \s-1SMTP\s0 authentication.
 
1186
Monit supports \s-1AUTH\s0 \s-1PLAIN\s0 and \s-1AUTH\s0 \s-1LOGIN\s0 for \s-1SMTP\s0 authentication.
1178
1187
You can set a username and a password using the \s-1USERNAME\s0 and
1179
1188
\&\s-1PASSWORD\s0 options.
1180
1189
.PP
1186
1195
Example (setting two mail servers for failover):
1187
1196
.PP
1188
1197
.Vb 1
1189
 
\& set mailserver mail1.foo.bar, mail2.foo.bar
 
1198
\& set mailserver smtp.gmail.com, smtp.other.host
1190
1199
.Ve
1191
1200
.PP
1192
 
By default, Monit uses the local host name in \s-1SMTP HELO/EHLO\s0
1193
 
and in the Message-ID header. You can override it using the
1194
 
\&\s-1HOSTNAME\s0 option.
 
1201
By default, Monit uses the local host name in \s-1SMTP\s0 \s-1HELO/EHLO\s0 and in the
 
1202
Message-ID header. You can override this using the \s-1HOSTNAME\s0 option.
1195
1203
.SS "Event queue"
1196
1204
.IX Subsection "Event queue"
1197
 
If no mail server is available, Monit \fIcan\fR queue events on the
1198
 
local file-system for retry until mail server recovery.
1199
 
.PP
1200
 
If Monit is configured with M/Monit, the event queue provides safe
1201
 
event store for M/Monit in the case of temporary problems as well.
1202
 
.PP
1203
 
The event queue is persistent across Monit restarts and provided
1204
 
that the back-end filesystem is persistent too, across system
1205
 
restart as well.
1206
 
.PP
1207
 
By default, the queue is disabled and if the alert handler fails,
1208
 
Monit will simply drop the alert message.
 
1205
If no mail server is available, Monit \fIcan\fR queue events in the
 
1206
local file-system for retry until the mail server recovers.
 
1207
.PP
 
1208
If Monit is used with M/Monit, the event queue provides a safe
 
1209
event store for M/Monit in the case of temporary problems.
 
1210
.PP
 
1211
The event queue is persistent across Monit restarts and provided that
 
1212
the back-end filesystem is persistent, across system restart as well.
 
1213
.PP
 
1214
By default, the queue is disabled and if the alert handler fails, Monit
 
1215
will simply drop the alert message.
1209
1216
.PP
1210
1217
To enable the event queue, add the following statement:
1211
1218
.PP
1229
1236
machine, you \fBmust\fR use separated event queue directories.
1230
1237
.SH "SERVICE METHODS"
1231
1238
.IX Header "SERVICE METHODS"
1232
 
Each service can have \fIstart\fR, \fIstop\fR and \fIrestart\fR methods
1233
 
which allow Monit to perform corresponding action with the service.
 
1239
Each service can have associated \fIstart\fR, \fIstop\fR and \fIrestart\fR
 
1240
methods which Monit can use to execute action on the service.
1234
1241
.PP
1235
1242
Syntax:
1236
 
.ie n .IP "<\s-1START\s0 | \s-1STOP\s0 | \s-1RESTART\s0> [\s-1PROGRAM\s0] = ""program"" [[\s-1AS\s0] \s-1UID\s0 <number | string>] [[\s-1AS\s0] \s-1GID\s0 <number | string>] [[\s-1WITH\s0] \s-1TIMEOUT\s0 <number> \s-1SECOND\s0(S)]" 4
1237
 
.el .IP "<\s-1START\s0 | \s-1STOP\s0 | \s-1RESTART\s0> [\s-1PROGRAM\s0] = ``program'' [[\s-1AS\s0] \s-1UID\s0 <number | string>] [[\s-1AS\s0] \s-1GID\s0 <number | string>] [[\s-1WITH\s0] \s-1TIMEOUT\s0 <number> \s-1SECOND\s0(S)]" 4
1238
 
.IX Item "<START | STOP | RESTART> [PROGRAM] = program [[AS] UID <number | string>] [[AS] GID <number | string>] [[WITH] TIMEOUT <number> SECOND(S)]"
1239
 
.PP
1240
 
If the \fIprogram\fR is shell script it must begin with \f(CW\*(C`#!\*(C'\fR and
 
1243
.PP
 
1244
.Vb 4
 
1245
\& <START | STOP | RESTART> [PROGRAM] = "program"
 
1246
\&        [[AS] UID <number | string>]
 
1247
\&        [[AS] GID <number | string>]
 
1248
\&        [[WITH] TIMEOUT <number> SECOND(S)]
 
1249
.Ve
 
1250
.PP
 
1251
If the \f(CW\*(C`program\*(C'\fR is a shell script it must begin with \f(CW\*(C`#!\*(C'\fR and
1241
1252
the remainder of the first line must specify an interpreter for
1242
1253
the program. e.g. \f(CW\*(C`#!/bin/sh\*(C'\fR
1243
1254
.PP
1244
 
The \fIprogram\fR must be executable (for example mode 0755).
 
1255
The \f(CW\*(C`program\*(C'\fR must also be executable (for example mode 0755).
1245
1256
.PP
1246
1257
It's possible to write scripts directly into the \fIprogram\fR this
1247
1258
way:
1248
1259
.PP
1249
1260
.Vb 1
1250
 
\& stop = "/bin/bash \-c \*(Aqkill \-s SIGTERM \`cat /var/run/myproc.pid\`\*(Aq"
 
1261
\& stop = "/bin/bash \-c \*(Aqkill \-s SIGTERM \`cat /var/run/process.pid\`\*(Aq"
1251
1262
.Ve
1252
1263
.PP
1253
1264
By default the program is executed as the user under which Monit
1258
1269
.PP
1259
1270
.Vb 3
1260
1271
\& check process mmonit with pidfile /usr/local/mmonit/mmonit/logs/mmonit.pid
1261
 
\&   start program = "/usr/local/mmonit/bin/mmonit \-d" as uid "mmonit" and gid "mmonit"
 
1272
\&   start program = "/usr/local/mmonit/bin/mmonit" as uid "mmonit" and gid "mmonit"
1262
1273
\&   stop program = "/usr/local/mmonit/bin/mmonit stop" as uid "mmonit" and gid "mmonit"
1263
1274
.Ve
1264
1275
.PP
1265
 
In the case of process check, Monit waits up to 30 seconds for the
1266
 
start/stop action to finish by checking the process table. You can
1267
 
override the action timeout using the \fI\s-1TIMEOUT\s0\fR option.
 
1276
In the case of a process check, Monit will wait up to 30 seconds for
 
1277
the start/stop action to finish before giving up and report an error.
 
1278
You can override this timeout using the \fI\s-1TIMEOUT\s0\fR option.
1268
1279
.PP
1269
1280
Example:
1270
1281
.PP
1275
1286
.Ve
1276
1287
.SH "SERVICE POLL TIME"
1277
1288
.IX Header "SERVICE POLL TIME"
1278
 
Services are checked in regular intervals given by the \fIset
1279
 
daemon n\fR statement. Checks are performed in the same order as
1280
 
they are written in the \fI.monitrc\fR file, except if dependencies
1281
 
are setup between services, in which case the services hierarchy
1282
 
may alternate the order of the checks.
 
1289
Services are checked in regular intervals by the \f(CW\*(C`set daemon n\*(C'\fR
 
1290
statement. Checks are performed in the same order as they are written
 
1291
in the \f(CW\*(C`.monitrc\*(C'\fR file, except if dependencies are setup between
 
1292
services.
1283
1293
.PP
1284
 
It is possible to modify the check schedule using the \fIevery\fR
 
1294
It is possible to modify a service check schedule by using the \f(CW\*(C`every\*(C'\fR
1285
1295
statement.
1286
1296
.PP
1287
1297
There are three variants:
1288
 
.IP "1. custom interval based on poll cycle length multiple" 4
1289
 
.IX Item "1. custom interval based on poll cycle length multiple"
1290
 
.Vb 1
1291
 
\&      EVERY [number] CYCLES
1292
 
.Ve
1293
 
.IP "2. test schedule based on cron-style string" 4
1294
 
.IX Item "2. test schedule based on cron-style string"
1295
 
.Vb 1
1296
 
\&      EVERY [cron]
1297
 
.Ve
1298
 
.IP "3. do-not-test schedule based on cron-style string" 4
1299
 
.IX Item "3. do-not-test schedule based on cron-style string"
1300
 
.Vb 1
1301
 
\&      NOT EVERY [cron]
 
1298
.IP "1. custom interval based on a poll cycle multiple" 4
 
1299
.IX Item "1. custom interval based on a poll cycle multiple"
 
1300
.Vb 1
 
1301
\& EVERY [number] CYCLES
 
1302
.Ve
 
1303
.IP "2. check is schedule based on a cron-style string" 4
 
1304
.IX Item "2. check is schedule based on a cron-style string"
 
1305
.Vb 1
 
1306
\& EVERY [cron]
 
1307
.Ve
 
1308
.IP "3. do-not-check schedule based on a cron-style string" 4
 
1309
.IX Item "3. do-not-check schedule based on a cron-style string"
 
1310
.Vb 1
 
1311
\& NOT EVERY [cron]
1302
1312
.Ve
1303
1313
.PP
1304
1314
A cron-style string, consist of 5 fields separated with
1305
1315
white-space. All fields are required:
1306
1316
.PP
1307
1317
.Vb 7
1308
 
\& Name:        | Allowed values:            | Special characters:              
 
1318
\& Name:        | Allowed values:            | Special characters:
1309
1319
\& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
1310
1320
\& Minutes      | 0\-59                       | * \- ,
1311
1321
\& Hours        | 0\-23                       | * \- ,
1325
1335
\&              | indicate every month.
1326
1336
\& \- (hyphen)   | Hyphens are used to define ranges. For example,
1327
1337
\&              | 8\-9 in the hour field indicate between 8AM and
1328
 
\&              | 9AM. Note that range is from time1 until and
1329
 
\&              | including time2. That is, from 8AM and until
 
1338
\&              | 9AM. Note that range is from start time until and
 
1339
\&              | including end time. That is, from 8AM and until
1330
1340
\&              | 10AM unless minutes are set. Another example,
1331
1341
\&              | 1\-5 in the weekday field, specify from monday to
1332
1342
\&              | friday (including friday).
1341
1351
.PP
1342
1352
.Vb 2
1343
1353
\& check process nginx with pidfile /var/run/nginx.pid
1344
 
\&   every 2 cycles
 
1354
\&       every 2 cycles
1345
1355
.Ve
1346
1356
.PP
1347
1357
Example 2: Check every workday 8AM\-7PM
1348
1358
.PP
1349
1359
.Vb 3
1350
 
\& check program checkOracleDatabase with
1351
 
\&       path /var/monit/programs/checkoracle.pl
1352
 
\&   every "* 8\-19 * * 1\-5"
 
1360
\& check program checkOracleDatabase
 
1361
\&        with path /var/monit/programs/checkoracle.pl
 
1362
\&       every "* 8\-19 * * 1\-5"
1353
1363
.Ve
1354
1364
.PP
1355
 
Example 3: Do not run the check in the backup window on 
 
1365
Example 3: Do not run the check in the backup window on
1356
1366
Sunday 0AM\-3AM
1357
1367
.PP
1358
1368
.Vb 2
1359
1369
\& check process mysqld with pidfile /var/run/mysqld.pid
1360
 
\&   not every "* 0\-3 * * 0"
 
1370
\&       not every "* 0\-3 * * 0"
1361
1371
.Ve
1362
1372
.PP
1363
1373
Limitations:
1364
1374
.PP
1365
 
The current test scheduler is poll cycle based. When Monit starts
1366
 
testing and the service test is constraint with the \fIevery cron\fR
1367
 
statement, it checks whether the current time match the
1368
 
cron-string pattern. If it does, the test is done, otherwise it
1369
 
is skipped. The cron specification thus does not guarantee when
1370
 
exactly the test will run \- that depends on the default poll time
1371
 
and the length of the testing cycle. In other words, we cannot
1372
 
guarantee that Monit will run on a specific time. Therefor we
 
1375
The current scheduler is poll cycle based. When a service check is
 
1376
constraint with the \fIevery cron\fR statement, Monit will check whether
 
1377
the current time match the cron-string pattern. If it does, the check
 
1378
is performed, otherwise it is skipped. The cron specification thus does
 
1379
not guarantee when exactly the test will run, this depends on the
 
1380
default poll time and the length of the check cycle. In other words, we
 
1381
cannot guarantee that Monit will run on a specific time. Therefor we
1373
1382
\&\fBstrongly\fR recommend to use an asterix in the minute field or at
1374
 
minimum a range, e..g. 0\-15. \fBNever\fR use a specific minute as
1375
 
Monit may not run on that minute.
 
1383
minimum a range, e..g. 0\-15. \fBNever\fR use a specific minute as Monit
 
1384
may not run on that minute.
1376
1385
.PP
1377
 
We will address this limitation in a future release and convert
1378
 
the test scheduler from serial polling into a parallel
1379
 
non-blocking scheduler where checks are guaranteed to run on time
1380
 
and with seconds resolution.
 
1386
We will address this limitation in a future release and convert the
 
1387
scheduler from serial polling into a parallel non-blocking scheduler
 
1388
where checks are guaranteed to run on time and with seconds resolution.
1381
1389
.SH "SERVICE GROUPS"
1382
1390
.IX Header "SERVICE GROUPS"
1383
1391
Service entries in the control file, \fImonitrc\fR, can be grouped
1412
1420
.Ve
1413
1421
.PP
1414
1422
Note:
1415
 
the \fIstatus\fR and \fIsummary\fR commands don't support the \-g
 
1423
the \fIstatus\fR and \fIsummary\fR commands does not support the \-g
1416
1424
option and will print the state of all services.
1417
1425
.PP
1418
 
Service can be added to multiple groups by adding group statement
1419
 
multiple times:
 
1426
A service can be added to multiple groups by using more than one group
 
1427
statement:
1420
1428
.PP
1421
1429
.Vb 2
1422
1430
\&  group www
1428
1436
\&\fIpassive\fR and \fImanual\fR. See also the example section below for
1429
1437
usage of the mode statement.
1430
1438
.PP
1431
 
In \fIactive\fR mode, Monit will pro-actively monitor a service and
1432
 
in case of problems Monit will raise alerts and/or restart the
1433
 
service. Active mode is the default mode.
1434
 
.PP
1435
 
In \fIpassive\fR mode, Monit will passively monitor a service and
1436
 
will raise alerts, but will \fBnot\fR try to fix a problem.
1437
 
.PP
1438
 
In \fImanual\fR mode, Monit will enter \fIactive\fR mode \fBonly\fR if a
 
1439
In \fIactive\fR mode (the default), Monit will pro-actively monitor a
 
1440
service and in case of problems raise alerts and/or restart
 
1441
the service.
 
1442
.PP
 
1443
In \fIpassive\fR mode, Monit will passively monitor a service and will
 
1444
raise alerts, but will \fBnot\fR try to fix a problem by executing
 
1445
\&\fIstart\fR, \fIstop\fR or \fIrestart\fR.
 
1446
.PP
 
1447
In \fImanual\fR mode, Monit will enter \fIactive\fR mode \fIonly\fR if a
1439
1448
service was started via Monit:
1440
1449
.PP
1441
1450
.Vb 1
1443
1452
.Ve
1444
1453
.PP
1445
1454
Use \*(L"monit stop <servicename>\*(R" to stop the service and take it out
1446
 
of Monit control. The manual mode can be used to build simple
 
1455
of Monit's control. The manual mode can be used to build a simple
1447
1456
cluster with active/passive HA-services.
1448
1457
.PP
1449
1458
A service's monitoring state is persistent across Monit restart.
1450
1459
.PP
1451
 
If you use Monit in a HA-cluster you should place the state file
 
1460
If you use Monit in a HA-cluster you should place the Monit state file
1452
1461
in a temporary filesystem so if the machine which runs HA-services
1453
1462
should crash and the stand-by machine take over its services, the
1454
1463
HA-services won't be started after the crashed node will boot again:
1471
1480
.PP
1472
1481
The syntax for the timeout statement is as follows (keywords are
1473
1482
in capital):
1474
 
.IP "\s-1IF\s0 <number> \s-1RESTART\s0 <number> \s-1CYCLE\s0(S) \s-1THEN\s0 <action>" 4
1475
 
.IX Item "IF <number> RESTART <number> CYCLE(S) THEN <action>"
1476
 
.PP
1477
 
Here is an example where Monit will unmonitor the service if it
1478
 
was restarted 2 times within 3 cycles:
 
1483
.PP
 
1484
.Vb 1
 
1485
\& IF <number> RESTART <number> CYCLE(S) THEN <action>
 
1486
.Ve
 
1487
.PP
 
1488
Here is an example where Monit will unmonitor the service if it was
 
1489
restarted 2 times within 3 cycles:
1479
1490
.PP
1480
1491
.Vb 1
1481
1492
\& if 2 restarts within 3 cycles then unmonitor
1482
1493
.Ve
1483
1494
.PP
1484
 
To have Monit check the service again after a monitoring was
1485
 
disabled, run 'monit monitor <servicename>' from the command
1486
 
line.
 
1495
To have Monit check the service again after monitoring was disabled,
 
1496
run \f(CW\*(C`monit monitor servicename\*(C'\fR from the command line.
1487
1497
.PP
1488
1498
Example for setting custom exec on timeout:
1489
1499
.PP
1504
1514
entries in the Monit control file.
1505
1515
.PP
1506
1516
The syntax for the depend statement is simply:
1507
 
.IP "\s-1DEPENDS\s0 on service[, service [,...]]" 4
1508
 
.IX Item "DEPENDS on service[, service [,...]]"
1509
 
.PP
1510
 
Where \fBservice\fR is a service entry name, for instance \fBapache\fR
1511
 
or \fBdatafs\fR.
 
1517
.PP
 
1518
.Vb 1
 
1519
\& DEPENDS on service[, service [,...]]
 
1520
.Ve
 
1521
.PP
 
1522
Where \fBservice\fR is a check service entry name used in your \f(CW\*(C`.monitrc\*(C'\fR
 
1523
file, for instance \fBapache\fR or \fBdatafs\fR.
1512
1524
.PP
1513
1525
You may add more than one service name of any type or use more
1514
1526
than one depend statement in an entry.
1530
1542
possibly cracked apache binary.
1531
1543
.PP
1532
1544
.Vb 7
1533
 
\& (1) check process apache 
 
1545
\& (1) check process apache
1534
1546
\& (2)    with pidfile "/usr/local/apache/logs/httpd.pid"
1535
1547
\& (3)    ...
1536
1548
\& (4)    depends on httpd
1539
1551
\& (7)    if failed checksum then unmonitor
1540
1552
.Ve
1541
1553
.PP
1542
 
The first entry is the process entry for apache shown before
1543
 
(abbreviated for clarity). The fourth line sets up a dependency
1544
 
between this entry and the service entry named httpd in line 6. A
1545
 
depend tree works as follows, if an action is conducted in a
1546
 
lower branch it will propagate upward in the tree and for every
1547
 
dependent entry execute the same action. In this case, if the
1548
 
checksum should fail in line 7 then an unmonitor action is
1549
 
executed and the apache binary is not checked anymore. But since
1550
 
the apache process entry depends on the httpd entry this entry
1551
 
will also execute the unmonitor action. In short, if the checksum
1552
 
test for the httpd binary file should fail, both the check file
1553
 
httpd entry and the check process apache entry is set in
 
1554
The first entry is the process entry for apache (abbreviated for
 
1555
clarity). The fourth line sets up a dependency between this entry and
 
1556
the service entry named httpd in line 6. A dependency tree works as
 
1557
follows, if an action is conducted in a lower branch it will propagate
 
1558
upward in the tree and for every dependent entry execute the same
 
1559
action. In this case, if the checksum should fail in line 7 then an
 
1560
unmonitor action is executed and the apache binary is not checked
 
1561
anymore. But since the apache process entry depends on the httpd entry
 
1562
this entry will also execute the unmonitor action. In short, if the
 
1563
checksum test for the httpd binary file should fail, both the check
 
1564
file httpd entry and the check process apache entry is set in
1554
1565
un-monitoring mode.
1555
1566
.PP
1556
 
A dependency tree is a general construct and can be used between
1557
 
all types of service entries and span many levels and propagate
1558
 
any supported action (except the exec action which will not
1559
 
propagate upward in a dependency tree for obvious reasons).
 
1567
A dependency tree is a general construct and can be used between all
 
1568
types of service entries and span many levels and propagate any
 
1569
supported action (except the exec action which will not propagate
 
1570
upward in a dependency tree for obvious reasons).
1560
1571
.PP
1561
1572
Here is another different example. Consider the following common
1562
1573
server setup:
1610
1621
control file.
1611
1622
.SH "SERVICE TESTS"
1612
1623
.IX Header "SERVICE TESTS"
1613
 
.SS "\s-1GENERIC SYNTAX\s0"
1614
 
.IX Subsection "GENERIC SYNTAX"
1615
 
Monit provides several tests you can use in a 'check' statement
1616
 
to test a service.
1617
 
.PP
1618
 
You can test either for some expected value or range or take
1619
 
action if the value changed.
1620
 
.PP
1621
 
General syntax for testing specific value or range:
1622
 
.IP "\s-1IF\s0 <\s-1TEST\s0> \s-1THEN ACTION\s0 [\s-1ELSE IF SUCCEEDED THEN ACTION\s0]" 4
1623
 
.IX Item "IF <TEST> THEN ACTION [ELSE IF SUCCEEDED THEN ACTION]"
1624
 
.PP
1625
 
The selected failure action is evaluated each time the <\s-1TEST\s0> condition
1626
 
is true. Success action is optional and executed only when the state
1627
 
changes from failure to success. If success action is not set, Monit
1628
 
will send recovery alert by default.
1629
 
.PP
1630
 
General syntax for value change test:
1631
 
.IP "\s-1IF CHANGED\s0 <\s-1TEST\s0> \s-1THEN ACTION\s0" 4
1632
 
.IX Item "IF CHANGED <TEST> THEN ACTION"
1633
 
.PP
1634
 
The selected action is executed each time the value changed. Monit
1635
 
will remember the new value and will trigger event if the value changed
1636
 
again.
 
1624
\fI\s-1GENERAL\s0 \s-1SYNTAX\s0\fR
 
1625
.IX Subsection "GENERAL SYNTAX"
 
1626
.PP
 
1627
Monit provides several tests you can use in a 'check' statement to test
 
1628
a service.
 
1629
.PP
 
1630
You can test either for some expected value or range and take
 
1631
actions if the value changed.
 
1632
.PP
 
1633
General syntax for testing a specific value or range:
 
1634
.PP
 
1635
.Vb 1
 
1636
\& IF <TEST> THEN ACTION [ELSE IF SUCCEEDED THEN ACTION]
 
1637
.Ve
 
1638
.PP
 
1639
The action is evaluated each time the <\s-1TEST\s0> condition is true. Success
 
1640
action is optional and executed only when the state changes from
 
1641
failure to success. If success action is not set, Monit will send a
 
1642
recovery alert by default.
 
1643
.PP
 
1644
General syntax for a value change test:
 
1645
.PP
 
1646
.Vb 1
 
1647
\& IF CHANGED <TEST> THEN ACTION
 
1648
.Ve
 
1649
.PP
 
1650
The action is executed each time the value changes. Monit will remember
 
1651
the new value and will trigger event if the value change again.
1637
1652
.PP
1638
1653
\fI\s-1ACTION\s0\fR
1639
1654
.IX Subsection "ACTION"
1643
1658
.IP "\(bu" 4
1644
1659
\&\fB\s-1ALERT\s0\fR sends the user an alert event on each state change.
1645
1660
.IP "\(bu" 4
1646
 
\&\fB\s-1RESTART\s0\fR restarts the service \fBand\fR sends an alert. Restart
1647
 
is conducted by calling service's registered restart method or
1648
 
by first calling the stop method followed by start method if restart
 
1661
\&\fB\s-1RESTART\s0\fR restarts the service \fBand\fR send an alert. Restart is
 
1662
performed by calling the service's registered restart method or by
 
1663
first calling the stop method followed by the start method if restart
1649
1664
is not set.
1650
1665
.IP "\(bu" 4
1651
1666
\&\fB\s-1START\s0\fR starts the service by calling the service's registered
1652
 
start method \fBand\fR sends an alert.
 
1667
start method \fBand\fR send an alert.
1653
1668
.IP "\(bu" 4
1654
1669
\&\fB\s-1STOP\s0\fR stops the service by calling the service's registered
1655
 
stop method \fBand\fR sends an alert. If Monit stops a service it
 
1670
stop method \fBand\fR send an alert. If Monit stops a service it
1656
1671
will not be checked by Monit anymore nor restarted again later.
1657
1672
To reactivate monitoring of the service again you must explicitly
1658
1673
enable monitoring from the web interface or from the console.
1669
1684
\&      as uid nobody and gid nobody
1670
1685
.Ve
1671
1686
.Sp
1672
 
Remember, if Monit is run by the superuser, then all programs
1673
 
executed by Monit will be started with superuser privileges
1674
 
unless the uid and gid extension was used.
 
1687
Remember, if Monit is run by root, then all programs executed by Monit
 
1688
will be started with superuser privileges unless the uid and gid
 
1689
extension is used.
1675
1690
.IP "\(bu" 4
1676
1691
\&\fB\s-1UNMONITOR\s0\fR will disable monitoring of the service \fBand\fR send
1677
1692
an alert. The service will not be checked by Monit anymore nor
1679
1694
you must explicitly enable monitoring from the web interface or
1680
1695
from the console.
1681
1696
.PP
1682
 
\fI\s-1FAILURE TOLERANCE\s0\fR
 
1697
\fI\s-1FAILURE\s0 \s-1TOLERANCE\s0\fR
1683
1698
.IX Subsection "FAILURE TOLERANCE"
1684
1699
.PP
1685
 
By default the action is executed on first match. You can ignore soft errors
1686
 
and require multiple errors before the event is triggered and the service state
1687
 
changed to failure.
 
1700
By default the action is executed if it matches and the service set in
 
1701
an error state. However, you can require a test to fail more than once
 
1702
before the error event is triggered and the service state changed to
 
1703
failed. This is useful to avoid getting alerts on spurious errors,
 
1704
which can happen, especially with network tests.
1688
1705
.PP
1689
1706
Syntax:
1690
 
.IP "... [\s-1FOR\s0] <X> \s-1CYCLES ...\s0" 4
1691
 
.IX Item "... [FOR] <X> CYCLES ..."
 
1707
.PP
 
1708
.Vb 1
 
1709
\& FOR <X> CYCLES ...
 
1710
.Ve
1692
1711
.PP
1693
1712
or:
1694
 
.IP "... <X> [\s-1TIMES WITHIN\s0] <Y> \s-1CYCLES ...\s0" 4
1695
 
.IX Item "... <X> [TIMES WITHIN] <Y> CYCLES ..."
1696
 
.PP
1697
 
The condition can be used both for the failure and success action.
1698
 
.PP
1699
 
The first simpler format requires <X> consecutive events before switching the
1700
 
state:
 
1713
.PP
 
1714
.Vb 1
 
1715
\& <X> [TIMES WITHIN] <Y> CYCLES ...
 
1716
.Ve
 
1717
.PP
 
1718
The condition can be used both for failure and success action.
 
1719
.PP
 
1720
The first, simpler and recommended format requires \f(CW\*(C`X\*(C'\fR consecutive
 
1721
events before switching the state:
1701
1722
.PP
1702
1723
.Vb 4
1703
 
\& if failed 
1704
 
\&    port 80 
1705
 
\&    for 10 cycles 
 
1724
\& if failed
 
1725
\&    port 80
 
1726
\&    for 3 cycles
1706
1727
\& then alert
1707
1728
.Ve
1708
1729
.PP
1709
 
The second format is more advanced and allows one to tolerate intermitent issues, but
1710
 
still catch excessive problems, where the service is flapping between error and
1711
 
success states frequently.
 
1730
The second format is more advanced and allows one to tolerate intermitent
 
1731
issues, but still catch excessive problems, where the service is
 
1732
flapping between error and success states frequently.
1712
1733
.PP
1713
 
For example if every second cycle is failure (1\-0\-1\-0\-1\-0\-...), then \*(L"for 2 cycles\*(R"
1714
 
condition will never match, despite the service has serious problems. The following
1715
 
statement will catch such state:
 
1734
For example if every second cycle fails (1\-0\-1\-0\-1\-0\-...), then \*(L"for 2
 
1735
cycles\*(R" condition will never match, despite the service having
 
1736
problems. The following statement will catch such a state:
1716
1737
.PP
1717
1738
.Vb 4
1718
 
\& if failed 
 
1739
\& if failed
1719
1740
\&    port 80
1720
 
\&    for 3 times within 5 cycles 
 
1741
\&    for 3 times within 5 cycles
1721
1742
\& then alert
1722
1743
.Ve
1723
1744
.PP
1729
1750
\&  if space usage > 90% for 5 cycles then exec \*(Aq/try/to/free/the/space\*(Aq
1730
1751
.Ve
1731
1752
.PP
1732
 
Note: the maximum number of cycles option value is 64.
1733
 
.SS "\s-1EXISTENCE TESTING\s0"
 
1753
Note: the maximum value for cycles is 64.
 
1754
.SS "\s-1EXISTENCE\s0 \s-1TESTING\s0"
1734
1755
.IX Subsection "EXISTENCE TESTING"
1735
 
Monit's default action when services does not exist (for example
1736
 
a process is not running, a file doesn't exist, etc.) is to perform
1737
 
restart action.
1738
 
.PP
1739
 
You can override the default action with following statement:
1740
 
.IP "\s-1IF\s0 [\s-1DOES\s0] \s-1NOT EXIST THEN\s0 action" 4
1741
 
.IX Item "IF [DOES] NOT EXIST THEN action"
1742
 
.PP
1743
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1744
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
1756
Monit's default action when a service does not exist (for example a
 
1757
process is not running, a file does not exist, etc.) is to perform
 
1758
the restart action.
 
1759
.PP
 
1760
You can override the default action with the following statement:
 
1761
.PP
 
1762
.Vb 1
 
1763
\& IF [DOES] NOT EXIST THEN action
 
1764
.Ve
 
1765
.PP
 
1766
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R", \*(L"\s-1EXEC\s0\*(R" or
 
1767
\&\*(L"\s-1UNMONITOR\s0\*(R".
1745
1768
.PP
1746
1769
Example:
1747
1770
.PP
1748
1771
.Vb 2
1749
1772
\& check file with path /cifs/mydata
1750
 
\&   if does not exist then exec "/usr/bin/mount_cifs.sh"
 
1773
\&       if does not exist then exec "/usr/bin/mount_cifs.sh"
1751
1774
.Ve
1752
 
.SS "\s-1RESOURCE TESTING\s0"
 
1775
.SS "\s-1RESOURCE\s0 \s-1TESTING\s0"
1753
1776
.IX Subsection "RESOURCE TESTING"
1754
1777
Monit can examine how much system resources a service is using.
1755
1778
This test can only be used within a system or process service
1763
1786
The full syntax for a resource-statement used for resource
1764
1787
testing is as follows (keywords are in capital and optional
1765
1788
statements in [brackets]),
1766
 
.IP "\s-1IF\s0 resource operator value \s-1THEN\s0 action" 4
1767
 
.IX Item "IF resource operator value THEN action"
1768
 
.PP
1769
 
\&\fIresource\fR is a choice of \*(L"\s-1CPU\*(R", \*(L"TOTAL CPU\*(R",
1770
 
\&\*(L"CPU\s0([user|system|wait])\*(R", \*(L"\s-1MEMORY\*(R", \*(L"SWAP\*(R", \*(L"CHILDREN\*(R", \*(L"TOTAL MEMORY\*(R",
1771
 
\&\*(L"LOADAVG\s0([1min|5min|15min])\*(R". Some resource tests can be used
1772
 
inside a check system entry, some in a check process entry and
1773
 
some in both:
 
1789
.PP
 
1790
.Vb 1
 
1791
\& IF resource operator value THEN action
 
1792
.Ve
 
1793
.PP
 
1794
\&\fIresource\fR is a choice of \*(L"\s-1CPU\s0\*(R", \*(L"\s-1TOTAL\s0 \s-1CPU\s0\*(R",
 
1795
\&\*(L"\s-1CPU\s0([user|system|wait])\*(R", \*(L"\s-1MEMORY\s0\*(R", \*(L"\s-1SWAP\s0\*(R", \*(L"\s-1CHILDREN\s0\*(R", \*(L"\s-1TOTAL\s0
 
1796
\&\s-1MEMORY\s0\*(R", \*(L"\s-1LOADAVG\s0([1min|5min|15min])\*(R". Some resource tests can be used
 
1797
inside a check system entry, some in a check process entry and some in
 
1798
both:
1774
1799
.PP
1775
1800
System only resource tests:
1776
1801
.PP
1778
1803
in user or kernel space and I/O.
1779
1804
.PP
1780
1805
\&\s-1SWAP\s0 is the swap usage of the system in either percent (of the
1781
 
systems total) or as an amount (Byte, kB, \s-1MB, GB\s0).
 
1806
systems total) or as an amount (Byte, kB, \s-1MB\s0, \s-1GB\s0).
1782
1807
.PP
1783
1808
Process only resource tests:
1784
1809
.PP
1785
1810
\&\s-1CPU\s0 is the \s-1CPU\s0 usage of the process itself (percent).
1786
1811
.PP
1787
 
\&\s-1TOTAL CPU\s0 is the total \s-1CPU\s0 usage of the process and its children
1788
 
in (percent). You will want to use \s-1TOTAL CPU\s0 typically for
1789
 
services like Apache web server where one master process forks the
 
1812
\&\s-1TOTAL\s0 \s-1CPU\s0 is the total \s-1CPU\s0 usage of the process and its children
 
1813
in (percent). You will want to use \s-1TOTAL\s0 \s-1CPU\s0 typically for
 
1814
services like Apache web server where one master process forks
1790
1815
child processes as workers.
1791
1816
.PP
1792
1817
\&\s-1CHILDREN\s0 is the number of child processes of the process.
1793
1818
.PP
1794
 
\&\s-1TOTAL MEMORY\s0 is the memory usage of the process and its child
1795
 
processes in either percent or as an amount (Byte, kB, \s-1MB, GB\s0).
 
1819
\&\s-1TOTAL\s0 \s-1MEMORY\s0 is the memory usage of the process and its child
 
1820
processes in either percent or as an amount (Byte, kB, \s-1MB\s0, \s-1GB\s0).
1796
1821
.PP
1797
1822
System and process resource tests:
1798
1823
.PP
1799
1824
\&\s-1MEMORY\s0 is the memory usage of the system or of a process (without
1800
1825
children) in either percent (of the systems total) or as an
1801
 
amount (Byte, kB, \s-1MB, GB\s0).
 
1826
amount (Byte, kB, \s-1MB\s0, \s-1GB\s0).
1802
1827
.PP
1803
1828
\&\s-1LOADAVG\s0([1min|5min|15min]) refers to the system's load average.
1804
1829
The load average is the number of processes in the system run
1810
1835
specified, default is \s-1EQUAL\s0).
1811
1836
.PP
1812
1837
\&\fIvalue\fR is either an integer or a real number (except for
1813
 
\&\s-1CHILDREN\s0). For \s-1CPU, TOTAL CPU, MEMORY\s0 and \s-1TOTAL MEMORY\s0 you need to
 
1838
\&\s-1CHILDREN\s0). For \s-1CPU\s0, \s-1TOTAL\s0 \s-1CPU\s0, \s-1MEMORY\s0 and \s-1TOTAL\s0 \s-1MEMORY\s0 you need to
1814
1839
specify a \fIunit\fR. This could be \*(L"%\*(R" or if applicable \*(L"B\*(R" (Byte),
1815
 
\&\*(L"kB\*(R" (1024 Byte), \*(L"\s-1MB\*(R" \s0(1024 KiloByte) or \*(L"\s-1GB\*(R" \s0(1024 MegaByte).
 
1840
\&\*(L"kB\*(R" (1024 Byte), \*(L"\s-1MB\s0\*(R" (1024 KiloByte) or \*(L"\s-1GB\s0\*(R" (1024 MegaByte).
1816
1841
.PP
1817
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1818
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
1842
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
1843
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
1819
1844
.PP
1820
1845
To calculate the cycles, a counter is raised whenever the
1821
1846
expression above is true and it is lowered whenever it is false
1828
1853
.Vb 1
1829
1854
\& if cpu is greater than 50% for 5 cycles then restart
1830
1855
.Ve
1831
 
.SS "\s-1FILE CHECKSUM TESTING\s0"
 
1856
.SS "\s-1FILE\s0 \s-1CHECKSUM\s0 \s-1TESTING\s0"
1832
1857
.IX Subsection "FILE CHECKSUM TESTING"
1833
1858
The checksum statement may only be used in a file service
1834
 
entry and allows one to check \s-1MD5\s0 or \s-1SHA1\s0 checksum.
 
1859
entry and can be used to check the file's \s-1MD5\s0 or \s-1SHA1\s0 checksum.
1835
1860
.PP
1836
1861
Check specific checksum:
1837
 
.IP "\s-1IF FAILED\s0 [MD5|SHA1] \s-1CHECKSUM\s0 [\s-1EXPECT\s0 checksum] \s-1THEN\s0 action" 4
1838
 
.IX Item "IF FAILED [MD5|SHA1] CHECKSUM [EXPECT checksum] THEN action"
 
1862
.PP
 
1863
.Vb 1
 
1864
\& IF FAILED [MD5|SHA1] CHECKSUM [EXPECT checksum] THEN action
 
1865
.Ve
1839
1866
.PP
1840
1867
Check any file changes:
1841
 
.IP "\s-1IF CHANGED\s0 [MD5|SHA1] \s-1CHECKSUM THEN\s0 action" 4
1842
 
.IX Item "IF CHANGED [MD5|SHA1] CHECKSUM THEN action"
1843
 
.PP
1844
 
The choice of \s-1MD5\s0 or \s-1SHA1\s0 is optional. \s-1MD5\s0 features a 256 bit 
1845
 
and \s-1SHA1\s0 a 320 bit checksum. If this option is omitted Monit 
1846
 
tries to guess the method from the \s-1EXPECT\s0 string or uses \s-1MD5\s0 as
1847
 
default.
1848
 
.PP
1849
 
\&\fIexpect\fR is optional and if used it specifies a md5 or sha1
1850
 
string Monit should expect when testing a file's checksum. If
1851
 
\&\fIexpect\fR is used, Monit will not compute an initial checksum for
1852
 
the file, but instead use the string you submit. For example:
 
1868
.PP
 
1869
.Vb 1
 
1870
\& IF CHANGED [MD5|SHA1] CHECKSUM THEN action
 
1871
.Ve
 
1872
.PP
 
1873
The choice of \s-1MD5\s0 or \s-1SHA1\s0 is optional. \s-1MD5\s0 features a 128 bits checksum
 
1874
(32 bytes hex encoded string) and \s-1SHA1\s0 a 160 bits checksum (40 bytes
 
1875
hex encoded string). If this option is omitted, Monit will try to guess
 
1876
the method from the \s-1EXPECT\s0 string or use \s-1MD5\s0 as the default checksum.
 
1877
.PP
 
1878
\&\f(CW\*(C`expect\*(C'\fR is optional and if used, specifies the md5 or sha1 string
 
1879
Monit should expect when testing a file's checksum. Monit will then not
 
1880
compute an initial checksum for the file, but instead use the string
 
1881
you submit. For example:
1853
1882
.PP
1854
1883
.Vb 3
1855
 
\& if failed 
 
1884
\& if failed
1856
1885
\&    checksum expect 8f7f419955cefa0b33a2ba316cba3659
1857
1886
\& then alert
1858
1887
.Ve
1859
1888
.PP
1860
 
You can, for example, use the \s-1GNU\s0 utility \fI\fImd5sum\fI\|(1)\fR or 
1861
 
\&\fI\fIsha1sum\fI\|(1)\fR to create a checksum string for a file and 
 
1889
You can, for example, use the \s-1GNU\s0 utility \fI\fImd5sum\fI\|(1)\fR or
 
1890
\&\fI\fIsha1sum\fI\|(1)\fR to create a checksum string for a file and
1862
1891
use this string in the expect-statement.
1863
1892
.PP
1864
1893
Reloading a server if its configuration file was changed:
1868
1897
\&     if changed checksum then exec "/usr/bin/apachectl graceful"
1869
1898
.Ve
1870
1899
.PP
1871
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1872
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
1873
 
.SS "\s-1TIMESTAMP TESTING\s0"
 
1900
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
1901
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
1902
.SS "\s-1TIMESTAMP\s0 \s-1TESTING\s0"
1874
1903
.IX Subsection "TIMESTAMP TESTING"
1875
1904
The timestamp statement may only be used in a file, fifo or
1876
1905
directory service entry.
1877
1906
.PP
1878
1907
Specific timestamp syntax:
1879
 
.IP "\s-1IF TIMESTAMP\s0 [[operator] value [unit]] \s-1THEN\s0 action" 4
1880
 
.IX Item "IF TIMESTAMP [[operator] value [unit]] THEN action"
1881
 
.PP
1882
 
Timestamp change syntax:
1883
 
.IP "\s-1IF CHANGED TIMESTAMP THEN\s0 action" 4
1884
 
.IX Item "IF CHANGED TIMESTAMP THEN action"
 
1908
.PP
 
1909
.Vb 1
 
1910
\& IF TIMESTAMP [[operator] value [unit]] THEN action
 
1911
.Ve
 
1912
.PP
 
1913
Timestamp changed syntax:
 
1914
.PP
 
1915
.Vb 1
 
1916
\& IF CHANGED TIMESTAMP THEN action
 
1917
.Ve
1885
1918
.PP
1886
1919
\&\fIoperator\fR is a choice of \*(L"<\*(R", \*(L">\*(R", \*(L"!=\*(R", \*(L"==\*(R" in C notation,
1887
 
\&\*(L"\s-1GT\*(R", \*(L"LT\*(R", \*(L"EQ\*(R", \*(L"NE\*(R"\s0 in shell sh notation and \*(L"\s-1GREATER\*(R",
1888
 
\&\*(L"LESS\*(R", \*(L"EQUAL\*(R", \*(L"NOTEQUAL\*(R"\s0 in human readable form (if not
 
1920
\&\*(L"\s-1GT\s0\*(R", \*(L"\s-1LT\s0\*(R", \*(L"\s-1EQ\s0\*(R", \*(L"\s-1NE\s0\*(R" in shell sh notation and \*(L"\s-1GREATER\s0\*(R",
 
1921
\&\*(L"\s-1LESS\s0\*(R", \*(L"\s-1EQUAL\s0\*(R", \*(L"\s-1NOTEQUAL\s0\*(R" in human readable form (if not
1889
1922
specified, default is \s-1EQUAL\s0).
1890
1923
.PP
1891
1924
\&\fIvalue\fR is a time watermark.
1892
1925
.PP
1893
1926
\&\fIunit\fR is either \*(L"\s-1SECOND\s0(S)\*(R", \*(L"\s-1MINUTE\s0(S)\*(R", \*(L"\s-1HOUR\s0(S)\*(R" or \*(L"\s-1DAY\s0(S)\*(R".
1894
1927
.PP
1895
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1896
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
1928
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
1929
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
1897
1930
.PP
1898
 
For example to reload apache if configuration file timestamp changed:
 
1931
For example to reload apache if the configuration file timestamp
 
1932
changed:
1899
1933
.PP
1900
1934
.Vb 2
1901
1935
\& check file apache_conf with path /etc/apache/httpd.conf
1905
1939
For example testing directory for file addition or removal:
1906
1940
.PP
1907
1941
.Vb 2
1908
 
\& check directory mydir path /foo/directory
1909
 
\&  if timestamp < 1 hour then alert
 
1942
\& check directory bar path /foo/bar
 
1943
\&       if timestamp < 1 hour then alert
1910
1944
.Ve
1911
 
.SS "\s-1FILE SIZE TESTING\s0"
 
1945
.SS "\s-1FILE\s0 \s-1SIZE\s0 \s-1TESTING\s0"
1912
1946
.IX Subsection "FILE SIZE TESTING"
1913
1947
The size statement may only be used in a check file service
1914
1948
entry. If specified in the control file, Monit will compute
1915
1949
a size for a file.
1916
1950
.PP
1917
1951
Testing specific size or range:
1918
 
.IP "\s-1IF SIZE\s0 [[operator] value [unit]] \s-1THEN\s0 action" 4
1919
 
.IX Item "IF SIZE [[operator] value [unit]] THEN action"
1920
 
.PP
1921
 
Testing size change:
1922
 
.IP "\s-1IF CHANGED SIZE THEN\s0 action" 4
1923
 
.IX Item "IF CHANGED SIZE THEN action"
 
1952
.PP
 
1953
.Vb 1
 
1954
\& IF SIZE [[operator] value [unit]] THEN action
 
1955
.Ve
 
1956
.PP
 
1957
Testing size changes:
 
1958
.PP
 
1959
.Vb 1
 
1960
\& IF CHANGED SIZE THEN action
 
1961
.Ve
1924
1962
.PP
1925
1963
\&\fIoperator\fR is a choice of \*(L"<\*(R", \*(L">\*(R", \*(L"!=\*(R", \*(L"==\*(R" in C notation,
1926
 
\&\*(L"\s-1GT\*(R", \*(L"LT\*(R", \*(L"EQ\*(R", \*(L"NE\*(R"\s0 in shell sh notation and \*(L"\s-1GREATER\*(R",
1927
 
\&\*(L"LESS\*(R", \*(L"EQUAL\*(R", \*(L"NOTEQUAL\*(R"\s0 in human readable form (if not
 
1964
\&\*(L"\s-1GT\s0\*(R", \*(L"\s-1LT\s0\*(R", \*(L"\s-1EQ\s0\*(R", \*(L"\s-1NE\s0\*(R" in shell sh notation and \*(L"\s-1GREATER\s0\*(R",
 
1965
\&\*(L"\s-1LESS\s0\*(R", \*(L"\s-1EQUAL\s0\*(R", \*(L"\s-1NOTEQUAL\s0\*(R" in human readable form (if not
1928
1966
specified, default is \s-1EQUAL\s0).
1929
1967
.PP
1930
1968
\&\fIvalue\fR is a size watermark.
1931
1969
.PP
1932
 
\&\fIunit\fR is a choice of \*(L"B\*(R",\*(L"\s-1KB\*(R",\*(L"MB\*(R",\*(L"GB\*(R"\s0 or long alternatives
 
1970
\&\fIunit\fR is a choice of \*(L"B\*(R",\*(L"\s-1KB\s0\*(R",\*(L"\s-1MB\s0\*(R",\*(L"\s-1GB\s0\*(R" or long alternatives
1933
1971
\&\*(L"byte\*(R", \*(L"kilobyte\*(R", \*(L"megabyte\*(R", \*(L"gigabyte\*(R". If it is not
1934
1972
specified, \*(L"byte\*(R" unit is assumed by default.
1935
1973
.PP
1936
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1937
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
1974
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
1975
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
1938
1976
.PP
1939
1977
For example to send an alert if the file is too large:
1940
1978
.PP
1942
1980
\& check file mydb with path /data/mydatabase.db
1943
1981
\&       if size > 1 GB then alert
1944
1982
.Ve
1945
 
.SS "\s-1FILE CONTENT TESTING\s0"
 
1983
.SS "\s-1FILE\s0 \s-1CONTENT\s0 \s-1TESTING\s0"
1946
1984
.IX Subsection "FILE CONTENT TESTING"
1947
 
The match statement allows one to incrementally test the content of a
 
1985
The match statement can be used to incrementally test the content of a
1948
1986
text file by using regular expressions.
1949
1987
.PP
1950
1988
Syntax:
1951
 
.IP "\s-1IF\s0 [\s-1NOT\s0] \s-1MATCH\s0 {regex|path} \s-1THEN\s0 action" 4
1952
 
.IX Item "IF [NOT] MATCH {regex|path} THEN action"
 
1989
.PP
 
1990
.Vb 1
 
1991
\& IF [NOT] MATCH {regex|path} THEN action
 
1992
.Ve
1953
1993
.PP
1954
1994
\&\fIregex\fR is a string containing the extended regular expression.
1955
1995
See also \fIregex\fR\|(7).
1957
1997
\&\fIpath\fR is an absolute path to a file containing extended
1958
1998
regular expression on every line. See also \fIregex\fR\|(7).
1959
1999
.PP
1960
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
1961
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2000
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2001
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
1962
2002
.PP
1963
2003
You can use the \fI\s-1NOT\s0\fR statement to invert a match.
1964
2004
.PP
1965
 
On startup the read position is set to the end of the file 
1966
 
and Monit continues to scan to the end of the file each cycle.
 
2005
On startup the read position is set to the end of the file
 
2006
and Monit continues to scan to the end of the file on each cycle.
1967
2007
.PP
1968
 
If the file size should decrease or inode change the read
 
2008
If the file size should decrease or inode changed, the read
1969
2009
position is set to the start of the file.
1970
2010
.PP
1971
2011
Only lines ending with a newline character are inspected.
1972
2012
.PP
1973
 
Only first 511 characters of a line are inspected.
1974
 
.IP "\s-1IGNORE\s0 [\s-1NOT\s0] \s-1MATCH\s0 {regex|path}" 4
1975
 
.IX Item "IGNORE [NOT] MATCH {regex|path}"
1976
 
.PP
1977
 
Lines matching an \fI\s-1IGNORE\s0\fR are not inspected during later 
1978
 
evaluations. \fI\s-1IGNORE MATCH\s0\fR has always precedence over 
1979
 
\&\fI\s-1IF MATCH\s0\fR.
1980
 
.PP
1981
 
All \fI\s-1IGNORE MATCH\s0\fR statements are evaluated first, in the 
1982
 
order of their appearance. Thereafter, all the \fI\s-1IF MATCH\s0\fR 
 
2013
Only the first 511 characters of a line are inspected.
 
2014
.PP
 
2015
.Vb 1
 
2016
\& IGNORE [NOT] MATCH {regex|path}
 
2017
.Ve
 
2018
.PP
 
2019
Lines matching an \fI\s-1IGNORE\s0\fR are not inspected during later
 
2020
evaluations. \fI\s-1IGNORE\s0 \s-1MATCH\s0\fR has always precedence over
 
2021
\&\fI\s-1IF\s0 \s-1MATCH\s0\fR.
 
2022
.PP
 
2023
All \fI\s-1IGNORE\s0 \s-1MATCH\s0\fR statements are evaluated first, in the
 
2024
order of their appearance. Thereafter, all the \fI\s-1IF\s0 \s-1MATCH\s0\fR
1983
2025
statements are evaluated.
1984
2026
.PP
1985
2027
For example:
1986
2028
.PP
1987
2029
.Vb 3
1988
2030
\&  check file syslog with path /var/log/syslog
1989
 
\&    ignore match "^monit"
1990
 
\&    if match "^mrcoffee" then alert
 
2031
\&        ignore match "^monit"
 
2032
\&        if match "^mrcoffee" then alert
1991
2033
.Ve
1992
 
.SS "\s-1FILESYSTEM FLAGS TESTING\s0"
 
2034
.SS "\s-1FILESYSTEM\s0 \s-1FLAGS\s0 \s-1TESTING\s0"
1993
2035
.IX Subsection "FILESYSTEM FLAGS TESTING"
1994
 
Monit can test the flags of a filesystem for changes. This test
1995
 
is implicit and Monit will send alert in case of failure by
1996
 
default.
 
2036
Monit can test the flags of a filesystem for changes. This test is
 
2037
implicit and Monit will send alert in case of failure by default.
1997
2038
.PP
1998
 
This test is useful for detecting changes of the filesystem flags
1999
 
such as when the filesystem became read-only (on disk error) or
2000
 
mount flags were changed (such as nosuid).
 
2039
This test is useful for detecting changes of filesystem flags such as
 
2040
if the filesystem become read-only (on disk error) or mount flags were
 
2041
changed (such as nosuid).
2001
2042
.PP
2002
2043
The syntax for the fsflags statement is:
2003
 
.IP "\s-1IF CHANGED FSFLAGS THEN\s0 action" 4
2004
 
.IX Item "IF CHANGED FSFLAGS THEN action"
2005
 
.PP
2006
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2007
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2044
.PP
 
2045
.Vb 1
 
2046
\& IF CHANGED FSFLAGS THEN action
 
2047
.Ve
 
2048
.PP
 
2049
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2050
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2008
2051
.PP
2009
2052
Example:
2010
2053
.PP
2012
2055
\& check filesystem rootfs with path /
2013
2056
\&       if changed fsflags then exec "/my/script"
2014
2057
.Ve
2015
 
.SS "\s-1SPACE TESTING\s0"
 
2058
.SS "\s-1SPACE\s0 \s-1TESTING\s0"
2016
2059
.IX Subsection "SPACE TESTING"
2017
 
Monit can test filesystem space usage. This test may only be used
2018
 
in the context of a filesystem service type.
 
2060
Monit can test a filesystem or disk for space usage. This test may only
 
2061
be used in the context of a filesystem service type.
2019
2062
.PP
2020
 
Monit checks a total space usage, including reserved blocks.
 
2063
Monit will check the total space usage, including reserved blocks.
2021
2064
.PP
2022
2065
Syntax:
2023
 
.IP "\s-1IF SPACE\s0 operator value unit \s-1THEN\s0 action" 4
2024
 
.IX Item "IF SPACE operator value unit THEN action"
 
2066
.PP
 
2067
.Vb 1
 
2068
\& IF SPACE operator value unit THEN action
 
2069
.Ve
2025
2070
.PP
2026
2071
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
2027
2072
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
2028
2073
\&\*(L"equal\*(R", \*(L"notequal\*(R" in human readable form (if not specified,
2029
2074
default is \s-1EQUAL\s0).
2030
2075
.PP
2031
 
\&\fIunit\fR is a choice of \*(L"B\*(R",\*(L"\s-1KB\*(R",\*(L"MB\*(R",\*(L"GB\*(R", \s0\*(L"%\*(R" or long
 
2076
\&\fIunit\fR is a choice of \*(L"B\*(R",\*(L"\s-1KB\s0\*(R",\*(L"\s-1MB\s0\*(R",\*(L"\s-1GB\s0\*(R", \*(L"%\*(R" or long
2032
2077
alternatives \*(L"byte\*(R", \*(L"kilobyte\*(R", \*(L"megabyte\*(R", \*(L"gigabyte\*(R",
2033
2078
\&\*(L"percent\*(R".
2034
2079
.PP
2035
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2036
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2080
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2081
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2037
2082
.PP
2038
2083
Example:
2039
2084
.PP
2041
2086
\& check filesystem rootfs with path /
2042
2087
\&       if space usage > 90% then alert
2043
2088
.Ve
2044
 
.SS "\s-1INODE TESTING\s0"
 
2089
.SS "\s-1INODE\s0 \s-1TESTING\s0"
2045
2090
.IX Subsection "INODE TESTING"
2046
2091
Monit can test filesystem inode usage. This test may only be used
2047
2092
in the context of a filesystem service type.
2048
2093
.PP
2049
2094
Syntax:
2050
 
.IP "\s-1IF INODE\s0(S) operator value [unit] \s-1THEN\s0 action" 4
2051
 
.IX Item "IF INODE(S) operator value [unit] THEN action"
 
2095
.PP
 
2096
.Vb 1
 
2097
\& IF INODE(S) operator value [unit] THEN action
 
2098
.Ve
2052
2099
.PP
2053
2100
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
2054
2101
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
2059
2106
count of inodes. You can use the \*(L"%\*(R" character or the longer
2060
2107
alternative \*(L"percent\*(R" as a unit.
2061
2108
.PP
2062
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2063
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2109
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2110
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2064
2111
.PP
2065
2112
Example:
2066
2113
.PP
2068
2115
\& check filesystem rootfs with path /
2069
2116
\&       if inode usage > 90% then alert
2070
2117
.Ve
2071
 
.SS "\s-1PERMISSION TESTING\s0"
 
2118
.SS "\s-1PERMISSION\s0 \s-1TESTING\s0"
2072
2119
.IX Subsection "PERMISSION TESTING"
2073
2120
Monit can test the permissions of file objects. This test may
2074
2121
only be used in the context of a file, fifo, directory or
2075
2122
filesystem service types.
2076
2123
.PP
2077
2124
Syntax:
2078
 
.IP "\s-1IF FAILED PERM\s0(\s-1ISSION\s0) octalnumber \s-1THEN\s0 action" 4
2079
 
.IX Item "IF FAILED PERM(ISSION) octalnumber THEN action"
 
2125
.PP
 
2126
.Vb 1
 
2127
\& IF FAILED PERM(ISSION) octalnumber THEN action
 
2128
.Ve
2080
2129
.PP
2081
2130
\&\fIoctalnumber\fR defines permissions for a file, a directory or a
2082
 
filesystem as four octal digits (0\-7). Valid range: 0000 \- 7777 (you
2083
 
can omit the leading zeros, Monit will add the zeros to the left
2084
 
thus for example \*(L"640\*(R" is valid value and matches \*(L"0640\*(R").
 
2131
filesystem as four octal digits (0\-7). Valid range is 0000 \- 7777 (you
 
2132
can omit the leading zeros, Monit will add the zeros to the left. For
 
2133
example, \*(L"640\*(R" is a valid value and matches \*(L"0640\*(R").
2085
2134
.PP
2086
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2087
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2135
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2136
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2088
2137
.PP
2089
2138
Example:
2090
2139
.PP
2092
2141
\& check file shadow with path /etc/shadow
2093
2142
\&       if failed permission 0640 then alert
2094
2143
.Ve
2095
 
.SS "\s-1UID TESTING\s0"
 
2144
.SS "\s-1UID\s0 \s-1TESTING\s0"
2096
2145
.IX Subsection "UID TESTING"
2097
2146
Monit can monitor the owner user id (uid) of a file, fifo, directory
2098
2147
or owner and effective user of a process.
2099
2148
.PP
2100
2149
Syntax:
2101
 
.IP "\s-1IF FAILED\s0 [E]UID user \s-1THEN\s0 action" 4
2102
 
.IX Item "IF FAILED [E]UID user THEN action"
 
2150
.PP
 
2151
.Vb 1
 
2152
\& IF FAILED [E]UID user THEN action
 
2153
.Ve
2103
2154
.PP
2104
2155
\&\fIuser\fR defines a user id either in numeric or in string form.
2105
2156
.PP
2106
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2107
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2157
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2158
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2108
2159
.PP
2109
2160
Example:
2110
2161
.PP
2112
2163
\& check file shadow with path /etc/shadow
2113
2164
\&       if failed uid root then alert
2114
2165
.Ve
2115
 
.SS "\s-1GID TESTING\s0"
 
2166
.SS "\s-1GID\s0 \s-1TESTING\s0"
2116
2167
.IX Subsection "GID TESTING"
2117
2168
Monit can monitor the owner group id (gid) of a file, fifo, directory
2118
2169
or process.
2119
2170
.PP
2120
2171
Syntax:
2121
 
.IP "\s-1IF FAILED GID\s0 group \s-1THEN\s0 action" 4
2122
 
.IX Item "IF FAILED GID group THEN action"
 
2172
.PP
 
2173
.Vb 1
 
2174
\& IF FAILED GID group THEN action
 
2175
.Ve
2123
2176
.PP
2124
2177
\&\fIgroup\fR defines a group id either in numeric or in string form.
2125
2178
.PP
2126
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2127
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2179
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2180
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2128
2181
.PP
2129
2182
Example:
2130
2183
.PP
2132
2185
\& check file shadow with path /etc/shadow
2133
2186
\&       if failed gid shadow then alert
2134
2187
.Ve
2135
 
.SS "\s-1PID TESTING\s0"
 
2188
.SS "\s-1PID\s0 \s-1TESTING\s0"
2136
2189
.IX Subsection "PID TESTING"
2137
 
Monit can test the process' \s-1PID.\s0 This test is implicit and Monit will
2138
 
send a alert in the case that the \s-1PID\s0 changed outside of Monit control.
 
2190
Monit can test the process' \s-1PID\s0. This test is implicit and Monit will
 
2191
send an alert in case the \s-1PID\s0 changed outside of Monit's control.
2139
2192
.PP
2140
2193
Syntax:
2141
 
.IP "\s-1IF CHANGED PID THEN\s0 action" 4
2142
 
.IX Item "IF CHANGED PID THEN action"
2143
 
.PP
2144
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2145
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2194
.PP
 
2195
.Vb 1
 
2196
\& IF CHANGED PID THEN action
 
2197
.Ve
 
2198
.PP
 
2199
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2200
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2146
2201
.PP
2147
2202
This test is useful to detect possible process restarts which has
2148
2203
occurred in the timeframe between two Monit testing cycles.
2149
2204
.PP
2150
 
For example if someone changes sshd configuration and do sshd
2151
 
restart outside of Monit's control you will be notified that the
2152
 
process was replaced by a new instance:
 
2205
For example if someone changes sshd configuration and did sshd restart
 
2206
outside of Monit's control you will be notified that the process was
 
2207
replaced by a new instance:
2153
2208
.PP
2154
2209
.Vb 2
2155
2210
\& check process sshd with pidfile /var/run/sshd.pid
2156
2211
\&       if changed pid then alert
2157
2212
.Ve
2158
 
.SS "\s-1PPID TESTING\s0"
 
2213
.SS "\s-1PPID\s0 \s-1TESTING\s0"
2159
2214
.IX Subsection "PPID TESTING"
2160
 
Monit can test the process' parent \s-1PID \s0(\s-1PPID\s0) for changes. This
 
2215
Monit can test the process' parent \s-1PID\s0 (\s-1PPID\s0) for changes. This
2161
2216
test is implicit and Monit will send alert in the case that the
2162
2217
\&\s-1PPID\s0 changed outside of Monit control.
2163
2218
.PP
2164
2219
The syntax for the ppid statement is:
2165
 
.IP "\s-1IF CHANGED PPID THEN\s0 action" 4
2166
 
.IX Item "IF CHANGED PPID THEN action"
2167
 
.PP
2168
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2169
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2220
.PP
 
2221
.Vb 1
 
2222
\& IF CHANGED PPID THEN action
 
2223
.Ve
 
2224
.PP
 
2225
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2226
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2170
2227
.PP
2171
2228
Example:
2172
2229
.PP
2174
2231
\& check process myproc with pidfile /var/run/myproc.pid
2175
2232
\&       if changed ppid then exec "/my/script"
2176
2233
.Ve
2177
 
.SS "\s-1PROCESS UPTIME TESTING\s0"
 
2234
.SS "\s-1PROCESS\s0 \s-1UPTIME\s0 \s-1TESTING\s0"
2178
2235
.IX Subsection "PROCESS UPTIME TESTING"
2179
2236
The uptime statement may only be used in a process service
2180
2237
type context.
2181
2238
.PP
2182
2239
Syntax:
2183
 
.IP "\s-1IF UPTIME\s0 [[operator] value [unit]] \s-1THEN\s0 action" 4
2184
 
.IX Item "IF UPTIME [[operator] value [unit]] THEN action"
 
2240
.PP
 
2241
.Vb 1
 
2242
\& IF UPTIME [[operator] value [unit]] THEN action
 
2243
.Ve
2185
2244
.PP
2186
2245
\&\fIoperator\fR is a choice of \*(L"<\*(R", \*(L">\*(R", \*(L"!=\*(R", \*(L"==\*(R" in C notation,
2187
 
\&\*(L"\s-1GT\*(R", \*(L"LT\*(R", \*(L"EQ\*(R", \*(L"NE\*(R"\s0 in shell sh notation and \*(L"\s-1GREATER\*(R",
2188
 
\&\*(L"LESS\*(R", \*(L"EQUAL\*(R", \*(L"NOTEQUAL\*(R"\s0 in human readable form (if not
 
2246
\&\*(L"\s-1GT\s0\*(R", \*(L"\s-1LT\s0\*(R", \*(L"\s-1EQ\s0\*(R", \*(L"\s-1NE\s0\*(R" in shell sh notation and \*(L"\s-1GREATER\s0\*(R",
 
2247
\&\*(L"\s-1LESS\s0\*(R", \*(L"\s-1EQUAL\s0\*(R", \*(L"\s-1NOTEQUAL\s0\*(R" in human readable form (if not
2189
2248
specified, default is \s-1EQUAL\s0).
2190
2249
.PP
2191
2250
\&\fIvalue\fR is a uptime watermark.
2192
2251
.PP
2193
 
\&\fIunit\fR is either \*(L"\s-1SECOND\*(R", \*(L"MINUTE\*(R", \*(L"HOUR\*(R"\s0 or \*(L"\s-1DAY\*(R" \s0(it is also
2194
 
possible to use \*(L"\s-1SECONDS\*(R", \*(L"MINUTES\*(R", \*(L"HOURS\*(R",\s0 or \*(L"\s-1DAYS\*(R"\s0).
 
2252
\&\fIunit\fR is either \*(L"\s-1SECOND\s0\*(R", \*(L"\s-1MINUTE\s0\*(R", \*(L"\s-1HOUR\s0\*(R" or \*(L"\s-1DAY\s0\*(R" (it is also
 
2253
possible to use \*(L"\s-1SECONDS\s0\*(R", \*(L"\s-1MINUTES\s0\*(R", \*(L"\s-1HOURS\s0\*(R", or \*(L"\s-1DAYS\s0\*(R").
2195
2254
.PP
2196
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2197
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2255
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2256
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2198
2257
.PP
2199
2258
Example of restarting the process every three days:
2200
2259
.PP
2204
2263
\&    stop program = "/etc/init.d/myapp stop"
2205
2264
\&    if uptime > 3 days then restart
2206
2265
.Ve
2207
 
.SS "\s-1PROGRAM STATUS TESTING\s0"
 
2266
.SS "\s-1PROGRAM\s0 \s-1STATUS\s0 \s-1TESTING\s0"
2208
2267
.IX Subsection "PROGRAM STATUS TESTING"
2209
2268
You can check the exit status of a program or a script. This test
2210
2269
may only be used within a check program service entry in the Monit
2211
2270
control file.
2212
2271
.PP
2213
2272
Syntax for testing specific exit value:
2214
 
.IP "\s-1IF STATUS\s0 operator value \s-1THEN\s0 action" 4
2215
 
.IX Item "IF STATUS operator value THEN action"
 
2273
.PP
 
2274
.Vb 1
 
2275
\& IF STATUS operator value THEN action
 
2276
.Ve
2216
2277
.PP
2217
2278
Syntax for testing any exit value change:
2218
 
.IP "\s-1IF CHANGED STATUS THEN\s0 action" 4
2219
 
.IX Item "IF CHANGED STATUS THEN action"
 
2279
.PP
 
2280
.Vb 1
 
2281
\& IF CHANGED STATUS THEN action
 
2282
.Ve
2220
2283
.PP
2221
2284
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
2222
2285
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
2223
2286
\&\*(L"equal\*(R", \*(L"notequal\*(R" in human readable form (if not specified,
2224
2287
default is \s-1EQUAL\s0).
2225
2288
.PP
2226
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2227
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2289
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2290
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2228
2291
.PP
2229
2292
Example:
2230
2293
.PP
2231
 
.Vb 3
2232
 
\& check program myscript with path /usr/local/bin/myscript.sh 
2233
 
\&       with timeout 500 seconds
 
2294
.Vb 2
 
2295
\& check program myscript with path /usr/local/bin/myscript.sh
2234
2296
\&       if status != 0 then alert
2235
2297
.Ve
2236
2298
.PP
2250
2312
.Ve
2251
2313
.PP
2252
2314
Arguments to the program or script is a sequence of whitespace
2253
 
separated strings. In the above example the strings '\-lrt' and 
2254
 
\&'/tmp/' are arguments to the program '/bin/ls'. If arguments are
2255
 
used, it is recommended to use quotes \fB"\fR to enclose the string,
2256
 
otherwise, if no arguments are used, quotes are not needed.
 
2315
separated strings. In the above example the strings '\-lrt' and '/tmp/'
 
2316
are arguments to the program '/bin/ls'. If arguments are used, it is
 
2317
recommended to use quotes \fB"\fR to enclose the string, otherwise, if no
 
2318
arguments are used, quotes are not needed.
2257
2319
.PP
2258
2320
Notes: If the program is a script, the interpreter is required
2259
2321
in the first line. The program or script must also be executable.
2260
2322
.PP
2261
 
If Monit is run as the super user, you can optionally run the
2262
 
program as a different user and/or group. In this example we
2263
 
run the \fIls\fR program as user www and as group staff:
 
2323
If Monit is run as the super user, you can optionally run the program
 
2324
as a different user and/or group. In this example we run the \fIls\fR
 
2325
program as user www and as group staff:
2264
2326
.PP
2265
2327
.Vb 3
2266
2328
\& check program ls with path "/bin/ls /tmp" as uid "www"
2268
2330
\&       if status != 0 then alert
2269
2331
.Ve
2270
2332
.PP
2271
 
Monit will execute the program periodically and if the exit
2272
 
status of the program does not match the expected result, Monit
2273
 
can perform an action. In the example above, Monit will raise an
2274
 
alert if the exit value is different from 0. By convention, 0
2275
 
means the program exited normally.
 
2333
Monit will execute the program periodically and if the exit status of
 
2334
the program does not match the expected result, Monit can perform an
 
2335
action. In the example above, Monit will raise an alert if the exit
 
2336
value is different from 0. By convention, 0 means the program exited
 
2337
normally.
2276
2338
.PP
2277
 
Program checks are asynchronous. Meaning that Monit will not wait
2278
 
for the program to exit, but instead, Monit will start the
2279
 
program in the background and immediately continue checking the
2280
 
next service entry in \fImonitrc\fR. At the next cycle, Monit will
2281
 
check if the program has finished and if so, collect the programs
2282
 
exit status \- if the status indicate a failure, Monit will raise
2283
 
an alert message containing the program's error (stderr) output,
2284
 
if any. If the program has not exited after the first cycle,
2285
 
Monit will wait another cycle and so on. If the program is still
2286
 
running after 5 minutes, Monit will kill it and generate a
2287
 
program timeout event. It is possible to override the default
2288
 
timeout (see the syntax below).
 
2339
Program checks are asynchronous. Meaning that Monit will not wait for
 
2340
the program to exit, but instead, Monit will start the program in the
 
2341
background and immediately continue checking the next service entry in
 
2342
\&\fImonitrc\fR. At the next cycle, Monit will check if the program has
 
2343
finished and if so, collect the program's exit status. If the status
 
2344
indicate a failure, Monit will raise an alert message containing the
 
2345
program's error (stderr) output, if any. If the program has not exited
 
2346
after the first cycle, Monit will wait another cycle and so on. If the
 
2347
program is still running after 5 minutes, Monit will kill it and
 
2348
generate a program timeout event. It is possible to override the
 
2349
default timeout (see the syntax below).
2289
2350
.PP
2290
2351
The asynchronous nature of the program check allows for
2291
2352
non-blocking behavior in the current Monit design, but it comes
2301
2362
.PP
2302
2363
Multiple status tests can be used, for example:
2303
2364
.PP
2304
 
.Vb 3
 
2365
.Vb 4
2305
2366
\& check program hwtest with path /usr/local/bin/hwtest.sh
 
2367
\&       with timeout 500 seconds
2306
2368
\&       if status = 1 then alert
2307
2369
\&       if status = 3 for 5 cycles then exec "/usr/local/bin/emergency.sh"
2308
2370
.Ve
2309
 
.SS "\s-1NETWORK PING TEST\s0"
 
2371
.SS "\s-1NETWORK\s0 \s-1LINK\s0 \s-1STATUS\s0 \s-1TEST\s0"
 
2372
.IX Subsection "NETWORK LINK STATUS TEST"
 
2373
You can check the network link state. This test may only be used
 
2374
within a check network service entry in the Monit control file.
 
2375
.PP
 
2376
Syntax:
 
2377
.PP
 
2378
.Vb 1
 
2379
\& IF FAILED LINK THEN action
 
2380
.Ve
 
2381
.PP
 
2382
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2383
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
2384
.PP
 
2385
The test will fail if the link is down or link errors were detected.
 
2386
.PP
 
2387
Example:
 
2388
.PP
 
2389
.Vb 1
 
2390
\& if failed link then alert
 
2391
.Ve
 
2392
.SS "\s-1NETWORK\s0 \s-1LINK\s0 \s-1CAPACITY\s0 \s-1TEST\s0"
 
2393
.IX Subsection "NETWORK LINK CAPACITY TEST"
 
2394
You can check the network link mode capacity for changes. This test 
 
2395
may only be used within a check network service entry in the Monit
 
2396
control file.
 
2397
.PP
 
2398
Syntax:
 
2399
.PP
 
2400
.Vb 1
 
2401
\& IF CHANGED LINK [CAPACITY] THEN action
 
2402
.Ve
 
2403
.PP
 
2404
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2405
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
2406
.PP
 
2407
The test will match if the link mode has changed (e.g. maximum speed
 
2408
dropped) or if the duplex mode has changed.
 
2409
.PP
 
2410
\&\s-1NOTE:\s0 not all interface types allow for capacity monitoring. Pseudo
 
2411
interfaces such as loopback device or VMWare interfaces don't have
 
2412
speed attribute.
 
2413
.PP
 
2414
Example:
 
2415
.PP
 
2416
.Vb 1
 
2417
\& if changed link capacity then alert
 
2418
.Ve
 
2419
.SS "\s-1NETWORK\s0 \s-1SATURATION\s0 \s-1TEST\s0"
 
2420
.IX Subsection "NETWORK SATURATION TEST"
 
2421
You can check the network link saturation. Monit then computes the link
 
2422
utilization based on the current transfer rate vs.  maximum link speed.
 
2423
This test may only be used within a check network service entry in the
 
2424
Monit control file.
 
2425
.PP
 
2426
Syntax:
 
2427
.PP
 
2428
.Vb 1
 
2429
\& IF SATURATION operator value% THEN action
 
2430
.Ve
 
2431
.PP
 
2432
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
 
2433
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
 
2434
\&\*(L"equal\*(R", \*(L"notequal\*(R" in human readable form (if not specified,
 
2435
default is \s-1EQUAL\s0).
 
2436
.PP
 
2437
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2438
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
2439
.PP
 
2440
\&\s-1NOTE:\s0 as this test depends on the link speed being available, not all
 
2441
interface types allow to test the saturation. See the \s-1LINK\s0 \s-1SPEED\s0 test
 
2442
description.
 
2443
.PP
 
2444
Example:
 
2445
.PP
 
2446
.Vb 1
 
2447
\& if saturation > 90% then alert
 
2448
.Ve
 
2449
.SS "\s-1NETWORK\s0 \s-1BANDWIDTH\s0 \s-1TEST\s0"
 
2450
.IX Subsection "NETWORK BANDWIDTH TEST"
 
2451
You can check the network link upload and download bandwidth \- current
 
2452
transfer rate and total data transferred in last 24 hours. This test may
 
2453
only be used within a check network service entry in the Monit control file.
 
2454
.PP
 
2455
Crrent upload bandwidth rate test syntax:
 
2456
.PP
 
2457
.Vb 1
 
2458
\& IF UPLOAD operator value unit THEN action
 
2459
.Ve
 
2460
.PP
 
2461
Current download bandwidth rate test syntax:
 
2462
.PP
 
2463
.Vb 1
 
2464
\& IF DOWNLOAD operator value unit THEN action
 
2465
.Ve
 
2466
.PP
 
2467
Total upload test syntax:
 
2468
.PP
 
2469
.Vb 1
 
2470
\& IF TOTAL UPLOAD operator value unit IN LAST number timeunit THEN action
 
2471
.Ve
 
2472
.PP
 
2473
Total download test syntax:
 
2474
.PP
 
2475
.Vb 1
 
2476
\& IF TOTAL DOWNLOAD operator value unit IN LAST number timeunit THEN action
 
2477
.Ve
 
2478
.PP
 
2479
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
 
2480
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
 
2481
\&\*(L"equal\*(R", \*(L"notequal\*(R" in human readable form (if not specified,
 
2482
default is \s-1EQUAL\s0).
 
2483
.PP
 
2484
\&\fIunit\fR is a choice of \*(L"B\*(R",\*(L"\s-1KB\s0\*(R",\*(L"\s-1MB\s0\*(R",\*(L"\s-1GB\s0\*(R" or long alternatives
 
2485
\&\*(L"byte\*(R", \*(L"kilobyte\*(R", \*(L"megabyte\*(R", \*(L"gigabyte\*(R".
 
2486
.PP
 
2487
\&\fItimeunit\fR is a choice of \*(L"\s-1MINUTE\s0(S)\*(R", \*(L"\s-1HOUR\s0(S)\*(R", \*(L"\s-1DAY\s0\*(R".
 
2488
\&\s-1NOTE:\s0 Monit keeps total upload/download statistics only for last
 
2489
24 hours => the test cannot span more then one day.
 
2490
.PP
 
2491
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2492
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
2493
.PP
 
2494
Examples:
 
2495
.PP
 
2496
.Vb 3
 
2497
\& if upload > 500 kB/s then alert
 
2498
\& if total download > 1 GB in last 2 hours then alert
 
2499
\& if total download > 10 GB in last day then alert
 
2500
.Ve
 
2501
.SS "\s-1NETWORK\s0 \s-1PACKETS\s0 \s-1TEST\s0"
 
2502
.IX Subsection "NETWORK PACKETS TEST"
 
2503
You can check the network link upload and download packets count \- current
 
2504
transfer rate and total data transferred in last 24 hours. This test may
 
2505
only be used within a check network service entry in the Monit control file.
 
2506
.PP
 
2507
Crrent upload bandwidth rate test syntax:
 
2508
.PP
 
2509
.Vb 1
 
2510
\& IF UPLOAD operator value PACKETS/S THEN action
 
2511
.Ve
 
2512
.PP
 
2513
Current download bandwidth rate test syntax:
 
2514
.PP
 
2515
.Vb 1
 
2516
\& IF DOWNLOAD operator value PACKETS/S THEN action
 
2517
.Ve
 
2518
.PP
 
2519
Total upload test syntax:
 
2520
.PP
 
2521
.Vb 1
 
2522
\& IF TOTAL UPLOAD operator value PACKETS IN LAST number timeunit THEN action
 
2523
.Ve
 
2524
.PP
 
2525
Total download test syntax:
 
2526
.PP
 
2527
.Vb 1
 
2528
\& IF TOTAL DOWNLOAD operator value PACKETS IN LAST number timeunit THEN action
 
2529
.Ve
 
2530
.PP
 
2531
\&\fIoperator\fR is a choice of \*(L"<\*(R",\*(L">\*(R",\*(L"!=\*(R",\*(L"==\*(R" in c notation, \*(L"gt\*(R",
 
2532
\&\*(L"lt\*(R", \*(L"eq\*(R", \*(L"ne\*(R" in shell sh notation and \*(L"greater\*(R", \*(L"less\*(R",
 
2533
\&\*(L"equal\*(R", \*(L"notequal\*(R" in human readable form (if not specified,
 
2534
default is \s-1EQUAL\s0).
 
2535
.PP
 
2536
\&\fItimeunit\fR is a choice of \*(L"\s-1MINUTE\s0(S)\*(R", \*(L"\s-1HOUR\s0(S)\*(R", \*(L"\s-1DAY\s0\*(R".
 
2537
\&\s-1NOTE:\s0 Monit keeps total upload/download statistics only for last
 
2538
24 hours => the test cannot span more then one day.
 
2539
.PP
 
2540
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2541
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
 
2542
.PP
 
2543
Examples:
 
2544
        if upload > 1000 packets/s then alert
 
2545
        if total upload > 900000 packets in last hour then alert
 
2546
.SS "\s-1NETWORK\s0 \s-1PING\s0 \s-1TEST\s0"
2310
2547
.IX Subsection "NETWORK PING TEST"
2311
2548
Monit can perform a network ping test by sending \s-1ICMP\s0 echo request
2312
2549
datagram packets to a host and wait for the reply. This test can
2313
2550
only be used within a check host statement. Monit must also run as
2314
2551
the root user in order to be able to perform the ping test (because
2315
2552
a ping test must use raw sockets which usually only the super user
2316
 
is allowed to do).
 
2553
is allowed to).
2317
2554
.PP
2318
2555
Syntax:
2319
2556
.PP
2320
2557
.Vb 3
2321
2558
\&  IF FAILED PING
2322
 
\&     [COUNT number] [WITH] [TIMEOUT number SECONDS] 
 
2559
\&     [COUNT number] [WITH] [TIMEOUT number SECONDS]
2323
2560
\&  THEN action
2324
2561
.Ve
2325
2562
.PP
2330
2567
by default, send \fIthree\fR ping request packets in one cycle to
2331
2568
prevent false alarm (i.e. up to 66% packet loss is tolerated). You
2332
2569
can set the \fB\s-1COUNT\s0\fR option to a value between 1 and 20 to send more
2333
 
or less packets. If you require 100% ping success, set the count to
 
2570
or fewer packets. If you require 100% ping success, set the count to
2334
2571
1 (i.e. just one request will be sent, and if the packet was lost
2335
2572
an error will be reported).
2336
2573
.PP
2338
2575
now, in which case there will be no reply from the host.
2339
2576
.PP
2340
2577
If a ping test is used in a check host entry, this test is run first
2341
 
and if the ping test should fail, we assume that the connection to the
2342
 
host is down and Monit does \fInot\fR continue to test any ports.
 
2578
and if the test should fail, we assume that the connection to the
 
2579
host is down and Monit will \fInot\fR continue with any subsequent port
 
2580
tests.
2343
2581
.PP
2344
2582
Example:
2345
2583
.PP
2357
2595
\&           ping count 5 with timeout 10 seconds
2358
2596
\&        then alert
2359
2597
.Ve
2360
 
.SS "\s-1CONNECTION TESTING\s0"
 
2598
.SS "\s-1CONNECTION\s0 \s-1TESTING\s0"
2361
2599
.IX Subsection "CONNECTION TESTING"
2362
2600
Monit can perform connection testing via network ports or via
2363
2601
Unix sockets. A connection test may only be used within a
2370
2608
I/O, Monit will execute a specified action.
2371
2609
.PP
2372
2610
\&\s-1TCP/UDP\s0 port test syntax:
2373
 
.IP "\s-1IF FAILED \s0 [host] <port> [type] [protocol | {send/expect}+] [timeout] [retry] \s-1THEN\s0 action" 4
2374
 
.IX Item "IF FAILED [host] <port> [type] [protocol | {send/expect}+] [timeout] [retry] THEN action"
 
2611
.PP
 
2612
.Vb 8
 
2613
\& IF FAILED
 
2614
\&    [host]
 
2615
\&    <port>
 
2616
\&    [type]
 
2617
\&    [protocol | {send/expect}+]
 
2618
\&    [timeout]
 
2619
\&    [retry]
 
2620
\& THEN action
 
2621
.Ve
2375
2622
.PP
2376
2623
Unix socket test syntax:
2377
 
.IP "\s-1IF FAILED \s0 <unixsocket> [type] [protocol | {send/expect}+] [timeout] [retry] \s-1THEN\s0 action" 4
2378
 
.IX Item "IF FAILED <unixsocket> [type] [protocol | {send/expect}+] [timeout] [retry] THEN action"
 
2624
.PP
 
2625
.Vb 7
 
2626
\& IF FAILED
 
2627
\&    <unixsocket>
 
2628
\&    [type]
 
2629
\&    [protocol | {send/expect}+]
 
2630
\&    [timeout]
 
2631
\&    [retry]
 
2632
\& THEN action
 
2633
.Ve
2379
2634
.PP
2380
2635
Examples:
2381
2636
.PP
2391
2646
.PP
2392
2647
\&\fIhost: \s-1HOST\s0 hostname\fR. Optionally specify the host to connect to.
2393
2648
If the host is not given then localhost is assumed if this test
2394
 
is used inside a process entry. If this test was used inside a
 
2649
is used inside a process entry. If this test is used inside a
2395
2650
remote host entry then the entry's remote host is assumed.
2396
2651
.PP
2397
2652
\&\fIport: \s-1PORT\s0 number\fR. The port number to connect to
2401
2656
.PP
2402
2657
\&\fItype: \s-1TYPE\s0 {TCP|UDP|TCPSSL}\fR. Optionally specify the socket type
2403
2658
Monit should use when trying to connect to the port. The
2404
 
different socket types are; \s-1TCP, UDP\s0 or \s-1TCPSSL,\s0 where \s-1TCP\s0 is a
 
2659
different socket types are; \s-1TCP\s0, \s-1UDP\s0 or \s-1TCPSSL\s0, where \s-1TCP\s0 is a
2405
2660
regular stream based socket, \s-1UDP\s0 is a datagram socket and \s-1TCPSSL\s0
2406
2661
specifies that Monit should use a \s-1TCP\s0 socket with \s-1SSL\s0 when
2407
 
connecting to a port. The default socket type is \s-1TCP.\s0 If \s-1TCPSSL\s0
 
2662
connecting to a port. The default socket type is \s-1TCP\s0. If \s-1TCPSSL\s0
2408
2663
is used you may optionally specify the \s-1SSL/TLS\s0 protocol to be
2409
2664
used and the \s-1MD5\s0 checksum of the server's certificate.
2410
2665
.PP
2415
2670
.Ve
2416
2671
.PP
2417
2672
The default mode is \fI\s-1SSLAUTO\s0\fR and it will select the method
2418
 
automatically, but note that for security reasons it supports \s-1TLS\s0
2419
 
methods only. If you need SSLv2 or SSLv3 you have to explicitly select
2420
 
that method using \fI\s-1SSLV2\s0\fR or \fI\s-1SSLV3\s0\fR option.
 
2673
automatically, but for security reasons only \s-1TLS\s0 is used, not \s-1SSL\s0. If
 
2674
you need SSLv2 or SSLv3 you have to explicitly select that method using
 
2675
\&\fI\s-1SSLV2\s0\fR or \fI\s-1SSLV3\s0\fR option.
2421
2676
.PP
2422
2677
\&\fIprotocol: \s-1PROTO\s0(\s-1COL\s0) protocol\fR. Optionally specify the protocol
2423
2678
Monit should speak when a connection is established. At the
2447
2702
 \fI\s-1RDATE\s0\fR
2448
2703
 \fI\s-1REDIS\s0\fR
2449
2704
 \fI\s-1RSYNC\s0\fR
 
2705
 \fI\s-1SIEVE\s0\fR
2450
2706
 \fI\s-1SIP\s0\fR
2451
2707
 \fI\s-1SMTP\s0\fR
2452
2708
 \fI\s-1SMTPS\s0\fR
2468
2724
retries within the same testing cycle in the case that the
2469
2725
connection failed. The default is fail on first error.
2470
2726
.PP
2471
 
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\*(R", \*(L"RESTART\*(R", \*(L"START\*(R", \*(L"STOP\*(R",
2472
 
\&\*(L"EXEC\*(R"\s0 or \*(L"\s-1UNMONITOR\*(R".\s0
 
2727
\&\fIaction\fR is a choice of \*(L"\s-1ALERT\s0\*(R", \*(L"\s-1RESTART\s0\*(R", \*(L"\s-1START\s0\*(R", \*(L"\s-1STOP\s0\*(R",
 
2728
\&\*(L"\s-1EXEC\s0\*(R" or \*(L"\s-1UNMONITOR\s0\*(R".
2473
2729
.PP
2474
2730
\fISpecific protocol test options\fR
2475
2731
.IX Subsection "Specific protocol test options"
2476
2732
.PP
2477
 
\s-1GENERIC \s0(\s-1SEND/EXPECT\s0)
 
2733
\s-1GENERIC\s0 (\s-1SEND/EXPECT\s0)
2478
2734
.IX Subsection "GENERIC (SEND/EXPECT)"
2479
2735
.PP
2480
2736
If Monit does not support the protocol spoken by the server,
2506
2762
Max value for the expect buffer is 100 kb. For example, to set
2507
2763
the expect buffer to read 10 kilobytes:
2508
2764
.PP
2509
 
set expectbuffer 10 kb
 
2765
.Vb 1
 
2766
\& set expectbuffer 10 kb
 
2767
.Ve
2510
2768
.PP
2511
2769
You can use non-printable characters in a \s-1SEND\s0 string if needed.
2512
2770
Use the hex notation, \e0xHEXHEX to send any char in the range
2538
2796
Here is a simple \s-1SMTP\s0 protocol example:
2539
2797
.PP
2540
2798
.Vb 7
2541
 
\& if failed 
 
2799
\& if failed
2542
2800
\&    port 25 and
2543
2801
\&    expect "^220.*"
2544
2802
\&    send   "HELO localhost.localdomain\er\en"
2564
2822
\&     [CONTENT {= | != } STRING]
2565
2823
.Ve
2566
2824
.PP
2567
 
\&\fI\s-1REQUEST\s0\fR option can set an \s-1URI\s0 string specifying a document on the
 
2825
\&\fI\s-1REQUEST\s0\fR option can set an \s-1URL\s0 string specifying a document on the
2568
2826
\&\s-1HTTP\s0 server. If the request statement isn't specified, the default \*(L"/\*(R"
2569
2827
page will be requested.
2570
2828
.PP
2571
2829
For example:
2572
2830
.PP
2573
2831
.Vb 5
2574
 
\& if failed 
 
2832
\& if failed
2575
2833
\&    port 80
2576
2834
\&    protocol http
2577
2835
\&    request "/data/show?a=b&c=d"
2578
2836
\& then restart
2579
2837
.Ve
2580
2838
.PP
2581
 
\&\fI\s-1STATUS\s0\fR option can be used to explicitly test the \s-1HTTP\s0 status 
2582
 
code returned by the \s-1HTTP\s0 server. If not used, the http protocol test
2583
 
will fail if the status code returned is greater than or equal to 400. 
2584
 
You can override this behaviour by using the \fIstatus\fR qualifier.
 
2839
\&\fI\s-1STATUS\s0\fR option can be used to explicitly test the \s-1HTTP\s0 status code
 
2840
returned by the \s-1HTTP\s0 server. If not used, the http protocol test will
 
2841
fail if the status code returned is greater than or equal to 400. You
 
2842
can override this behaviour by using the \fIstatus\fR qualifier.
2585
2843
.PP
2586
 
For example to test that a page does \fBnot\fR exist (404 should be returned
2587
 
in this case):
 
2844
For example to test that a page does \fBnot\fR exist (the \s-1HTTP\s0 server
 
2845
should return 404 in this case):
2588
2846
.PP
2589
2847
.Vb 6
2590
2848
\&  if failed
2595
2853
\&  then alert
2596
2854
.Ve
2597
2855
.PP
2598
 
\&\fI\s-1CHECKSUM\s0\fR You can test the checksum for documents returned by a \s-1HTTP\s0
 
2856
\&\fI\s-1CHECKSUM\s0\fR You can test the checksum of documents returned by a \s-1HTTP\s0
2599
2857
server. Either \s-1MD5\s0 or \s-1SHA1\s0 hash can be used. Monit will \fBnot\fR test the
2600
 
checksum for a document if the server does not set the \s-1HTTP
2601
 
\&\s0\fIContent-Length\fR header. A \s-1HTTP\s0 server should set this header when it
 
2858
checksum for a document if the server does not set the \s-1HTTP\s0
 
2859
\&\fIContent-Length\fR header. A \s-1HTTP\s0 server should set this header when it
2602
2860
server a static document (i.e. a file). There are no limitation on the
2603
2861
document size, but keep in mind that Monit will use time to download the
2604
 
document over the network.
 
2862
document over the network to compute the checksum.
2605
2863
.PP
2606
2864
Example:
2607
2865
.PP
2608
2866
.Vb 6
2609
 
\& if failed 
 
2867
\& if failed
2610
2868
\&    port 80
2611
2869
\&    protocol http
2612
 
\&    request "/page.html" 
 
2870
\&    request "/page.html"
2613
2871
\&    checksum 8f7f419955cefa0b33a2ba316cba3659
2614
2872
\& then alert
2615
2873
.Ve
2616
2874
.PP
2617
 
\&\fI\s-1HTTP HEADERS\s0\fR can be used to send a list of any \s-1HTTP\s0 headers
 
2875
\&\fI\s-1HTTP\s0 \s-1HEADERS\s0\fR can be used to send a list of any \s-1HTTP\s0 headers
2618
2876
with a http protocol test. For instance, the host header. If the
2619
2877
host header is not set, Monit will use the hostname or IP-address
2620
 
of the host as specified in the check host statement. Specifying 
2621
 
a host header is useful if you want to connect to and test a 
 
2878
of the host as specified in the check host statement. Specifying
 
2879
a host header is useful if you want to connect to and test a
2622
2880
name-based virtual host. The syntax for setting \s-1HTTP\s0 headers is
2623
2881
.PP
2624
2882
.Vb 1
2701
2959
Example:
2702
2960
.PP
2703
2961
.Vb 5
2704
 
\& if failed port 80 protocol apache\-status 
 
2962
\& if failed port 80 protocol apache\-status
2705
2963
\&        loglimit > 10% or
2706
2964
\&        dnslimit > 50% or
2707
2965
\&        waitlimit < 20%
2726
2984
\&\fI\s-1MAXFORWARD\s0\fR Limit the number of proxies or gateways that can forward the
2727
2985
request to the next server. It's value is an integer in the range
2728
2986
0\-255, set by default to 70. If max-forward = 0, the next server
2729
 
may respond 200 \s-1OK \s0(test succeeded) or send a 483 Too Many Hops
 
2987
may respond 200 \s-1OK\s0 (test succeeded) or send a 483 Too Many Hops
2730
2988
(test failed)
2731
2989
.PP
2732
2990
For example:
2733
2991
.PP
2734
2992
.Vb 5
2735
2993
\& check host openser_all with address 127.0.0.1
2736
 
\&   if failed 
 
2994
\&   if failed
2737
2995
\&      port 5060 type udp protocol sip
2738
2996
\&      with target "localhost:5060" and maxforward 6
2739
2997
\&   then alert
2756
3014
\& check process radiusd with pidfile /var/run/radiusd.pid
2757
3015
\&       start program = "/etc/init.d/freeradius start"
2758
3016
\&       stop program = "/etc/init.d/freeradius stop"
2759
 
\&       if failed 
 
3017
\&       if failed
2760
3018
\&          host 127.0.0.1 port 1812 type udp protocol radius
2761
 
\&          secret testing123
 
3019
\&          secret pingpong
2762
3020
\&       then alert
2763
3021
.Ve
2764
3022
.PP
2821
3079
.PP
2822
3080
Here's a more advanced example for monitoring an apache
2823
3081
web-server listening on the default port number for \s-1HTTP\s0 and
2824
 
\&\s-1HTTPS.\s0 In this example Monit will restart apache if it's not
 
3082
\&\s-1HTTPS\s0. In this example Monit will restart apache if it's not
2825
3083
accepting connections at the port numbers. The method Monit use
2826
3084
for a process restart is to first execute the stop-program, wait
2827
3085
up to 30s for the process to stop and then execute the start-program
2834
3092
\& check process apache with pidfile /var/run/httpd.pid
2835
3093
\&       start program = "/etc/init.d/httpd start" with timeout 60 seconds
2836
3094
\&       stop program  = "/etc/init.d/httpd stop"
2837
 
\&       if failed port 80 then restart
2838
 
\&       if failed port 443 with timeout 15 seconds then restart
 
3095
\&       if failed port 80 for 2 cycles then restart
 
3096
\&       if failed port 443 for 2 cycles with timeout 15 seconds then restart
2839
3097
.Ve
2840
3098
.PP
2841
3099
This example demonstrate how you can run a program as a specified
2851
3109
.PP
2852
3110
.Vb 7
2853
3111
\& check process tomcat with pidfile /var/run/tomcat.pid
2854
 
\&       start program = "/etc/init.d/tomcat start" 
 
3112
\&       start program = "/etc/init.d/tomcat start"
2855
3113
\&             as uid nobody and gid nobody
2856
3114
\&       stop program  = "/etc/init.d/tomcat stop"
2857
3115
\&             # You can also use id numbers instead and write:
2884
3142
localhost that answers for several IP-based virtual hosts or
2885
3143
vhosts, hence the host statement before port:
2886
3144
.PP
2887
 
.Vb 7
 
3145
.Vb 6
2888
3146
\& check process apache with pidfile /var/run/httpd.pid
2889
3147
\&       start "/etc/init.d/httpd start"
2890
3148
\&       stop  "/etc/init.d/httpd stop"
2891
3149
\&       if failed host www.sol.no port 80 then alert
2892
3150
\&       if failed host shop.sol.no port 443 then alert
2893
3151
\&       if failed host chat.sol.no port 80 then alert
2894
 
\&       if failed host www.tildeslash.com port 80 then alert
2895
3152
.Ve
2896
3153
.PP
2897
3154
To make sure that Monit is communicating with a http server a
2901
3158
\& check process apache with pidfile /var/run/httpd.pid
2902
3159
\&       start "/etc/init.d/httpd start"
2903
3160
\&       stop  "/etc/init.d/httpd stop"
2904
 
\&       if failed 
 
3161
\&       if failed
2905
3162
\&          host www.sol.no port 80 protocol http
2906
3163
\&       then alert
2907
3164
.Ve
2913
3170
\& check process apache with pidfile /var/run/httpd.pid
2914
3171
\&       start "/etc/init.d/httpd start"
2915
3172
\&       stop  "/etc/init.d/httpd stop"
2916
 
\&       if failed 
 
3173
\&       if failed
2917
3174
\&          host www.sol.no port 80 and
2918
3175
\&          send "GET / HTTP/1.1\er\enHost: www.sol.no\er\en\er\en"
2919
3176
\&          expect "HTTP/[0\-9\e.]{3} 200.*"
2950
3207
.PP
2951
3208
.Vb 6
2952
3209
\& check host tildeslash with address www.tildeslash.com
2953
 
\&       if failed 
2954
 
\&          port 80 protocol http and 
 
3210
\&       if failed
 
3211
\&          port 80 protocol http and
2955
3212
\&          request "/monit/dist/monit\-5.7.tar.gz"
2956
3213
\&          with checksum f9d26b8393736b5dfad837bb13780786
2957
3214
\&       then alert
2962
3219
server and then an Asterisk server
2963
3220
.PP
2964
3221
.Vb 12
2965
 
\& check process freeswitch 
 
3222
\& check process freeswitch
2966
3223
\&    with pidfile /usr/local/freeswitch/log/freeswitch.pid
2967
3224
\&  start program = "/usr/local/freeswitch/bin/freeswitch \-nc \-hp"
2968
3225
\&  stop program = "/usr/local/freeswitch/bin/freeswitch \-stop"
2970
3227
\&  if total memory > 1500.0 MB for 5 cycles then alert
2971
3228
\&  if total memory > 2000.0 MB for 5 cycles then restart
2972
3229
\&  if cpu > 60% for 5 cycles then alert
2973
 
\&  if failed 
 
3230
\&  if failed
2974
3231
\&     port 5060 type udp protocol SIP
2975
 
\&     target me@foo.bar and maxforward 10 
 
3232
\&     target me@foo.bar and maxforward 10
2976
3233
\&  then restart
2977
3234
\&
2978
 
\& check process asterisk 
 
3235
\& check process asterisk
2979
3236
\&   with pidfile /var/run/asterisk/asterisk.pid
2980
3237
\&   start program = "/usr/sbin/asterisk"
2981
3238
\&   stop program = "/usr/sbin/asterisk \-r \-x \*(Aqshutdown now\*(Aq"
2983
3240
\&   if total memory > 1500.0 MB for 5 cycles then alert
2984
3241
\&   if total memory > 2000.0 MB for 5 cycles then restart
2985
3242
\&   if cpu > 60% for 5 cycles then alert
2986
 
\&   if failed 
 
3243
\&   if failed
2987
3244
\&      port 5060 type udp protocol SIP
2988
3245
\&      and target me@foo.bar maxforward 10
2989
3246
\&   then restart
3018
3275
\&       start program = "/etc/init.d/oracle start"
3019
3276
\&       stop program  = "/etc/init.d/oracle stop"
3020
3277
\&       mode active # Not necessary really, since it\*(Aqs the default
3021
 
\&       if failed 
 
3278
\&       if failed
3022
3279
\&          port 9001 protocol tns
3023
3280
\&       then restart
3024
3281
\&       group database
3059
3316
\& check process apache with pidfile /var/run/httpd.pid
3060
3317
\&      start = "/etc/init.d/httpd start"
3061
3318
\&      stop  = "/etc/init.d/httpd stop"
3062
 
\&      alert admin@bar on {nonexist, timeout} 
3063
 
\&        with mail\-format { 
 
3319
\&      alert admin@bar on {nonexist, timeout}
 
3320
\&        with mail\-format {
3064
3321
\&              from:     bofh@$HOST
3065
3322
\&              subject:  apache $EVENT \- $ACTION
3066
 
\&              message:  This event occurred on $HOST at $DATE. 
 
3323
\&              message:  This event occurred on $HOST at $DATE.
3067
3324
\&              Your faithful employee,
3068
3325
\&              monit
3069
3326
\&      }
3073
3330
\&      group apache
3074
3331
\&
3075
3332
\& check file httpd_bin with path /usr/local/apache/bin/httpd
3076
 
\&       alert security@bar on {checksum, timestamp, 
 
3333
\&       alert security@bar on {checksum, timestamp,
3077
3334
\&                  permission, uid, gid}
3078
3335
\&             with mail\-format {subject: Alaaarrm! on $HOST}
3079
 
\&       if failed checksum 
 
3336
\&       if failed checksum
3080
3337
\&          and expect 8f7f419955cefa0b33a2ba316cba3659
3081
3338
\&              then unmonitor
3082
3339
\&       if failed permission 755 then unmonitor
3113
3370
\&       stop  = "/etc/init.d/oracle stop"
3114
3371
\&       if failed port 9001 for 3 cycles then restart
3115
3372
\&
3116
 
\& check process oracle\-import 
 
3373
\& check process oracle\-import
3117
3374
\&      with pidfile /var/run/oracle\-import.pid
3118
3375
\&       start = "/etc/init.d/oracle\-import start"
3119
3376
\&       stop  = "/etc/init.d/oracle\-import stop"
3120
3377
\&       depends on oracle
3121
3378
\&
3122
 
\& check process oracle\-export 
 
3379
\& check process oracle\-export
3123
3380
\&      with pidfile /var/run/oracle\-export.pid
3124
3381
\&       start = "/etc/init.d/oracle\-export start"
3125
3382
\&       stop  = "/etc/init.d/oracle\-export stop"
3127
3384
.Ve
3128
3385
.SH "FILES"
3129
3386
.IX Header "FILES"
3130
 
\&\fI~/.monitrc\fR  
 
3387
\&\fI~/.monitrc\fR
3131
3388
   Default run control file
3132
3389
.PP
3133
3390
\&\fI/etc/monitrc\fR
3134
 
   If the control file is not found in the default 
 
3391
   If the control file is not found in the default
3135
3392
   location and /etc contains a \fImonitrc\fR file, this
3136
3393
   file will be used instead.
3137
3394
.PP
3138
 
\&\fI./monitrc\fR  
 
3395
\&\fI./monitrc\fR
3139
3396
   If the control file is not found in either of the
3140
 
   previous two locations, and the current working 
3141
 
   directory contains a \fImonitrc\fR file, this file is 
 
3397
   previous two locations, and the current working
 
3398
   directory contains a \fImonitrc\fR file, this file is
3142
3399
   used instead.
3143
3400
.PP
3144
3401
\&\fI~/.monit.pid\fR
3157
3414
   Lock file to help prevent concurrent runs (root mode,
3158
3415
   systems without /var/run).
3159
3416
.PP
3160
 
\&\fI~/.monit.state\fR  
 
3417
\&\fI~/.monit.state\fR
3161
3418
   Monit saves its state to this file and utilizes
3162
 
   information found in this file to recover from 
3163
 
   a crash. This is a binary file and its content is 
 
3419
   information found in this file to recover from
 
3420
   a crash. This is a binary file and its content is
3164
3421
   only of interest to monit. You may set the location
3165
 
   of this file in the Monit control file or by using 
 
3422
   of this file in the Monit control file or by using
3166
3423
   the \-s switch when Monit is started.
3167
3424
.PP
3168
 
\&\fI~/.monit.id\fR  
 
3425
\&\fI~/.monit.id\fR
3169
3426
    Monit save its unique id to this file.
3170
3427
.SH "ENVIRONMENT"
3171
3428
.IX Header "ENVIRONMENT"
3185
3442
occurred.
3186
3443
.IP "\s-1MONIT_DATE\s0" 4
3187
3444
.IX Item "MONIT_DATE"
3188
 
The time and date (\s-1RFC 822\s0 style) the event occurred
 
3445
The time and date (\s-1RFC\s0 822 style) the event occurred
3189
3446
.IP "\s-1MONIT_HOST\s0" 4
3190
3447
.IX Item "MONIT_HOST"
3191
3448
The host the event occurred on
3192
3449
.PP
3193
3450
The following environment variables are only available for
3194
3451
process service entries:
3195
 
.IP "\s-1MONIT_PROCESS_PID \s0" 4
3196
 
.IX Item "MONIT_PROCESS_PID "
 
3452
.IP "\s-1MONIT_PROCESS_PID\s0" 4
 
3453
.IX Item "MONIT_PROCESS_PID"
3197
3454
The process pid. This may be 0 if the process was (re)started,
3198
 
.IP "\s-1MONIT_PROCESS_MEMORY \s0" 4
3199
 
.IX Item "MONIT_PROCESS_MEMORY "
 
3455
.IP "\s-1MONIT_PROCESS_MEMORY\s0" 4
 
3456
.IX Item "MONIT_PROCESS_MEMORY"
3200
3457
Process memory. This may be 0 if the process was (re)started,
3201
 
.IP "\s-1MONIT_PROCESS_CHILDREN \s0" 4
3202
 
.IX Item "MONIT_PROCESS_CHILDREN "
 
3458
.IP "\s-1MONIT_PROCESS_CHILDREN\s0" 4
 
3459
.IX Item "MONIT_PROCESS_CHILDREN"
3203
3460
Process children. This may be 0 if the process was (re)started,
3204
 
.IP "\s-1MONIT_PROCESS_CPU_PERCENT \s0" 4
3205
 
.IX Item "MONIT_PROCESS_CPU_PERCENT "
 
3461
.IP "\s-1MONIT_PROCESS_CPU_PERCENT\s0" 4
 
3462
.IX Item "MONIT_PROCESS_CPU_PERCENT"
3206
3463
Process cpu%. This may be 0 if the process was (re)started,
3207
3464
.SH "SIGNALS"
3208
3465
.IX Header "SIGNALS"