/[monit]/monit/web/monit.html
ViewVC logotype

Diff of /monit/web/monit.html

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

revision 1.8 by hauk, Mon Aug 26 10:59:28 2002 UTC revision 1.9 by hauk, Thu Sep 19 09:17:37 2002 UTC
# Line 4  Line 4 
4  <LINK REV="made" HREF="mailto:bhcompile@daffy.perf.redhat.com">  <LINK REV="made" HREF="mailto:bhcompile@daffy.perf.redhat.com">
5  </HEAD>  </HEAD>
6    
7  <BODY BGCOLOR="#FFFFFF">  <BODY>
8    
9  <A NAME="__index__"></A>  <A NAME="__index__"></A>
10  <!-- INDEX BEGIN -->  <!-- INDEX BEGIN -->
# Line 31  Line 31 
31          </UL>          </UL>
32    
33          <LI><A HREF="#program timeout">PROGRAM TIMEOUT</A></LI>          <LI><A HREF="#program timeout">PROGRAM TIMEOUT</A></LI>
34            <LI><A HREF="#resource testing">RESOURCE TESTING</A></LI>
35          <LI><A HREF="#connection testing">CONNECTION TESTING</A></LI>          <LI><A HREF="#connection testing">CONNECTION TESTING</A></LI>
36          <LI><A HREF="#monit httpd">MONIT HTTPD</A></LI>          <LI><A HREF="#monit httpd">MONIT HTTPD</A></LI>
37          <UL>          <UL>
# Line 230  so:</P> Line 231  so:</P>
231  <HR>  <HR>
232  <H1><A NAME="alert messages">ALERT MESSAGES</A></H1>  <H1><A NAME="alert messages">ALERT MESSAGES</A></H1>
233  <P>monit will send an email alert if a program timed out, if monit  <P>monit will send an email alert if a program timed out, if monit
234  restarted a program or if a checksum error occurred (see also the  restarted or stopped a program, a resource statement matches
235  section MD5 CHECKSUM below). More than one alert statement can be  (see also the section RESOURCE TESTING below) or if a checksum
236  used in a process entry. This means that you can send different  error occurred (see also the section MD5 CHECKSUM below). More
237  emails to different addresses. The full syntax for the alert  than one alert statement can be used in a process entry. This
238  statement is as follows: (keywords are in capital)</P>  means that you can send different emails to different addresses.
239    The full syntax for the alert statement is as follows:
240    (keywords are in capital)</P>
241  <PRE>  <PRE>
242   ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</PRE>   ALERT mail-address [{events}] [MAIL-FORMAT {mail-format}]</PRE>
243  <P>Simply using:</P>  <P>Simply using:</P>
244  <PRE>  <PRE>
245   alert foo@bar</PRE>   alert foo@bar</PRE>
246  <P>will send a default email alert to the address foo@bar whenever a  <P>will send a default email alert to the address foo@bar whenever a
247  timeout, restart or checksum error occurs.</P>  timeout, restart, checksum, stop or resource error occurs.</P>
248  <P>If you only want an alert message sent when a certain event  <P>If you only want an alert message sent when a certain event
249  occurs for example a timeout or when a program is restarted;  occurs for example a timeout or when a program is restarted;
250  postfix the alert-statement respectively</P>  postfix the alert-statement respectively</P>
# Line 258  postfix the alert-statement respectively Line 261  postfix the alert-statement respectively
261  <P>It is also possible to combine events and send mail to different  <P>It is also possible to combine events and send mail to different
262  email addresses like:</P>  email addresses like:</P>
263  <PRE>  <PRE>
264   alert foo@bar { restart, timeout }   alert foo@bar { restart, timeout, resource }
265   alert security@bar on { checksum }   alert security@bar on { checksum, stop }
266   alert manager@bar</PRE>   alert manager@bar</PRE>
267  <P>This will send an alert message to foo@bar when a timeout or  <P>This will send an alert message to foo@bar when a timeout or
268  restart occurs and a message to security@bar if a checksum error  restart occurs and a message to security@bar if a checksum error
# Line 271  event occurs. Line 274  event occurs.
274  The following alert-statement:</PRE>  The following alert-statement:</PRE>
275  <PRE>  <PRE>
276    
277   alert foo@bar { timeout, restart, checksum }</PRE>   alert foo@bar { timeout, restart, checksum, resource, stop }</PRE>
278  <P>is equivalent to:</P>  <P>is equivalent to:</P>
279  <PRE>  <PRE>
280   alert foo@bar</PRE>   alert foo@bar</PRE>
281  <P>which as stated above, will send a message when a timeout, a  <P>which as stated above, will send a message when a timeout, a
282  restart or a checksum error occurs. (If the post fix variant is  restart or a checksum error occurs. (If the post fix variant is
283  used, then note that the parenthesis are <EM>mandatory</EM>).</P>  used, then note that the parenthesis are <EM>mandatory</EM>).</P>
284    <P>A restart alert is also sent <EM>if monit fails to execute</EM> the
285    start or the stop program for an entry. <STRONG>It is therefor strongly
286    advised</STRONG> that at least one alert statement register interest for
287    restart alerts.</P>
288  <P>monit will provide a default mail message layout that is short  <P>monit will provide a default mail message layout that is short
289  and to the point. Here's an example of a standard alert mail sent  and to the point. Here's an example of a standard alert mail sent
290  by monit:</P>  by monit:</P>
# Line 332  is using you can do:</P> Line 339  is using you can do:</P>
339  variables was used. If used they will be substituted into the  variables was used. If used they will be substituted into the
340  text with a special value:</P>  text with a special value:</P>
341  <P><EM>$EVENT</EM> A string describing the event that occured. The values  <P><EM>$EVENT</EM> A string describing the event that occured. The values
342  are fixed and are, ``restarted'', ``timed out'' and ``checksum error''</P>  are fixed and are, ``restarted'', ``timed out'', ``stopped and
343    ''checksum error``</P>
344  <P><EM>$PROGRAM</EM> The program entry name in monitrc</P>  <P><EM>$PROGRAM</EM> The program entry name in monitrc</P>
345  <P><EM>$DATE</EM> The current time and date (C time style).</P>  <P><EM>$DATE</EM> The current time and date (C time style).</P>
346  <P><EM>$HOST</EM> The name of the host monit is running on</P>  <P><EM>$HOST</EM> The name of the host monit is running on</P>
# Line 390  timeout lock in the daemon and make the Line 398  timeout lock in the daemon and make the
398  the program again.</P>  the program again.</P>
399  <P>  <P>
400  <HR>  <HR>
401    <H1><A NAME="resource testing">RESOURCE TESTING</A></H1>
402    <P>Monit can examine how much system resources a service or the
403    system is using.</P>
404    <P>Depending on this indicators services can be stopped or restarted
405    and alerts can be generated.  Thus it is possible to utilize
406    systems which are idle and to spare system under high load.</P>
407    <P>The full syntax for the resource-statements used for resource
408    testing is as follows (keywords are in capital and optional
409    statements in [brackets]),</P>
410    <PRE>
411     resource operator value [cycles] action</PRE>
412    <P><EM>resource</EM> is a choice of ``CPUUSAGE'', ``MEMUSAGE'', ``MEMKBYTE'',
413    ``LOADAVG([1min|5min|15min])'':</P>
414    <P>CPUUSAGE is the CPU usage of the process and it's children in
415    parts of hundred (percent). This resource <EM>value</EM> is a floating
416    point number. For instance, 60.0.</P>
417    <P>In case the system has more then one CPU and the process has
418    child processes the CPU usage can raise above 100%.</P>
419    <P>MEMUSAGE is the memory usage of the process in parts of hundred
420    (percent). This resource <EM>value</EM> is also a floating point
421    number.</P>
422    <P>MEMKBYTE is the memory amount of the process in KiB (1024
423    byte). This resource <EM>value</EM> is an integer number.</P>
424    <P><CODE>LOADAVG([1min|5min|15min])</CODE> refers to the system's load average.
425    The load average is the number of processes in the system run
426    queue averaged over the specified time period. This resource
427    <EM>value</EM> is again a floating point number.</P>
428    <P><EM>operator</EM> is a choice of ``&lt;'',``&gt;'',``!='',``=='' in c notation, ``gt'',
429    ``lt'', ``eq'', ``ne'' in shell sh notation and ``greater'', ``less'',
430    ``equal'', ``notequal'' in human readable form.</P>
431    <P><EM>cycles</EM> is the maximum number of cycles the expression above
432    has to be true in order to start an action.  If <EM>cylces</EM> is
433    omitted then it is set to one.</P>
434    <P><EM>action</EM> is a choice of ``ALERT'', ``RESTART'', ``STOP''.</P>
435    <P>ALERT sends the user a resource alert in case the maximum number
436    of cycles has been reached.</P>
437    <P>RESTART restarts the service in case the maximum number of cycles
438    has been reached.</P>
439    <P>STOP stops the service in case the maximum number of cycles has
440    been reached. If monit stops a service it will not be checked by
441    monit anymore nor restarted again later. You must explicit start
442    it again from the web interface or from the console, like: 'monit
443    start apache' if you want the monit daemon to monitor the service
444    again.</P>
445    <P>To calculate the cycles a counter is raised whenever the
446    expression above is true and it is lowered whenever it is false
447    (but not below 0).  All counters are reseted in case of a
448    restart.</P>
449    <P>In order to check that the CPU usage of a service is not going
450    beyond 50% for five cycles before restarting it, the following
451    expression could be used:</P>
452    <PRE>
453     if cpuusage is greater than 50.0 for 5 cylces then restart</PRE>
454    <P>Or the short version without noise keywords:</P>
455    <PRE>
456     cpuusage &gt; 50.0 5 restart</PRE>
457    <P>See also the example section below.</P>
458    <P>
459    <HR>
460  <H1><A NAME="connection testing">CONNECTION TESTING</A></H1>  <H1><A NAME="connection testing">CONNECTION TESTING</A></H1>
461  <P>Monit is able to to perfom connection testing via networked ports  <P>Monit is able to perfom connection testing via networked ports
462  and via unix sockets.</P>  and via unix sockets.</P>
463  <P>If a program listens on one or more sockets, monit can connect to  <P>If a program listens on one or more sockets, monit can connect to
464  the port (using either tcp or udp) and verify that the program  the port (using either tcp or udp) and verify that the program
# Line 621  expect-statement.</P> Line 688  expect-statement.</P>
688  <P>The preferred way to set up monit is to write a <EM>.monitrc</EM> file  <P>The preferred way to set up monit is to write a <EM>.monitrc</EM> file
689  in your home directory.  When there is a conflict between the  in your home directory.  When there is a conflict between the
690  command-line arguments and the arguments in this file, the  command-line arguments and the arguments in this file, the
691  command-line arguments take precedence.</P>  command-line arguments take precedence. To protect the security
692    of your control file and passwords the control file must have
693    permissions <EM>no more than 0700</EM> (u=xrw,g=,o=); monit will
694    complain and exit otherwise.</P>
695  <P>  <P>
696  <H2><A NAME="run control syntax">Run Control Syntax</A></H2>  <H2><A NAME="run control syntax">Run Control Syntax</A></H2>
697  <P>Comments begin with a '#' and extend through the end of the line.  <P>Comments begin with a '#' and extend through the end of the line.
# Line 634  and may contain whitespace (and quoted d Line 704  and may contain whitespace (and quoted d
704  string).  An unquoted string is any whitespace-delimited token,  string).  An unquoted string is any whitespace-delimited token,
705  containing characters and/or numbers.</P>  containing characters and/or numbers.</P>
706  <P>Each program entry consists of the keywords `check', followed by  <P>Each program entry consists of the keywords `check', followed by
707  a descriptive name for the program, which is again followed by a  a unique descriptive name for the program, which is again
708  path to the program's pidfile. For monit to be able to start and  followed by a path to the program's pidfile. A check entry can
709  stop the program, use the following keywords, 'start and 'stop -  have a number of optional statements. These statements are
710  followed by a string specifying a path to a program for  described below and in the example section.</P>
711  respectively starting and stopping the process. If the program  <P>You can use noise keywords like 'if', `and', `with(in)', `has',
 listens on certain portnumbers you can state this with the  
 keyword 'port' followed by a number indicating the portnumber,  
 one or more times.</P>  
 <P>You can use the noise keywords 'if', `and', `with(in)', `has',  
712  `using', 'use', 'on(ly)' and `program' anywhere in an entry to  `using', 'use', 'on(ly)' and `program' anywhere in an entry to
713  make it resemble English. They're ignored, but can make entries  make it resemble English. They're ignored, but can make entries
714  much easier to read at a glance. The punctuation characters ';'  much easier to read at a glance. The punctuation characters ';'
# Line 655  much easier to read at a glance. The pun Line 721  much easier to read at a glance. The pun
721   set daemon      Set a background poll interval in seconds   set daemon      Set a background poll interval in seconds
722   set init        Set monit to run from init   set init        Set monit to run from init
723   set logfile     Name of a file to dump error- and status-   set logfile     Name of a file to dump error- and status-
724                   messages to.                   messages to. If syslog is specified as the
725                     file, monit will utilize the syslog daemon
726                     to log messages.
727   set mailserver  The mailserver used for sending alert   set mailserver  The mailserver used for sending alert
728                   notifications. If the mailserver is not                   notifications. If the mailserver is not
729                   defined, monit will try to use 'localhost'                   defined, monit will try to use 'localhost'
# Line 714  much easier to read at a glance. The pun Line 782  much easier to read at a glance. The pun
782                   You're welcome to write new protocol test                   You're welcome to write new protocol test
783                   modules. If no protocol is specified monit                   modules. If no protocol is specified monit
784                   will use a default test which in most cases                   will use a default test which in most cases
785                   is good enough.                   are good enough.
786   request         Specifies a server request and must come   request         Specifies a server request and must come
787                   after the protocol keyword mentioned above.                   after the protocol keyword mentioned above.
788                    - for http it can contain an URI and an                    - for http it can contain an URI and an
# Line 730  much easier to read at a glance. The pun Line 798  much easier to read at a glance. The pun
798                   is the cycle interval to test restarts.                   is the cycle interval to test restarts.
799                   This statement is optional                   This statement is optional
800   alert           Specifies an email address for notification   alert           Specifies an email address for notification
801                   if checksum, timeout or restart occurs.                   if checksum, timeout, stop or restart occurs.
802                   Alert can also be postfixed, to only send a                   Alert can also be postfixed, to only send a
803                   message for certain events. See the examples                   message for certain events. See the examples
804                   above. This statement is also optional.                   above. More than one alert statement is allowed
805                     in an entry. This statement is also optional.
806   mail-format     Specifies a mail format for an alert message   mail-format     Specifies a mail format for an alert message
807                   This statement is an optional part of the                   This statement is an optional part of the
808                   alert statement.                   alert statement.
# Line 750  much easier to read at a glance. The pun Line 819  much easier to read at a glance. The pun
819                   some time to start.                   some time to start.
820   autostart       Must be followed by the keywords yes or no.   autostart       Must be followed by the keywords yes or no.
821                   If yes, monit will restart the program if                   If yes, monit will restart the program if
822                   it is not running (the default behaviour).</PRE>                   it is not running (the default behaviour).
823     cpuusage        Must be followed by a compare operator, a
824                     floating point number, optionally a maximum
825                     number of cycles and an action. This statement
826                     is used to check the cpu usage in percent of a
827                     process with it's children over a number of
828                     cylces.  If the compare expression matches then
829                     the action restart, alert or stop is activated
830     memusage        The equivalent to cpuusage for memory of a
831                     process (w/o children!). The syntax is the same
832                     as above.
833     memkbyte        The equivalent to memusage but with amounts
834                     in Kb instead of percentages.
835     loadavg         Must be followed by [1min,5min,15min] in (), a
836                     compare operator, a floating point number,
837                     optionally a maximum number of cycles and an
838                     action.  This statement is used to check the
839                     system load average over a number of cylces. If
840                     the compare expression matches then the action
841                     start, alert or stop is avtivated.</PRE>
842  <P>Here's the complete list of reserved <STRONG>keywords</STRONG> used by monit:</P>  <P>Here's the complete list of reserved <STRONG>keywords</STRONG> used by monit:</P>
843  <P><EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, <EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>,  <P><EM>set</EM>, <EM>daemon</EM>, <EM>logfile</EM>, <EM>syslog</EM>, <EM>address</EM>, <EM>httpd</EM>,
844  <EM>allow</EM>, <EM>check</EM>, <EM>init</EM>, <EM>pidfile</EM>, <EM>group</EM>, <EM>start</EM>,  <EM>allow</EM>, <EM>check</EM>, <EM>init</EM>, <EM>pidfile</EM>, <EM>group</EM>, <EM>start</EM>,
845  <EM>stop</EM>, <EM>port(number)</EM>, <EM>unix(socket)</EM>, <EM>type</EM>,  <EM>stop</EM>, <EM>port(number)</EM>, <EM>unix(socket)</EM>, <EM>type</EM>,
846  <EM>proto(col)</EM>, <EM>tcp</EM>, <EM>udp</EM>, <EM>alert</EM>, <EM>mail-format</EM>,  <EM>proto(col)</EM>, <EM>tcp</EM>, <EM>udp</EM>, <EM>alert</EM>, <EM>mail-format</EM>,
847  <EM>restart</EM>, <EM>timeout</EM>, <EM>checksum</EM>, <EM>expect</EM>, <EM>mailserver</EM>,  <EM>restart</EM>, <EM>timeout</EM>, <EM>checksum</EM>, <EM>resource</EM>, <EM>expect</EM>,
848  <EM>every</EM>, <EM>autostart</EM>, <EM>yes</EM>, <EM>no</EM>, <EM>host</EM>, <EM>default</EM>,  <EM>mailserver</EM>, <EM>every</EM>, <EM>autostart</EM>, <EM>yes</EM>, <EM>no</EM>, <EM>host</EM>,
849  <EM>http</EM>, <EM>ftp</EM>, <EM>smtp</EM>, <EM>pop</EM>, <EM>nntp</EM> <EM>imap</EM> and <EM>request</EM>.</P>  <EM>default</EM>, <EM>http</EM>, <EM>ftp</EM>, <EM>smtp</EM>, <EM>pop</EM>, <EM>nntp</EM>, <EM>imap</EM>,
850    <EM>request</EM>, <EM>cpuusage</EM>, <EM>memusage</EM>, <EM>memkbyte</EM> and <EM>loadavg</EM>.</P>
851  <P>And here is a complete list of <STRONG>noise keywords</STRONG> ignored by  <P>And here is a complete list of <STRONG>noise keywords</STRONG> ignored by
852  monit:</P>  monit:</P>
853  <P><EM>if</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>, <EM>using</EM>, <EM>use</EM>,  <P><EM>if</EM>, <EM>is</EM>, <EM>are</EM>, <EM>on(ly)</EM>, <EM>with(in)</EM>, <EM>and</EM>, <EM>has</EM>,
854  <EM>the</EM>, <EM>sum</EM>, <EM>restarts</EM>, <EM>program(s)</EM>, <EM>cycle(s)</EM>.</P>  <EM>using</EM>, <EM>use</EM>, <EM>the</EM>, <EM>sum</EM>, <EM>restarts</EM>, <EM>program(s)</EM>,
855    <EM>cycle(s)</EM>, <EM>than</EM>, <EM>then</EM>, <EM>for</EM>.</P>
856  <P><STRONG>Note:</STRONG> If the <EM>start</EM> or <EM>stop</EM> programs are shell scripts,  <P><STRONG>Note:</STRONG> If the <EM>start</EM> or <EM>stop</EM> programs are shell scripts,
857  then the script must begin with <CODE>#!</CODE> and the remainder of the  then the script must begin with <CODE>#!</CODE> and the remainder of the
858  first line must specify an interpreter for the  first line must specify an interpreter for the
# Line 860  if it is not running:</P> Line 950  if it is not running:</P>
950     port 9001     port 9001
951     alert bofh@foo.bar     alert bofh@foo.bar
952     group database</PRE>     group database</PRE>
953    <P>Here is an example to show the usage of the resource checks. It
954    will send an alert when the CPU usage of the http daemon and it's
955    child processes raises beyond 60% for over two cycles.  It is
956    restarted when the CPU usage it over 80% for five cycles, the
957    memory usage over 100MiBfor five cycles or the load average is
958    beyond 10 for 8 cycles:</P>
959    <PRE>
960     check apache with pidfile /var/run/httpd.pid
961       start program = &quot;/etc/init.d/httpd start&quot;
962       stop program  = &quot;/etc/init.d/httpd stop&quot;
963       if cpuusage &gt; 60.0 for 2 cycles then alert
964       if cpuusage &gt; 80.0 for 5 cycles then restart
965       if memkbyte &gt; 100000 for 5 cycles then stop
966       if loadavg(5min) greater than 10.0 for 8 cycles then stop</PRE>
967  <P>In this example we demonstrate usage of the extended alert  <P>In this example we demonstrate usage of the extended alert
968  statement:</P>  statement:</P>
969  <PRE>  <PRE>
# Line 890  statement:</P> Line 994  statement:</P>
994      and expect the sum 8f7f419955cefa0b33a2ba316cba3659      and expect the sum 8f7f419955cefa0b33a2ba316cba3659
995     host www.sol.no     port 80  type tcp protocol http     host www.sol.no     port 80  type tcp protocol http
996     host kvasir.sol.no  port 80  type tcp protocol http     host kvasir.sol.no  port 80  type tcp protocol http
997        and use the request &quot;/login.html&quot;        and use the request &quot;/login.cgi&quot;
998     host shop.sol.no    port 443 type tcp # default protocol test     host shop.sol.no    port 443 type tcp # default protocol test
999     timeout (2,3)     timeout (2,3)
1000       if cpuusage is greater than 60.0 for 2 cycles then alert
1001       if cpuusage &gt; 80.0 for 5 cycles then restart
1002       if memkbyte &gt; 100000 then stop
1003     alert foo@bar on { checksum }     alert foo@bar on { checksum }
1004     alert bofh@bar on { restart, timeout } with     alert bofh@bar on { restart, timeout } with
1005       mail-format { from: monit@foo.bar.no }       mail-format { from: monit@foo.bar.no }
# Line 941  authors.</P> Line 1048  authors.</P>
1048  <P>  <P>
1049  <HR>  <HR>
1050  <H1><A NAME="authors">AUTHORS</A></H1>  <H1><A NAME="authors">AUTHORS</A></H1>
1051  <P><A HREF="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</A></P>  <P>Jan-Henrik Haukeland &lt;<A HREF="mailto:hauk@tildeslash.com">hauk@tildeslash.com</A>&gt;,
1052    Martin Pala &lt;<A HREF="mailto:martin.pala@hq.iol.cz">martin.pala@hq.iol.cz</A>&gt;,
1053    Christian Hopp &lt;<A HREF="mailto:chopp@iei.tu-clausthal.de">chopp@iei.tu-clausthal.de</A>&gt;,
1054    Rory Toma &lt;<A HREF="mailto:rory@digeo.com">rory@digeo.com</A>&gt;,
1055    Thomas Oppel &lt;<A HREF="mailto:oppel@kbis.de">oppel@kbis.de</A>&gt;</P>
1056    <P>See also <A HREF="http://www.tildeslash.com/monit/who.html">http://www.tildeslash.com/monit/who.html</A></P>
1057  <P>  <P>
1058  <HR>  <HR>
1059  <H1><A NAME="copyright">COPYRIGHT</A></H1>  <H1><A NAME="copyright">COPYRIGHT</A></H1>

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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