797 |
|
|
798 |
=head1 SERVICE TESTS |
=head1 SERVICE TESTS |
799 |
|
|
800 |
Monit provides several tests you may utilize in a service |
Monit provides several tests you may utilize in a service entry |
801 |
entry to test a service. Basicaly here are two classes of tests: |
to test a service. Basicaly here are two classes of tests: |
802 |
variable and constant object tests. |
variable and constant object tests. |
803 |
|
|
804 |
Constant object tests are related to failed/passed state. |
Constant object tests are related to failed/passed state. In the |
805 |
In the case of error, monit will watch whether the failed |
case of error, monit will watch whether the failed parameter will |
806 |
parameter will recover - in such case it will handle recovery |
recover - in such case it will handle recovery related |
807 |
related action. General format: |
action. General format: |
808 |
|
|
809 |
=over 4 |
=over 4 |
810 |
|
|
813 |
=back |
=back |
814 |
|
|
815 |
For constant object tests if the <TEST> should validate to true, |
For constant object tests if the <TEST> should validate to true, |
816 |
then the selected action is executed each cycle the condition remains |
then the selected action is executed each cycle the condition |
817 |
true. The value for comparision is constant. Recovery action is |
remains true. The value for comparision is constant. Recovery |
818 |
evalueated only once (on failed->recovered state change only). The |
action is evalueated only once (on failed->recovered state change |
819 |
'ELSE IF RECOVERED' part is optional - if omitted, monit will do alert |
only). The 'ELSE IF RECOVERED' part is optional - if omitted, |
820 |
action on recovery by default. The alert is delivered once on each |
monit will do alert action on recovery by default. The alert is |
821 |
state change regardless of state change direction). |
delivered once on each state change regardless of state change |
822 |
|
direction). |
823 |
|
|
824 |
Variable object tests beggins with 'IF CHANGED' statement and serves |
|
825 |
for monitoring of object, which property can change legaly - monit |
Variable object tests beggins with 'IF CHANGED' statement and |
826 |
watches whether the value will change again. You can use it just |
serves for monitoring of object, which property can change legaly |
827 |
for alert or to involve some automatic action, as for example to |
- monit watches whether the value will change again. You can use |
828 |
reload monitored process after its configuration file was changed. |
it just for alert or to involve some automatic action, as for |
829 |
Variable tests are supported for 'checksum', 'size', 'pid, 'ppid' |
example to reload monitored process after its configuration file |
830 |
and 'timestamp' tests only, if you consider that other tests can |
was changed. Variable tests are supported for 'checksum', |
831 |
be useful in variable form too, please let us know. |
'size', 'pid, 'ppid' and 'timestamp' tests only, if you consider |
832 |
|
that other tests can be useful in variable form too, please let |
833 |
|
us know. |
834 |
|
|
835 |
=over 4 |
=over 4 |
836 |
|
|
838 |
|
|
839 |
=back |
=back |
840 |
|
|
841 |
For variable object tests if the <TEST> should validate to true, then |
For variable object tests if the <TEST> should validate to true, |
842 |
the selected action is executed once and monit will watch for another |
then the selected action is executed once and monit will watch |
843 |
change. The value for comparision is variable - the last result becomes |
for another change. The value for comparision is variable - the |
844 |
actual value, which is compared in future cycles. The alert is delivered |
last result becomes actual value, which is compared in future |
845 |
each time the condition becomes true. |
cycles. The alert is delivered each time the condition becomes |
846 |
|
true. |
847 |
|
|
848 |
|
|
849 |
You must select an action to be executed from this list: |
You must select an action to be executed from this list: |
869 |
|
|
870 |
=item * |
=item * |
871 |
|
|
872 |
B<STOP> stops the service by calling the service's registered stop |
B<STOP> stops the service by calling the service's registered |
873 |
method I<and> send an alert. If monit stops a service it will not |
stop method I<and> send an alert. If monit stops a service it |
874 |
be checked by monit anymore nor restarted again later. To |
will not be checked by monit anymore nor restarted again |
875 |
reactivate monitoring of the service again you must explicitly |
later. To reactivate monitoring of the service again you must |
876 |
enable monitoring from the web interface or from the console, |
explicitly enable monitoring from the web interface or from the |
877 |
e.g. 'monit monitor apache'. |
console, e.g. 'monit monitor apache'. |
878 |
|
|
879 |
=item * |
=item * |
880 |
|
|
949 |
The load average is the number of processes in the system run |
The load average is the number of processes in the system run |
950 |
queue, averaged over the specified time period. |
queue, averaged over the specified time period. |
951 |
|
|
952 |
I<operator> is a choice of "<",">","!=","==" in c notation, "gt", |
I<operator> is a choice of "<", ">", "!=", "==" in C notation, |
953 |
"lt", "eq", "ne" in shell sh notation and "greater", "less", |
"gt", "lt", "eq", "ne" in shell sh notation and "greater", |
954 |
"equal", "notequal" in human readable form (if not specified, |
"less", "equal", "notequal" in human readable form (if not |
955 |
default is EQUAL). |
specified, default is EQUAL). |
956 |
|
|
957 |
I<value> is either an integer or a real number (except for |
I<value> is either an integer or a real number (except for |
958 |
CHILDREN). For CPU, MEMORY and TOTALMEMORY you need to specify a |
CHILDREN). For CPU, MEMORY and TOTALMEMORY you need to specify a |
1012 |
tries to guess the method from the EXPECT string or uses MD5 as |
tries to guess the method from the EXPECT string or uses MD5 as |
1013 |
default. |
default. |
1014 |
|
|
1015 |
I<expect> is optional and if used it specifies a md5 or sha1 |
I<expect> is optional and if used it specifies a md5 or sha1 |
1016 |
string monit should expect when testing a file's checksum. |
string monit should expect when testing a file's checksum. If |
1017 |
If I<expect> is used, monit will not compute an initial checksum |
I<expect> is used, monit will not compute an initial checksum for |
1018 |
for the file, but instead use the string you submit. For example: |
the file, but instead use the string you submit. For example: |
1019 |
|
|
1020 |
if failed checksum and |
if failed checksum and |
1021 |
expect the sum 8f7f419955cefa0b33a2ba316cba3659 |
expect the sum 8f7f419955cefa0b33a2ba316cba3659 |
1028 |
I<action> is a choice of "ALERT", "RESTART", "START", "STOP", |
I<action> is a choice of "ALERT", "RESTART", "START", "STOP", |
1029 |
"EXEC" or "UNMONITOR". |
"EXEC" or "UNMONITOR". |
1030 |
|
|
1031 |
The checksum statement in variable form may be used to check |
The checksum statement in variable form may be used to check a |
1032 |
a file for changes and if changed, do a specified action. |
file for changes and if changed, do a specified action. For |
1033 |
For instance to reload a server if its configuration file |
instance to reload a server if its configuration file was |
1034 |
was changed. The following illustrate this for the apache |
changed. The following illustrate this for the apache web server: |
|
web server: |
|
1035 |
|
|
1036 |
check file httpd.conf path /usr/local/apache/conf/httpd.conf |
check file httpd.conf path /usr/local/apache/conf/httpd.conf |
1037 |
if changed sha1 checksum |
if changed sha1 checksum |
1051 |
=head2 TIMESTAMP TESTING |
=head2 TIMESTAMP TESTING |
1052 |
|
|
1053 |
The timestamp statement may only be used in a file or directory |
The timestamp statement may only be used in a file or directory |
1054 |
service entry. If specified in the control file, monit will compute |
service entry. If specified in the control file, monit will |
1055 |
a timestamp for a file or directory. |
compute a timestamp for a file or directory. |
1056 |
|
|
1057 |
The timestamp test in constant form is used to verify various |
The timestamp test in constant form is used to verify various |
1058 |
timestamp conditions. Syntax (keywords are in capital): |
timestamp conditions. Syntax (keywords are in capital): |
1074 |
|
|
1075 |
=back |
=back |
1076 |
|
|
1077 |
I<operator> is a choice of "<",">","!=","==" in c notation, "GT", |
I<operator> is a choice of "<", ">", "!=", "==" in C notation, |
1078 |
"LT", "EQ", "NE" in shell sh notation and "GREATER", "LESS", |
"GT", "LT", "EQ", "NE" in shell sh notation and "GREATER", |
1079 |
"EQUAL", "NOTEQUAL" in human readable form (if not specified, |
"LESS", "EQUAL", "NOTEQUAL" in human readable form (if not |
1080 |
default is EQUAL). |
specified, default is EQUAL). |
1081 |
|
|
1082 |
I<value> is a time watermark. |
I<value> is a time watermark. |
1083 |
|
|
1159 |
|
|
1160 |
=back |
=back |
1161 |
|
|
1162 |
The size statement in variable form is simply to test an |
The size statement in variable form is simply to test an existing |
1163 |
existing file for size changes and if changed, execute an |
file for size changes and if changed, execute an action. Syntax |
1164 |
action. Syntax (keywords are in capital): |
(keywords are in capital): |
1165 |
|
|
1166 |
=over 4 |
=over 4 |
1167 |
|
|
1169 |
|
|
1170 |
=back |
=back |
1171 |
|
|
1172 |
I<operator> is a choice of "<",">","!=","==" in c notation, "GT", |
I<operator> is a choice of "<", ">", "!=", "==" in C notation, |
1173 |
"LT", "EQ", "NE" in shell sh notation and "GREATER", "LESS", |
"GT", "LT", "EQ", "NE" in shell sh notation and "GREATER", |
1174 |
"EQUAL", "NOTEQUAL" in human readable form (if not specified, |
"LESS", "EQUAL", "NOTEQUAL" in human readable form (if not |
1175 |
default is EQUAL). |
specified, default is EQUAL). |
1176 |
|
|
1177 |
I<value> is a size watermark. |
I<value> is a size watermark. |
1178 |
|
|
1179 |
I<unit> is a choice of "B","KB","MB","GB" or long alternatives |
I<unit> is a choice of "B","KB","MB","GB" or long alternatives |
1180 |
"byte", "kilobyte", "megabyte", "gigabyte". If it is not specified, |
"byte", "kilobyte", "megabyte", "gigabyte". If it is not |
1181 |
"byte" unit is assumed by default. |
specified, "byte" unit is assumed by default. |
1182 |
|
|
1183 |
I<action> is a choice of "ALERT", "RESTART", "START", "STOP", |
I<action> is a choice of "ALERT", "RESTART", "START", "STOP", |
1184 |
"EXEC" or "UNMONITOR". |
"EXEC" or "UNMONITOR". |
1188 |
changes and send an alert or execute an action. Monit will |
changes and send an alert or execute an action. Monit will |
1189 |
register the size of the file at startup and monitor the file for |
register the size of the file at startup and monitor the file for |
1190 |
changes. As soon as the value changed, monit will do specified |
changes. As soon as the value changed, monit will do specified |
1191 |
action, reset the registered value to new result and continue |
action, reset the registered value to new result and continue to |
1192 |
to monitor, whether the size changed again. |
monitor, whether the size changed again. |
1193 |
|
|
1194 |
One example of use for this statement is to conduct security checks, |
One example of use for this statement is to conduct security checks, |
1195 |
for instance: |
for instance: |
1205 |
checksum, timestamp, and so on. |
checksum, timestamp, and so on. |
1206 |
|
|
1207 |
The constant size test form may be useful in similar or different |
The constant size test form may be useful in similar or different |
1208 |
contexts. It can, for instance, be used to test if a certain |
contexts. It can, for instance, be used to test if a certain file |
1209 |
file size was exceeded and then alert you or monit may execute |
size was exceeded and then alert you or monit may execute a |
1210 |
a certain action specified by you. An example is to use this |
certain action specified by you. An example is to use this |
1211 |
statement to rotate log files after they have reached a certain |
statement to rotate log files after they have reached a certain |
1212 |
size or to check that a database file does not grow beyond a |
size or to check that a database file does not grow beyond a |
1213 |
specified threshold. |
specified threshold. |
1243 |
|
|
1244 |
=head2 SPACE TESTING |
=head2 SPACE TESTING |
1245 |
|
|
1246 |
|
The match statement allows to check lines of file content against |
1247 |
|
a regular expression (regex). In case of a match a action like |
1248 |
|
an alarm is triggered. Syntax (keywords are in capital): |
1249 |
|
|
1250 |
|
=over 4 |
1251 |
|
|
1252 |
|
=item IF [NOT] MATCH {regex|path} THEN action |
1253 |
|
|
1254 |
|
=back |
1255 |
|
|
1256 |
|
I<regex> is a string containing the extended regular expression. |
1257 |
|
See also regex(7). |
1258 |
|
|
1259 |
|
I<path> is an absolute path to a file containing extended |
1260 |
|
regular expression on every line. See also regex(7). |
1261 |
|
|
1262 |
|
I<action> is a choice of "ALERT", "RESTART", "START", "STOP", |
1263 |
|
"EXEC" or "UNMONITOR". |
1264 |
|
|
1265 |
|
You can use the I<NOT> statement to invert a match. |
1266 |
|
|
1267 |
|
The content is only being checked every cycle. If content is |
1268 |
|
being added and removed during between two check they are |
1269 |
|
unnoticed. |
1270 |
|
|
1271 |
|
On startup the read position is the file end. Upon file size |
1272 |
|
decrease and inode change the read position is set to the file |
1273 |
|
start. |
1274 |
|
|
1275 |
|
Only lines ending with a newline character are inspected. Thus, |
1276 |
|
lines are being ignored until they have been completed with this |
1277 |
|
character. |
1278 |
|
|
1279 |
|
Only the first 511 characters of a line are inspected any |
1280 |
|
following is omitted. |
1281 |
|
|
1282 |
|
=over 4 |
1283 |
|
|
1284 |
|
=item IGNORE [NOT] MATCH {regex|path} |
1285 |
|
|
1286 |
|
=back |
1287 |
|
|
1288 |
|
Lines matching an I<IGNORE> are not inspected for later matches. |
1289 |
|
I<IGNORE MATCH> has always precedence over I<IF MATCH>. |
1290 |
|
|
1291 |
|
In first all I<IGNORE MATCH> statements are evaluated in the |
1292 |
|
order of there appearance. In second all I<IF MATCH> statements |
1293 |
|
are evaluated. |
1294 |
|
|
1295 |
|
A real life example might look like this: |
1296 |
|
|
1297 |
|
check file syslog with path /var/log/syslog |
1298 |
|
ignore match |
1299 |
|
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ monit\[[0-9]+\]:" |
1300 |
|
ignore match /etc/monit/syslog.regex.ignore |
1301 |
|
if match |
1302 |
|
"^\w{3} [ :0-9]{11} [._[:alnum:]-]+ mrcoffee\[[0-9]+\]:" |
1303 |
|
if match /etc/monit/syslog.regex.alert then alert |
1304 |
|
|
1305 |
|
|
1306 |
|
=head2 SPACE TESTING |
1307 |
|
|
1308 |
Monit can test devices/file systems and check for space |
Monit can test devices/file systems and check for space |
1309 |
usage. This test may only be used within a device service entry |
usage. This test may only be used within a device service entry |
1310 |
in the monit control file. |
in the monit control file. |
3466 |
|
|
3467 |
=head1 SEE ALSO |
=head1 SEE ALSO |
3468 |
|
|
3469 |
GNU text utilities; md5sum(1); sha1sum(1); openssl(1); glob(7) |
GNU text utilities; md5sum(1); sha1sum(1); openssl(1); glob(7); |
3470 |
|
regex(7) |
3471 |
|
|
3472 |
|
|
3473 |
=cut |
=cut |