/[monit]/monit/monit.pod
ViewVC logotype

Diff of /monit/monit.pod

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.114 by chopp, Mon Sep 29 15:53:24 2003 UTC revision 1.115 by hauk, Mon Sep 29 23:45:43 2003 UTC
# Line 1222  as follows (keywords are in capital and Line 1222  as follows (keywords are in capital and
1222    
1223  =over 4  =over 4
1224    
1225  =item IF FAILED [host] port [type] [protocol|send/expect] [timeout]  =item IF FAILED [host] port [type]
1226             [protocol|{send/expect}+] [timeout]
1227        THEN action        THEN action
1228    
1229  =back  =back
# Line 1231  or for Unix sockets, Line 1232  or for Unix sockets,
1232    
1233  =over 4  =over 4
1234    
1235  =item  IF FAILED [unixsocket] [type] [protocol|send/expect] [timeout]  =item  IF FAILED [unixsocket] [type]
1236        THEN action            [protocol|{send/expect}+] [timeout]
1237           THEN action
1238    
1239  =back  =back
1240    
# Line 1286  As you can see, you may specify a reques Line 1288  As you can see, you may specify a reques
1288  the moment only the HTTP protocol supports the request option.  the moment only the HTTP protocol supports the request option.
1289  See also below for an example.  See also below for an example.
1290    
1291  B<send/expect: {SEND|EXPECT} "string" ...>.  In case monit does not  B<send/expect: {SEND|EXPECT} "string" ...>.  If monit does not
1292  support the service's protocol, is possible to use a user defined  support the protocol spoken by the server, you can write your own
1293  protocol.  Using the I<SEND> statement the string is sent to the port.  protocol-test using I<send> and I<expect> strings. The I<SEND>
1294  With I<EXPECT> on line is read from the port and compared with the  statement sends a string to the server port and the I<EXPECT>
1295  string.  Extended posix regex are used if the operating system  statement compares a newline terminated string read from the
1296  supports them.  Otherwise the string is used as is. The send/expect  server with the string given in the expect statement. If your
1297  statement is:  system supports POSIX regular expressions, you can use regular
1298   [{SEND|EXPECT} "string" [{SEND|EXPECT} "string"] [...]]  expressions in the expect string. Otherwise the string is used as
1299    is. The send/expect statement is:
1300    
1301     [{SEND|EXPECT} "string"]+
1302    
1303    If you have regular expressions support on your system, read the
1304    man file regex(7) to learn more about the types of regular
1305    expressions you can use in an expect string. Also note that monit
1306    will send a string as it is, and you B<must> remember to include
1307    CR and LF in the string to send, if the protocol expect those.
1308    Likewise monit will read newline terminated strings from the
1309    server or up to 256 bytes from the server and use this string
1310    when comparing the expect string. If the server sends strings
1311    terminated by CRLF, (i.e. "\r\n") you must remember to add the
1312    same terminating characters to the string you expect from the
1313    server. Finally, send/expect can be used with TCP stream sockets
1314    and UNIX sockets but B<not> with TCP udp sockets.
1315    
1316  B<timeout:with TIMEOUT x SECONDS>. Optionally specifies the  B<timeout:with TIMEOUT x SECONDS>. Optionally specifies the
1317  connect and read timeout for the connection. If monit cannot  connect and read timeout for the connection. If monit cannot
1318  connect to the server within this time it will assume that the  connect to the server within this time it will assume that the
# Line 1381  it sends the request to the http server, Line 1399  it sends the request to the http server,
1399  unsafe characters in the request. If the request statement isn't  unsafe characters in the request. If the request statement isn't
1400  specified, the default web server page will be requested.  specified, the default web server page will be requested.
1401    
1402    As mentioned above, if the server protocol is not supported by
1403    monit you can write your own protocol test using send/expect
1404    strings. Here we show a generic protocol test using send/expect
1405    strings for an imaginary protocol:
1406    
1407     if failed host server.whereever.bar port 2345
1408        send "LET ME IN\r\n"
1409        expect "WHO ARE YOU?\r\n"
1410        send "ME\r\n"
1411        expect "OK, please enter!\r\n"
1412        send "BYE\r\n"
1413        expect "OK, See you later!\r\n"
1414     then restart
1415    
1416  The I<TCPSSL> statement can optionally test the md5 sum of the  The I<TCPSSL> statement can optionally test the md5 sum of the
1417  server's certificate. You must state the md5 certificate string  server's certificate. You must state the md5 certificate string
1418  you expect the server to deliver and upon a connect to the  you expect the server to deliver and upon a connect to the
# Line 1405  process entry: Line 1437  process entry:
1437         if failed host www.tildeslash.com port 80 then restart         if failed host www.tildeslash.com port 80 then restart
1438         alert foo@bar.baz         alert foo@bar.baz
1439    
 Here, a generic connection test with send/expect is used :  
   
  check process myservice with pidfile /var/run/whatever.pid  
        start program = "/etc/init.d/whatever start"  
        stop program = "/etc/init.d/whatever stop"  
        if failed host server.whereever.bar port 2345  
                 send "LET ME IN\n"  
                 expect "WHO ARE YOU: "  
                 send "ME\n"  
                 expect "Okay, go in!\n"  
                 send "BYE\n"  
                 expect "See you later!\n"  
                 then restart  
        alert foo@bar.baz  
   
1440  Here, a connection test is used in a remote host entry:  Here, a connection test is used in a remote host entry:
1441    
1442   check host up2date with address ftp.redhat.com   check host up2date with address ftp.redhat.com
# Line 2216  the send/expect mechanism: Line 2233  the send/expect mechanism:
2233         start "/etc/init.d/httpd start"         start "/etc/init.d/httpd start"
2234         stop  "/etc/init.d/httpd stop"         stop  "/etc/init.d/httpd stop"
2235         if failed host www.sol.no port 80         if failed host www.sol.no port 80
2236                send "GET / HTTP/1.0\n\n"            send "GET / HTTP/1.0\r\nHost: www.sol.no\r\n\r\n"
2237                expect "HTTP/1\.[0-9] [0-9]{3} .*\n"            expect "HTTP/[0-9\.]{3} 200\r\n"
2238                then alert            then alert
2239    
2240  In the following example we ask monit to compute and verify the  In the following example we ask monit to compute and verify the
2241  checksum for the underlying apache binary used by the start and  checksum for the underlying apache binary used by the start and

Legend:
Removed from v.1.114  
changed lines
  Added in v.1.115

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26