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

Diff of /monit/monit.pod

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

revision 1.109 by martinp, Wed Sep 17 23:54:20 2003 UTC revision 1.110 by hauk, Sat Sep 20 03:25:04 2003 UTC
# Line 105  B<stop all> Line 105  B<stop all>
105  B<stop name>  B<stop name>
106     Stop the named service and disable its monitoring.     Stop the named service and disable its monitoring.
107     The name is a service entry name from the monitrc     The name is a service entry name from the monitrc
108     file. available     file.
109    
110    
111  B<restart all>  B<restart all>
# Line 119  B<restart name> Line 119  B<restart name>
119  B<monitor all>      B<monitor all>    
120     Enable monitoring of all services listed in the     Enable monitoring of all services listed in the
121     control file. If the group option is set, only start     control file. If the group option is set, only start
122     the services monitoring in the named group.     monitoring of services in the named group.
123    
124  B<monitor name>  B<monitor name>
125     Enable monitoring of the named service.  The name is     Enable monitoring of the named service.  The name is
# Line 197  There are three kinds of tokens in the c Line 197  There are three kinds of tokens in the c
197  keywords, numbers and strings.  keywords, numbers and strings.
198    
199  On a semantic level, the control file consists of two types of  On a semantic level, the control file consists of two types of
200  entries:  statements:
201    
202  =over 4  =over 4
203    
# Line 260  various statements will be explained in Line 260  various statements will be explained in
260  monit will log status and error messages to a log file. If  monit will log status and error messages to a log file. If
261  B<syslog> is given as a value for the I<-l> command-line switch  B<syslog> is given as a value for the I<-l> command-line switch
262  (or the keyword I<set logfile syslog> is found in the control  (or the keyword I<set logfile syslog> is found in the control
263  file) monit will use the B<syslog> system daemon for logging  file) monit will use the B<syslog> system daemon to log
264  messages. To turn off logging, simply do not set the logfile in  messages. To turn off logging, simply do not set the logfile in
265  the control file (and of course, do not use the -l switch)  the control file (and of course, do not use the -l switch)
266    
# Line 303  of waking it up. Line 303  of waking it up.
303  =head1 INIT SUPPORT  =head1 INIT SUPPORT
304    
305  Monit can run and be controlled from I<init>. If monit should  Monit can run and be controlled from I<init>. If monit should
306  crash I<init> will re-spawn a new monit process. Using init to  crash, I<init> will re-spawn a new monit process. Using init to
307  start monit is probably the best way to run monit if you want to  start monit is probably the best way to run monit if you want to
308  be certain that you always have a running monit daemon on your  be certain that you always have a running monit daemon on your
309  system. (It's obvious, but never the less worth to stress; Make  system. (It's obvious, but never the less worth to stress; Make
310  sure that the control file does not have any syntax errors before  sure that the control file does not have any syntax errors before
311  you start monit from init. Also, make sure that if you run monit  you start monit from init. Also, make sure that if you run monit
312  from init, that you do not start monit in your startup scripts as  from init, that you do not start monit from a startup scripts as
313  well).  well).
314    
315  To setup monit to run from init, you can either use the 'set  To setup monit to run from init, you can either use the 'set
# Line 328  For systems without telinit: Line 328  For systems without telinit:
328    
329    kill -1 1    kill -1 1
330    
331  In the case, that you are using SYSV init script for starting the  B<Things you need to know if you choose to start monit from
332  monitored services and monit (either from init or rc its own rc  init:> If monit is used to monitor services that are also started
333  script), in the special case of slow starting monitored service  at boot time (e.g. services started via SYSV init rc scripts or
334  you can observe the race condition between particular service's  via inittab) then in some situations a special race condition can
335  startup and its monitoring. In such case monit can produce false  occur. That is; if a service is slow to start, monit can assume
336  alarms. Possible solutions:  that the service is not running and possibly try to start it and
337    raise an alert, while, in fact the service is already about to
338    start or already in its startup sequence. If you experience this
339    problem, here are a couple of strategies you can use to prevent
340    this type of race condition:
341    
342    
343  =over 4  =over 4
344    
345  =item start critical services from monit directly:  =item start critical services directly from monit:
346    
347  This is the recommended solution - monit will takeover the  This is the recommended solution - let monit takeover the
348  responsibility for service's startup. To use it you need to  responsibility for starting services. To use this strategy you
349  replace the service's start and stop in appropriate runlevels.  must turn off the systems automatic start and stop for all
350  You can use for example on RedHat:  services handled by monit.
351    
352    On RedHat, you can for example use:
353    
354    chkconfig myprocess off    chkconfig myprocess off
355    
# Line 350  on Debian: Line 357  on Debian:
357    
358    update-rc.d -f myprocess remove    update-rc.d -f myprocess remove
359    
360  general example:  a general example:
361    
362    mv /etc/rc2.d/S99myprocess /etc/rc2.d/s99myprocess    mv /etc/rc2.d/S99myprocess /etc/rc2.d/s99myprocess
363    
364  To stop the service on system shutdown, you need either to add  If monit is started from a rc script, then to stop the service at
365  for example following line to monit's rc script:  systems shutdown, you should add the following line to monit's rc
366    script:
367    
368    /usr/local/bin/monit -c /etc/monitrc stop myprocess    /usr/local/bin/monit -c /etc/monitrc stop myprocess
369    
370  or to stop all services:  or if monit handles more than one service, simply stop all
371    services by using:
372    
373    /usr/local/bin/monit -c /etc/monitrc stop all    /usr/local/bin/monit -c /etc/monitrc stop all
374    
375  If you are running monit from init then you can add the second  If monit instead is started from init then, add a second line to
376  line of following example to stop the service:  inittab to stop the service:
377    
378    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
379    m0:06:wait:/usr/local/bin/monit -Ic /etc/monitrc stop myprocess    m0:06:wait:/usr/local/bin/monit -Ic /etc/monitrc stop myprocess
380    
381  or to stop all services:  or to stop all services handled by monit:
382    
383    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
384    m0:06:wait:/usr/local/bin/monit -Ic /etc/monitrc stop all    m0:06:wait:/usr/local/bin/monit -Ic /etc/monitrc stop all
385    
386  The monitored service must have start and stop methods defined,  Services handled by monit I<must> have start and stop methods
387  such as for example:  defined so monit can start and stop a service. For instance:
388    
389    check process myprocess with pidfile /var/run/myprocess.pid    check process myprocess with pidfile /var/run/myprocess.pid
390          start program = "/etc/init.d/myprocess start"          start program = "/etc/init.d/myprocess start"
391          stop program = "/etc/init.d/myprocess stop"          stop program = "/etc/init.d/myprocess stop"
392          alert foo@bar.baz          alert foo@bar.baz
393    
394  =item wait for service to start  =item make init wait for a service to start:
395    
396  This solution will cause that init process will wait for the service  This solution will make the init process wait for the service to
397  to start before it will continue to start other services. If you are  start before it will continue to start other services. If you are
398  running monit from init, you must define monit's line as last in  running monit from init, you must enter monit's line at the end
399  /etc/inittab (short example):  of /etc/inittab (A short example):
400    
401    si::sysinit:/etc/init.d/rcS    si::sysinit:/etc/init.d/rcS
402    ...    ...
# Line 395  running monit from init, you must define Line 404  running monit from init, you must define
404    ...    ...
405    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc    mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
406    
407  The rc script of the monitored service must be modified so, that it  The rc script for the monitored service must be I<modified> so,
408  will not return unless the service will be online or the startup  that it will not return unless the service was started or start
409  timed out. As dumb method sleep is sufficient.  of the service timed out. Creative use of sleep(1) may be
410    sufficient.
411    
412  The monitored service must have start and stop methods defined,  As in the above example, services handled by monit must have
413  such as for example:  start and stop methods defined, such as for example:
414    
415    check process myprocess with pidfile /var/run/myprocess.pid    check process myprocess with pidfile /var/run/myprocess.pid
416          start program = "/etc/init.d/myprocess start"          start program = "/etc/init.d/myprocess start"
417          stop program = "/etc/init.d/myprocess stop"          stop program = "/etc/init.d/myprocess stop"
418          alert foo@bar.baz          alert foo@bar.baz
419    
420  =item enable the service monitoring manualy  =item enable the service monitoring manually from monit:
421    
422    check file myprocess.pid with path /var/run/myprocess.pid    check file myprocess.pid with path /var/run/myprocess.pid
423          if timestamp > 5 minutes then          if timestamp > 5 minutes then
# Line 421  such as for example: Line 431  such as for example:
431          alert foo@bar.baz          alert foo@bar.baz
432          mode manual          mode manual
433    
434  This will cause to wait for 5 minutes before it will enable  This will cause monit to wait for 5 minutes before it will enable
435  monitoring of the service myprocess.  monitoring of the service myprocess.
436    
437  =back  =back
# Line 689  for messages sent by monit, like so: Line 699  for messages sent by monit, like so:
699    
700  B<monit> provides a service timeout mechanism for situations  B<monit> provides a service timeout mechanism for situations
701  where a service simply refuses to start or respond over a longer  where a service simply refuses to start or respond over a longer
702  period. In cases like this, and particularly if monits poll-cycle  period. In cases like this, and particularly if monit's poll-cycle
703  is low, monit will simply increase the machine load by trying to  is low, monit will simply increase the machine load by trying to
704  restart the service.  restart the service.
705    
# Line 769  e.g. 'monit monitor apache'. Line 779  e.g. 'monit monitor apache'.
779    
780  B<EXEC> may be used to execute an arbitrary program I<and> send  B<EXEC> may be used to execute an arbitrary program I<and> send
781  an alert. If you choose this action you must state the program to  an alert. If you choose this action you must state the program to
782  be executed. You may also optionally specify the uid and gid the  be executed and if the program require arguments you must enclose
783  executed program should switch to upon start. For instance:  the program and its arguments in a quoted string. You may
784    optionally specify the uid and gid the executed program should
785    switch to upon start. For instance:
786    
787   exec "/usr/local/tomcat/bin/startup.sh"   exec "/usr/local/tomcat/bin/startup.sh"
788        as uid nobody and gid nobody        as uid nobody and gid nobody
789    
790  This may be useful if the program to be started cannot change to  This may be useful if the program to be started cannot change to
791  a lesser privileged user and group. This is typically needed for  a lesser privileged user and group. This is typically needed for
792  Java Servers. If monit is run by the superuser, the program monit  Java Servers. Remember, if monit is run by the superuser, then
793  execute will be started with superuser privileges unless the uid  all programs executed by monit will be started with superuser
794  and gid extension was used.  privileges unless the uid and gid extension was used.
795    
796  =item *  =item *
797    
# Line 894  but instead use the string you submit. F Line 906  but instead use the string you submit. F
906   then alert   then alert
907    
908  You can, for example, use the GNU utility I<md5sum(1)> to create  You can, for example, use the GNU utility I<md5sum(1)> to create
909  a checksum string for a file and then use this string in the  a checksum string for a file and use this string in the
910  expect-statement.  expect-statement.
911    
912  I<action> is a choice of "ALERT", "RESTART", "STOP", "EXEC" or  I<action> is a choice of "ALERT", "RESTART", "STOP", "EXEC" or
# Line 907  illustrate this for the apache web serve Line 919  illustrate this for the apache web serve
919    
920   check file httpd.conf path /usr/local/apache/conf/httpd.conf   check file httpd.conf path /usr/local/apache/conf/httpd.conf
921       if failed checksum       if failed checksum
922          then exec "/usr/local/apache/bin/apachectl restart"          then exec "/usr/local/apache/bin/apachectl graceful"
923    
924  If you plan to use the checksum statement for security reasons,  If you plan to use the checksum statement for security reasons,
925  (a very good idea, by the way) and to monitor a file or files  (a very good idea, by the way) and to monitor a file or files
926  which should not change, then please read the DEPENDENCY TREE  which should not change, then please also read the DEPENDENCY
927  section below to see a detailed example on how to do this  TREE section below to see a detailed example on how to do this
928  properly.  properly.
929    
930    
# Line 1098  size is explicitly defined (Note that th Line 1110  size is explicitly defined (Note that th
1110    
1111  =head2 SPACE TESTING  =head2 SPACE TESTING
1112    
1113  Monit can test devices/filesystems and check for space  Monit can test devices/file systems and check for space
1114  usage. This test may only be used within a device service entry  usage. This test may only be used within a device service entry
1115  in the monit control file.  in the monit control file.
1116    
# Line 1485  Here, a connection test is used in a rem Line 1497  Here, a connection test is used in a rem
1497         alert foo@bar.baz         alert foo@bar.baz
1498    
1499  Since we did not explicit specify a host in the above test, monit  Since we did not explicit specify a host in the above test, monit
1500  will connect to port 21 at ftp.redhat.com. Aprops, the host  will connect to port 21 at ftp.redhat.com. Apropos, the host
1501  address can be specified as a dotted IP address string or as  address can be specified as a dotted IP address string or as
1502  hostname in the DNS. The following is exactly[*] the same test,  hostname in the DNS. The following is exactly[*] the same test,
1503  but using an ip address instead:  but were an ip address is used instead:
1504    
1505   check host up2date with address 66.187.232.30   check host up2date with address 66.187.232.30
1506         if failed port 21 and protocol ftp then alert         if failed port 21 and protocol ftp then alert
# Line 1609  commands. (That is; most of the availabl Line 1621  commands. (That is; most of the availabl
1621   'monit -g groupname unmonitor all'   'monit -g groupname unmonitor all'
1622    
1623  If a monit daemon is running in the background we will ask the  If a monit daemon is running in the background we will ask the
1624  deamon (via the HTTP protocol) to execute the above commands.  daemon (via the HTTP protocol) to execute the above commands.
1625  That is, the daemon is requested to start and stop the services.  That is, the daemon is requested to start and stop the services.
1626  This ensures that a daemon will not restart a service that you  This ensures that a daemon will not restart a service that you
1627  requested to stop and that (any) timeout lock will be removed  requested to stop and that (any) timeout lock will be removed
# Line 1631  to, but only hosts with a valid domain n Line 1643  to, but only hosts with a valid domain n
1643  allowed. If you specify a hostname that does not resolve, monit  allowed. If you specify a hostname that does not resolve, monit
1644  will write an error message in the console and not start.  will write an error message in the console and not start.
1645    
1646  The http server will query a nameserver to check any hosts  The http server will query a name server to check any hosts
1647  connecting to the server. If a host (client) is trying to connect  connecting to the server. If a host (client) is trying to connect
1648  to the server, but cannot be found in the access list or cannot  to the server, but cannot be found in the access list or cannot
1649  be resolved, the server will shutdown the connection to the  be resolved, the server will shutdown the connection to the
# Line 1644  Control file example: Line 1656  Control file example:
1656        allow my.other.work.machine.com        allow my.other.work.machine.com
1657        allow 10.1.1.1        allow 10.1.1.1
1658    
1659    Clients, not mentioned in the allow list that tries to connect to
1660    the server are logged with their ip-address.
1661    
1662    
1663  =head4 Basic Authentication  =head4 Basic Authentication
1664    
# Line 1694  password is written in clear-text. (Use Line 1709  password is written in clear-text. (Use
1709  600 ~/.monitrc). In fact, since monit B<version 3.0>, monit will  600 ~/.monitrc). In fact, since monit B<version 3.0>, monit will
1710  complain and exit if the control file is readable by others.  complain and exit if the control file is readable by others.
1711    
1712    Clients trying to connect to the server but supply the wrong
1713    username and/or password are logged with their ip-address.
1714    
1715    
1716  =head1 DEPENDENCY TREE  =head1 DEPENDENCY TREE
# Line 1896  file or a directory which is part of a f Line 1913  file or a directory which is part of a f
1913  recommended to use a block special file directly (for example  recommended to use a block special file directly (for example
1914  /dev/hda1 on Linux or /dev/dsk/c0t0d0s1 on Solaris, etc.) If you  /dev/hda1 on Linux or /dev/dsk/c0t0d0s1 on Solaris, etc.) If you
1915  use a mount point (for example /data), be careful, because if the  use a mount point (for example /data), be careful, because if the
1916  device is unmounted the test will still be true becasue the mount  device is unmounted the test will still be true because the mount
1917  point exist.  point exist.
1918    
1919  If the device becomes unavailable, monit will call the entry's  If the device becomes unavailable, monit will call the entry's
# Line 2203  sent). Line 2220  sent).
2220    
2221  This example demonstrate how you can run a program as a specified  This example demonstrate how you can run a program as a specified
2222  user (uid) and with a specified group (gid). Many daemon programs  user (uid) and with a specified group (gid). Many daemon programs
2223  will do the uid and gid switch by themself, but for those  will do the uid and gid switch by them self, but for those
2224  programs that does not (e.g. java programs), monit's ability to  programs that does not (e.g. java programs), monit's ability to
2225  start a program as a certain user can be very useful.  In this  start a program as a certain user can be very useful.  In this
2226  example we start the Tomcat Java Servlet Engine as the standard  example we start the Tomcat Java Servlet Engine as the standard
# Line 2666  and I<only> the following environment va Line 2683  and I<only> the following environment va
2683    
2684  =item MONIT_EVENT  =item MONIT_EVENT
2685    
2686  The event that occured on the service  The event that occurred on the service
2687    
2688  =item MONIT_SERVICE  =item MONIT_SERVICE
2689    
2690  The name of the service (from monitrc) on which the event occured.  The name of the service (from monitrc) on which the event occurred.
2691    
2692  =item MONIT_DATE  =item MONIT_DATE
2693    
2694  The time and date (rfc 822 style) the event occured  The time and date (rfc 822 style) the event occurred
2695    
2696  =item MONIT_HOST  =item MONIT_HOST
2697    
2698  The host the event occured on  The host the event occurred on
2699    
2700  =back  =back
2701    

Legend:
Removed from v.1.109  
changed lines
  Added in v.1.110

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