# Monit control file # # Comments begin with a '#' and extend through the end of the line. # Blank lines between program entries are ignored. Keywords are case # insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/' # # Legal keywords are # check -- Must be followed by a descriptive name for the # program. # # pidfile -- Must be followed by a path to the programs pidfile. # Such a file should contain only one entry, a number # representing the process's pid. (See the apache pid # file for an example) # # group -- Must be followed by a descriptive name for a process # group. This statement can be used to group together # several processes. Monit can start/stop/restart a # group of processes. # # start -- Must be followed by a full path to a program for # starting the process. If you need to specify arguments # to the program, enclose the program and arguments in # quotes - like: "/local/bin/program -i start". # This entry is optional. # # stop -- Must be followed by a full path to a program for # stopping the process. If you need to specify arguments # to the program, enclose the program and arguments in # quotes - like: "/local/bin/program -i stop". # This entry is optional. # # host -- Specify a hostname or ip-address to test port # connection at. This statement must be followed by a # port statement. # # port(number) -- Must be followed by an integer representing a portnumber. # The monit program will try to connect to this port to # to verify that there is a server listening behind the # portnumber. If the connection fails the default action # is to write a notification into the logfile and to # restart the process. This entry is optional. # # unix(socket) -- Must be followed by a string representing a pathname. # The monit program will try to connect to this socket to # to verify that there is a server listening behind the # unix socket. If the connection fails the default action # is to write a notification into the logfile and to # restart the process. This entry is optional. # # type -- Must be followed by the keyword udp or tcp. This keyword # specifies the type of socket the monit program should # use when testing connection to the portnumber. If the # type keyword is omitted, tcp is used. # # tcp -- Specifies that monit should use a TCP socket type # (Stream socket) when testing the port # # udp -- Specifies that monit should use a UDP socket type # (datagram socket) when testing the port # # protocol -- Must be followed by a protocol keyword. This keyword # specifies the type of service found at the port. # monit knows at the moment how to speak HTTP, SMPT, # FTP, POP and IMAP. You're welcome to write new # protocol test modules. If no protocol is specified # monit will use a default test which in most cases is # good enough. This statement is optional. # # request -- Must be followed by URI string specifying a document # from the http server. Currently only the HTTP protocol # module supports the request statement, such as: # "/data/show.php?a=b&c=d" # # timeout -- Must be followed by two integers where the first # number is max restart and the second the number of # poll-cycles. This statement is optional. # # alert -- Specifies an email address for notification if a # process timed out or restarted. This statement is # optional. More than one alert statement is allowed. # # checksum -- Must be followed by a list of files with an absolute # path. This statement is optional. More than one # checksum statement is allowed. # # expect -- Specify a md5 string digest monit should expect when # testing a particular file's checksum. This statement is # an optional part of the checksum statement. # # every -- Only check the program at every n cycles. Optional. # # autostart -- Must be followed by the keywords yes or no. If yes # monit will restart the program if it is not running # (this is the default behaviour). If no monit will not # (re)start the program if it is not running. It is # recommended that you use yes or don't use this statement. # # cpuusage -- Must be followed by a compare operator, a floating # point number, optionally a maximum number of cycles # and an action. This statement is used to check the # cpu usage in percent of a process with it's children # over a number of cylces. If the compare expression # matches the action (restart, alert or stop) is used. # # memusage -- The equivalent to cpuusage for memory of a process # (w/o children!). The syntax is the same # # memkbyte -- The equivalent to memusage but with amounts instead # of percentages. # # loadavg -- Must be followed by [1min,5min,15min] in (), a compare # operator, a floating point number, optionally a # maximum number of cycles and an action. This statement # is used to check the system load average over a number # of cylces. If the compare expression matches the action # (restart, alert or stop) is used. # # # Legal global option statements are # # set daemon -- Must be followed by a number (in seconds) # # set init -- If specified, do not background monit. This allows # init to control and restart monit. To work properly, # modification of /etc/inittab is required. # (see FAQ.txt for details) # # set logfile -- Must be followed by either a filename (full path is # required) or the string 'syslog'. # # set mailserver -- Must be followed by a mailserver hostname. If the # mailserver is not defined, monit will try to use # 'localhost' as the smtp-server for sending mail # notification. # # set mail-format - Must be followed by a mail format list containing at # least one of the keywords; from: subject: or message: # # set httpd port -- Must be followed by a portnumber for the monit http # server. # # address -- If specified, the http server will only accept connect # requests to this addresses This statement is an optional # part of the set httpd statement. # # allow -- Specify a hostnames or IP addresses allowed to connect # to the http server (one allow statement per host) # and/or # allow -- Specify a username:password in clear text for # connecting to monit httpd # # # The noise keywords `if', `and', `the', `with', `has', `using', `use', # `on(ly)', `for', `than`, `then` and `program(s)' are ignored anywhere # in an entry; they can be used to make it resemble English. The # punctuation characters `,' `;' and '=' are also ignored. # # # Here's an example for monitoring an apache web-server on port # HTTP and HTTPS and a Sybase Database Server: # # [NB! Check and edit for your system and uncomment below] # # set daemon 120 # Poll at 2-minute intervals # set init # Run monit in "init" mode (non-backgrounded) # set logfile syslog # Set syslog as the logfile # set mailserver localhost # Use localhost as the smtp server # set mail-format # Set a default mail from address for # { from: address@hidden } # all alert messages emitted by monit set httpd port 2812 # Make monit start it's web-server # use address localhost # and only accept connection from localhost allow 10.124.4.34 # allow localhost to connect to the server and allow 10.2.58.195 # allow localhost to connect to the server and # allow hauk:monit # user 'hauk' with password 'monit' # #check apache with pidfile /usr/local/apache/logs/httpd.pid # start program = "/etc/init.d/httpd start" # stop program = "/etc/init.d/httpd stop" #host demo1.al-pi.net port 80 protocol http # and request "/monit/next.html" # port 443 # default/no protocol test # unix /var/run/foosocket # default/no protocol test # checksum /usr/local/apache/bin/httpd # and expect the sum 8f7f419955cefa0b33a2ba316cba3659 #alert address@hidden # with the mail-format { subject: Alarm! } # alert address@hidden on { timeout, restart } # timeout(3, 5) # group server # cpuusage > 60.0 2 alert # cpuusage > 80.0 5 restart # memkbyte > 100000.0 5 stop # if loadavg(5min) greater than 10 for 8 cycles then stop # # # check sybase with pidfile /var/run/sybase.pid # start program = "/etc/init.d/sybase start" # stop program = "/etc/init.d/sybase stop" # port 4001 # timeout if 2 restarts within 3 cycles # alert address@hidden # autostart no # group database check ssh with pidfile /etc/sshd.pid start program = "/etc/init.d/sshd start" stop program = "/etc/init.d/sshd stop" port 22 alert address@hidden group server check slapd with pidfile /usr/local/var/slapd.pid start program = "/etc/init.d/start_slapd start" stop program = "/etc/init.d/start_slapd stop" port 389 alert address@hidden autostart no group server