1222 |
|
|
1223 |
=over 4 |
=over 4 |
1224 |
|
|
1225 |
=item IF FAILED [host] port [type] [protocol] [timeout] |
=item IF FAILED [host] port [type] [protocol|send/expect] [timeout] |
1226 |
THEN action |
THEN action |
1227 |
|
|
1228 |
=back |
=back |
1231 |
|
|
1232 |
=over 4 |
=over 4 |
1233 |
|
|
1234 |
=item IF FAILED [unixsocket] [type] [protocol] [timeout] |
=item IF FAILED [unixsocket] [type] [protocol|send/expect] [timeout] |
1235 |
THEN action |
THEN action |
1236 |
|
|
1237 |
=back |
=back |
1286 |
the moment only the HTTP protocol supports the request option. |
the moment only the HTTP protocol supports the request option. |
1287 |
See also below for an example. |
See also below for an example. |
1288 |
|
|
1289 |
|
B<send/expect: {SEND|EXPECT} "string" ...>. In case monit does not |
1290 |
|
support the service's protocol, is possible to use a user defined |
1291 |
|
protocol. Using the I<SEND> statement the string is sent to the port. |
1292 |
|
With I<EXPECT> on line is read from the port and compared with the |
1293 |
|
string. Extended posix regex are used if the operating system |
1294 |
|
supports them. Otherwise the string is used as is. The send/expect |
1295 |
|
statement is: |
1296 |
|
[{SEND|EXPECT} "string" [{SEND|EXPECT} "string"] [...]] |
1297 |
|
|
1298 |
B<timeout:with TIMEOUT x SECONDS>. Optionally specifies the |
B<timeout:with TIMEOUT x SECONDS>. Optionally specifies the |
1299 |
connect and read timeout for the connection. If monit cannot |
connect and read timeout for the connection. If monit cannot |
1300 |
connect to the server within this time it will assume that the |
connect to the server within this time it will assume that the |
1405 |
if failed host www.tildeslash.com port 80 then restart |
if failed host www.tildeslash.com port 80 then restart |
1406 |
alert foo@bar.baz |
alert foo@bar.baz |
1407 |
|
|
1408 |
|
Here, a generic connection test with send/expect is used : |
1409 |
|
|
1410 |
|
check process myservice with pidfile /var/run/whatever.pid |
1411 |
|
start program = "/etc/init.d/whatever start" |
1412 |
|
stop program = "/etc/init.d/whatever stop" |
1413 |
|
if failed host server.whereever.bar port 2345 |
1414 |
|
send "LET ME IN\n" |
1415 |
|
expect "WHO ARE YOU: " |
1416 |
|
send "ME\n" |
1417 |
|
expect "Okay, go in!\n" |
1418 |
|
send "BYE\n" |
1419 |
|
expect "See you later!\n" |
1420 |
|
then restart |
1421 |
|
alert foo@bar.baz |
1422 |
|
|
1423 |
Here, a connection test is used in a remote host entry: |
Here, a connection test is used in a remote host entry: |
1424 |
|
|
1425 |
check host up2date with address ftp.redhat.com |
check host up2date with address ftp.redhat.com |
1985 |
optional query string. |
optional query string. |
1986 |
- other protocols does not support this |
- other protocols does not support this |
1987 |
statement yet |
statement yet |
1988 |
|
send/expect These keywords specify a generic protocol. |
1989 |
|
Both require a string whether to be sent or |
1990 |
|
to be matched against (as extended regex if |
1991 |
|
supported). Send/expect can not be used together |
1992 |
|
with the proto(col) statement. |
1993 |
unix(socket) Specifies a Unix socket file and used like |
unix(socket) Specifies a Unix socket file and used like |
1994 |
the port statement above to test a Unix |
the port statement above to test a Unix |
1995 |
domain network socket connection. |
domain network socket connection. |
2092 |
I<connection>, I<port(number)>, I<unix(socket)>, I<type>, |
I<connection>, I<port(number)>, I<unix(socket)>, I<type>, |
2093 |
I<proto(col)>, I<tcp>, I<tcpssl>, I<udp>, I<alert>, |
I<proto(col)>, I<tcp>, I<tcpssl>, I<udp>, I<alert>, |
2094 |
I<mail-format>, I<restart>, I<timeout>, I<checksum>, I<resource>, |
I<mail-format>, I<restart>, I<timeout>, I<checksum>, I<resource>, |
2095 |
I<expect>, I<mailserver>, I<every>, I<mode>, I<active>, |
I<expect>, I<send>, I<mailserver>, I<every>, I<mode>, I<active>, |
2096 |
I<passive>, I<manual>, I<depends>, I<host>, I<default>, I<http>, |
I<passive>, I<manual>, I<depends>, I<host>, I<default>, I<http>, |
2097 |
I<ftp>, I<smtp>, I<pop>, I<nntp>, I<imap>, I<ssh>, I<dwp>, |
I<ftp>, I<smtp>, I<pop>, I<nntp>, I<imap>, I<ssh>, I<dwp>, |
2098 |
I<ldap2>, I<ldap3>, I<request>, I<cpu>, I<mem>, I<totalmem>, |
I<ldap2>, I<ldap3>, I<request>, I<cpu>, I<mem>, I<totalmem>, |
2199 |
if failed host chat.sol.no port 80 then alert |
if failed host chat.sol.no port 80 then alert |
2200 |
if failed host www.tildeslash.com port 80 then alert |
if failed host www.tildeslash.com port 80 then alert |
2201 |
|
|
2202 |
|
To make sure that monit is communicating with a http server a |
2203 |
|
protocol can be added, too: |
2204 |
|
|
2205 |
|
check process apache with pidfile /var/run/httpd.pid |
2206 |
|
start "/etc/init.d/httpd start" |
2207 |
|
stop "/etc/init.d/httpd stop" |
2208 |
|
if failed host www.sol.no port 80 |
2209 |
|
protocol HTTP |
2210 |
|
then alert |
2211 |
|
|
2212 |
|
This example shows a different way to check a webserver using |
2213 |
|
the send/expect mechanism: |
2214 |
|
|
2215 |
|
check process apache with pidfile /var/run/httpd.pid |
2216 |
|
start "/etc/init.d/httpd start" |
2217 |
|
stop "/etc/init.d/httpd stop" |
2218 |
|
if failed host www.sol.no port 80 |
2219 |
|
send "GET / HTTP/1.0\n\n" |
2220 |
|
expect "HTTP/1\.[0-9] [0-9]{3} .*\n" |
2221 |
|
then alert |
2222 |
|
|
2223 |
In the following example we ask monit to compute and verify the |
In the following example we ask monit to compute and verify the |
2224 |
checksum for the underlying apache binary used by the start and |
checksum for the underlying apache binary used by the start and |
2225 |
stop programs. If the the checksum test should fail, monitoring |
stop programs. If the the checksum test should fail, monitoring |