10 |
|
|
11 |
<p>Updated for release 4.6 |
<p>Updated for release 4.6 |
12 |
|
|
|
|
|
13 |
<p><a name="__index__"></a></p> |
<p><a name="__index__"></a></p> |
14 |
<!-- INDEX BEGIN --> |
<!-- INDEX BEGIN --> |
15 |
|
|
51 |
<li><a href="#file_checksum_testing">FILE CHECKSUM TESTING</a></li> |
<li><a href="#file_checksum_testing">FILE CHECKSUM TESTING</a></li> |
52 |
<li><a href="#timestamp_testing">TIMESTAMP TESTING</a></li> |
<li><a href="#timestamp_testing">TIMESTAMP TESTING</a></li> |
53 |
<li><a href="#file_size_testing">FILE SIZE TESTING</a></li> |
<li><a href="#file_size_testing">FILE SIZE TESTING</a></li> |
54 |
<li><a href="#space_testing">SPACE TESTING</a></li> |
<li><a href="#file_content_testing">FILE CONTENT TESTING</a></li> |
55 |
<li><a href="#space_testing">SPACE TESTING</a></li> |
<li><a href="#space_testing">SPACE TESTING</a></li> |
56 |
<li><a href="#inode_testing">INODE TESTING</a></li> |
<li><a href="#inode_testing">INODE TESTING</a></li> |
57 |
<li><a href="#permission_testing">PERMISSION TESTING</a></li> |
<li><a href="#permission_testing">PERMISSION TESTING</a></li> |
829 |
action. General format:</p> |
action. General format:</p> |
830 |
<dl> |
<dl> |
831 |
<dt><strong><a name="item_if__3ctest_3e__5b_5b_3cx_3e_5d__5btimes_within_5d_">IF <TEST> [[<X>] [TIMES WITHIN] <Y> CYCLES] THEN ACTION |
<dt><strong><a name="item_if__3ctest_3e__5b_5b_3cx_3e_5d__5btimes_within_5d_">IF <TEST> [[<X>] [TIMES WITHIN] <Y> CYCLES] THEN ACTION |
832 |
[ELSE IF RECOVERED [[<X>] [TIMES WITHIN] <Y> CYCLES] THEN ACTION]</a></strong><br /> |
[ELSE IF PASSED [[<X>] [TIMES WITHIN] <Y> CYCLES] THEN ACTION]</a></strong><br /> |
833 |
</dt> |
</dt> |
834 |
</dl> |
</dl> |
835 |
<p>For constant object tests if the <TEST> should validate to true, |
<p>For constant object tests if the <TEST> should validate to true, |
836 |
then the selected action is executed each cycle the condition |
then the selected action is executed each cycle the condition |
837 |
remains true. The value for comparision is constant. Recovery |
remains true. The value for comparision is constant. Recovery |
838 |
action is evalueated only once (on failed->recovered state change |
action is evalueated only once (on failed->passed state change |
839 |
only). The 'ELSE IF RECOVERED' part is optional - if omitted, |
only). The 'ELSE IF PASSED' part is optional - if omitted, |
840 |
monit will do alert action on recovery by default. The alert is |
monit will do alert action on recovery by default. The alert is |
841 |
delivered only once on each state change unless overriden by |
delivered only once on each state change unless overriden by |
842 |
'reminder' alert option.</p> |
'reminder' alert option.</p> |
963 |
statements in [brackets]),</p> |
statements in [brackets]),</p> |
964 |
<dl> |
<dl> |
965 |
<dt><strong><a name="item_if_resource_operator_value__5b_5b_3cx_3e_5d__3cy_3">IF resource operator value [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_resource_operator_value__5b_5b_3cx_3e_5d__3cy_3">IF resource operator value [[<X>] <Y> CYCLES] THEN action |
966 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
967 |
</dt> |
</dt> |
968 |
</dl> |
</dl> |
969 |
<p><em>resource</em> is a choice of ``CPU'', ``MEMORY'', ``CHILDREN'', |
<p><em>resource</em> is a choice of ``CPU'', ``MEMORY'', ``CHILDREN'', |
1008 |
file does not change. Syntax (keywords are in capital):</p> |
file does not change. Syntax (keywords are in capital):</p> |
1009 |
<dl> |
<dl> |
1010 |
<dt><strong><a name="item_if_failed__5bmd5_7csha1_5d_checksum__5bexpect_chec">IF FAILED [MD5|SHA1] CHECKSUM [EXPECT checksum] [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_failed__5bmd5_7csha1_5d_checksum__5bexpect_chec">IF FAILED [MD5|SHA1] CHECKSUM [EXPECT checksum] [[<X>] <Y> CYCLES] THEN action |
1011 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1012 |
</dt> |
</dt> |
1013 |
</dl> |
</dl> |
1014 |
<p>The checksum test in variable form is used to watch for |
<p>The checksum test in variable form is used to watch for |
1059 |
timestamp conditions. Syntax (keywords are in capital):</p> |
timestamp conditions. Syntax (keywords are in capital):</p> |
1060 |
<dl> |
<dl> |
1061 |
<dt><strong><a name="item_if_timestamp__5b_5boperator_5d_value__5bunit_5d_5d">IF TIMESTAMP [[operator] value [unit]] [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_timestamp__5b_5boperator_5d_value__5bunit_5d_5d">IF TIMESTAMP [[operator] value [unit]] [[<X>] <Y> CYCLES] THEN action |
1062 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1063 |
</dt> |
</dt> |
1064 |
</dl> |
</dl> |
1065 |
<p>The timestamp statement in variable form is simply to test an |
<p>The timestamp statement in variable form is simply to test an |
1134 |
size conditions. Syntax (keywords are in capital):</p> |
size conditions. Syntax (keywords are in capital):</p> |
1135 |
<dl> |
<dl> |
1136 |
<dt><strong><a name="item_if_size__5b_5boperator_5d_value__5bunit_5d_5d__5b_">IF SIZE [[operator] value [unit]] [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_size__5b_5boperator_5d_value__5bunit_5d_5d__5b_">IF SIZE [[operator] value [unit]] [[<X>] <Y> CYCLES] THEN action |
1137 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1138 |
</dt> |
</dt> |
1139 |
</dl> |
</dl> |
1140 |
<p>The size statement in variable form is simply to test an existing |
<p>The size statement in variable form is simply to test an existing |
1203 |
if size != 95564 then exec "/sbin/ifconfig eth0 down"</pre> |
if size != 95564 then exec "/sbin/ifconfig eth0 down"</pre> |
1204 |
<p> |
<p> |
1205 |
</p> |
</p> |
1206 |
<h2><a name="space_testing">SPACE TESTING</a></h2> |
<h2><a name="file_content_testing">FILE CONTENT TESTING</a></h2> |
1207 |
<p>The match statement allows to check lines of file content against |
<p>The match statement allows you to test the content of a text |
1208 |
a regular expression (regex). In case of a match a action like |
file by using regular expressions. This is a great feature if |
1209 |
an alarm is triggered. Syntax (keywords are in capital):</p> |
you need to periodically test files, such as log files, for |
1210 |
|
certain patterns. If a pattern match, monit defaults to |
1211 |
|
raise an alert, other actions are also possible.</p> |
1212 |
|
<p>The syntax (keywords in capital) for using this function is:</p> |
1213 |
<dl> |
<dl> |
1214 |
<dt><strong><a name="item_if__5bnot_5d_match__7bregex_7cpath_7d__5b_5b_3cx_3">IF [NOT] MATCH {regex|path} [[<X>] <Y> CYCLES] THEN action</a></strong><br /> |
<dt><strong><a name="item_if__5bnot_5d_match__7bregex_7cpath_7d__5b_5b_3cx_3">IF [NOT] MATCH {regex|path} [[<X>] <Y> CYCLES] THEN action</a></strong><br /> |
1215 |
</dt> |
</dt> |
1221 |
<p><em>action</em> is a choice of ``ALERT'', ``RESTART'', ``START'', ``STOP'', |
<p><em>action</em> is a choice of ``ALERT'', ``RESTART'', ``START'', ``STOP'', |
1222 |
``EXEC'', ``MONITOR'' or ``UNMONITOR''.</p> |
``EXEC'', ``MONITOR'' or ``UNMONITOR''.</p> |
1223 |
<p>You can use the <em>NOT</em> statement to invert a match.</p> |
<p>You can use the <em>NOT</em> statement to invert a match.</p> |
1224 |
<p>The content is only being checked every cycle. If content is |
<p>The content is only being checked every cycle. If content is |
1225 |
being added and removed during between two check they are |
being added and removed between two checks they are unnoticed.</p> |
1226 |
unnoticed.</p> |
<p>On startup the read position is set to the end of the file |
1227 |
<p>On startup the read position is the file end. Upon file size |
and monit continue to scan to the end of file on each cycle. |
1228 |
decrease and inode change the read position is set to the file |
But if the file size should decrease or inode change the read |
1229 |
start.</p> |
position is set to the start of the file.</p> |
1230 |
<p>Only lines ending with a newline character are inspected. Thus, |
<p>Only lines ending with a newline character are inspected. Thus, |
1231 |
lines are being ignored until they have been completed with this |
lines are being ignored until they have been completed with this |
1232 |
character.</p> |
character. Also note that only the first 511 characters of a |
1233 |
<p>Only the first 511 characters of a line are inspected any |
line are inspected.</p> |
|
following is omitted.</p> |
|
1234 |
<dl> |
<dl> |
1235 |
<dt><strong><a name="item_ignore__5bnot_5d_match__7bregex_7cpath_7d">IGNORE [NOT] MATCH {regex|path}</a></strong><br /> |
<dt><strong><a name="item_ignore__5bnot_5d_match__7bregex_7cpath_7d">IGNORE [NOT] MATCH {regex|path}</a></strong><br /> |
1236 |
</dt> |
</dt> |
1237 |
</dl> |
</dl> |
1238 |
<p>Lines matching an <em>IGNORE</em> are not inspected for later matches. |
<p>Lines matching an <em>IGNORE</em> are not inspected during later |
1239 |
<em>IGNORE MATCH</em> has always precedence over <em>IF MATCH</em>.</p> |
evaluations. <em>IGNORE MATCH</em> has always precedence over |
1240 |
<p>In first all <em>IGNORE MATCH</em> statements are evaluated in the |
<em>IF MATCH</em>.</p> |
1241 |
order of there appearance. In second all <em>IF MATCH</em> statements |
<p>All <em>IGNORE MATCH</em> statements are evaluated first, in the |
1242 |
are evaluated.</p> |
order of their appearance. Thereafter, all the <em>IF MATCH</em> |
1243 |
|
statements are evaluated.</p> |
1244 |
<p>A real life example might look like this:</p> |
<p>A real life example might look like this:</p> |
1245 |
<pre> |
<pre> |
1246 |
check file syslog with path /var/log/syslog |
check file syslog with path /var/log/syslog |
1247 |
ignore match |
ignore match |
1248 |
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ monit\[[0-9]+\]:" |
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ monit\[[0-9]+\]:" |
1249 |
ignore match /etc/monit/syslog.regex.ignore |
ignore match /etc/monit/ignore.regex |
1250 |
if match |
if match |
1251 |
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ mrcoffee\[[0-9]+\]:" |
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ mrcoffee\[[0-9]+\]:" |
1252 |
if match /etc/monit/syslog.regex.alert then alert</pre> |
if match /etc/monit/active.regex then alert</pre> |
1253 |
<p> |
<p> |
1254 |
</p> |
</p> |
1255 |
<h2><a name="space_testing">SPACE TESTING</a></h2> |
<h2><a name="space_testing">SPACE TESTING</a></h2> |
1274 |
<p>The full syntax for the space statement is:</p> |
<p>The full syntax for the space statement is:</p> |
1275 |
<dl> |
<dl> |
1276 |
<dt><strong><a name="item_if_space_operator_value_unit__5b_5b_3cx_3e_5d__3cy">IF SPACE operator value unit [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_space_operator_value_unit__5b_5b_3cx_3e_5d__3cy">IF SPACE operator value unit [[<X>] <Y> CYCLES] THEN action |
1277 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1278 |
</dt> |
</dt> |
1279 |
</dl> |
</dl> |
1280 |
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
1299 |
<p>The syntax for the inode statement is:</p> |
<p>The syntax for the inode statement is:</p> |
1300 |
<dl> |
<dl> |
1301 |
<dt><strong><a name="item_inode">IF <code>INODE(S)</code> operator value [unit] [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_inode">IF <code>INODE(S)</code> operator value [unit] [[<X>] <Y> CYCLES] THEN action |
1302 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1303 |
</dt> |
</dt> |
1304 |
</dl> |
</dl> |
1305 |
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
<p><em>operator</em> is a choice of ``<'',``>'',``!='',``=='' in c notation, ``gt'', |
1320 |
<p>The syntax for the permission statement is:</p> |
<p>The syntax for the permission statement is:</p> |
1321 |
<dl> |
<dl> |
1322 |
<dt><strong><a name="item_perm">IF FAILED <code>PERM(ISSION)</code> octalnumber [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_perm">IF FAILED <code>PERM(ISSION)</code> octalnumber [[<X>] <Y> CYCLES] THEN action |
1323 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1324 |
</dt> |
</dt> |
1325 |
</dl> |
</dl> |
1326 |
<p><em>octalnumber</em> defines permissions for a file, a directory or a |
<p><em>octalnumber</em> defines permissions for a file, a directory or a |
1349 |
<p>The syntax for the uid statement is:</p> |
<p>The syntax for the uid statement is:</p> |
1350 |
<dl> |
<dl> |
1351 |
<dt><strong><a name="item_if_failed_uid_user__5b_5b_3cx_3e_5d__3cy_3e_cycles">IF FAILED UID user [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_failed_uid_user__5b_5b_3cx_3e_5d__3cy_3e_cycles">IF FAILED UID user [[<X>] <Y> CYCLES] THEN action |
1352 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1353 |
</dt> |
</dt> |
1354 |
</dl> |
</dl> |
1355 |
<p><em>user</em> defines a user id either in numeric or in string form.</p> |
<p><em>user</em> defines a user id either in numeric or in string form.</p> |
1377 |
<p>The syntax for the gid statement is:</p> |
<p>The syntax for the gid statement is:</p> |
1378 |
<dl> |
<dl> |
1379 |
<dt><strong><a name="item_if_failed_gid_user__5b_5b_3cx_3e_5d__3cy_3e_cycles">IF FAILED GID user [[<X>] <Y> CYCLES] THEN action |
<dt><strong><a name="item_if_failed_gid_user__5b_5b_3cx_3e_5d__3cy_3e_cycles">IF FAILED GID user [[<X>] <Y> CYCLES] THEN action |
1380 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1381 |
</dt> |
</dt> |
1382 |
</dl> |
</dl> |
1383 |
<p><em>user</em> defines a group id either in numeric or in string form.</p> |
<p><em>user</em> defines a group id either in numeric or in string form.</p> |
1474 |
<dt><strong><a name="item_if_failed__5bhost_5d_port__5btype_5d__5bprotocol_7">IF FAILED [host] port [type] |
<dt><strong><a name="item_if_failed__5bhost_5d_port__5btype_5d__5bprotocol_7">IF FAILED [host] port [type] |
1475 |
[protocol|{send/expect}+] [timeout] [[<X>] <Y> CYCLES] |
[protocol|{send/expect}+] [timeout] [[<X>] <Y> CYCLES] |
1476 |
THEN action |
THEN action |
1477 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1478 |
</dt> |
</dt> |
1479 |
</dl> |
</dl> |
1480 |
<p>or for Unix sockets,</p> |
<p>or for Unix sockets,</p> |
1482 |
<dt><strong><a name="item_if_failed__5bunixsocket_5d__5btype_5d__5bprotocol_">IF FAILED [unixsocket] [type] |
<dt><strong><a name="item_if_failed__5bunixsocket_5d__5btype_5d__5bprotocol_">IF FAILED [unixsocket] [type] |
1483 |
[protocol|{send/expect}+] [timeout] [[<X>] <Y> CYCLES] |
[protocol|{send/expect}+] [timeout] [[<X>] <Y> CYCLES] |
1484 |
THEN action |
THEN action |
1485 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</a></strong><br /> |
1486 |
</dt> |
</dt> |
1487 |
</dl> |
</dl> |
1488 |
<p><strong>host:HOST hostname</strong>. Optionally specify the host to connect |
<p><strong>host:HOST hostname</strong>. Optionally specify the host to connect |
1619 |
[CONTENT {==|!=} "regular-expression"] |
[CONTENT {==|!=} "regular-expression"] |
1620 |
[TIMEOUT number SECONDS] [[<X>] <Y> CYCLES] |
[TIMEOUT number SECONDS] [[<X>] <Y> CYCLES] |
1621 |
THEN action |
THEN action |
1622 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</pre> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</pre> |
1623 |
<p>Where URL-spec is an URL on the standard form as specified in RFC |
<p>Where URL-spec is an URL on the standard form as specified in RFC |
1624 |
2396:</p> |
2396:</p> |
1625 |
<pre> |
<pre> |
1663 |
IF FAILED ICMP TYPE ECHO |
IF FAILED ICMP TYPE ECHO |
1664 |
[COUNT number] [WITH] [TIMEOUT number SECONDS] [[<X>] <Y> CYCLES] |
[COUNT number] [WITH] [TIMEOUT number SECONDS] [[<X>] <Y> CYCLES] |
1665 |
THEN action |
THEN action |
1666 |
[ELSE IF RECOVERED [[<X>] <Y> CYCLES] THEN action]</pre> |
[ELSE IF PASSED [[<X>] <Y> CYCLES] THEN action]</pre> |
1667 |
<p>The rules for action and timeout are the same as those mentioned |
<p>The rules for action and timeout are the same as those mentioned |
1668 |
above in the CONNECTION TESTING section. The count parameter |
above in the CONNECTION TESTING section. The count parameter |
1669 |
specifies how many consecutive echo requests will be send to the |
specifies how many consecutive echo requests will be send to the |
2666 |
if failed port 80 protocol http |
if failed port 80 protocol http |
2667 |
and request "/monit/dist/monit-4.0.tar.gz" |
and request "/monit/dist/monit-4.0.tar.gz" |
2668 |
with checksum f9d26b8393736b5dfad837bb13780786 |
with checksum f9d26b8393736b5dfad837bb13780786 |
2669 |
then alert with mail-format { subject: Aaaalarm! } |
then alert |
2670 |
alert hauk@tildeslash.com</pre> |
alert hauk@tildeslash.com with mail-format { subject: Aaaalarm! }</pre> |
2671 |
<p>Some servers are slow starters, like for example Java based |
<p>Some servers are slow starters, like for example Java based |
2672 |
Application Servers. So if we want to keep the poll-cycle low |
Application Servers. So if we want to keep the poll-cycle low |
2673 |
(i.e. < 60 seconds) but allow some services to take its time to |
(i.e. < 60 seconds) but allow some services to take its time to |
2863 |
if failed port 80 protocol http |
if failed port 80 protocol http |
2864 |
and request "/pub/gnu/bash/bash-2.05b.tar.gz" |
and request "/pub/gnu/bash/bash-2.05b.tar.gz" |
2865 |
with checksum 8f7f419955cefa0b33a2ba316cba3659 |
with checksum 8f7f419955cefa0b33a2ba316cba3659 |
2866 |
then alert with mail-format { |
then alert |
2867 |
subject: The gnu server may be hacked again! } |
alert rms@gnu.org with mail-format { |
2868 |
alert rms@gnu.org</pre> |
subject: The gnu server may be hacked again! }</pre> |
2869 |
<p>Note; only the <strong>check type</strong>, <strong>pidfile/path/address</strong> statements |
<p>Note; only the <strong>check type</strong>, <strong>pidfile/path/address</strong> statements |
2870 |
are mandatory, the other statements are optional and the order of |
are mandatory, the other statements are optional and the order of |
2871 |
the optional statements is not important.</p> |
the optional statements is not important.</p> |