chrissv

monit 5.15 monitrc

Nov 12th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.69 KB | None | 0 0
  1. ###############################################################################
  2. ## Monit control file
  3. ###############################################################################
  4. ##
  5. ## Comments begin with a '#' and extend through the end of the line. Keywords
  6. ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
  7. ##
  8. ## Below you will find examples of some frequently used statements. For
  9. ## information about the control file and a complete list of statements and
  10. ## options, please have a look in the Monit manual.
  11. ##
  12. ##
  13. ###############################################################################
  14. ## Global section
  15. ###############################################################################
  16. ##
  17. ## Start Monit in the background (run as a daemon):
  18. #
  19. set daemon 120 # check services at 2-minute intervals
  20. with start delay 60 # optional: delay the first check by 4-minutes (by
  21. # # default Monit check immediately after Monit start)
  22. #
  23. #
  24. ## Set syslog logging with the 'daemon' facility. If the FACILITY option is
  25. ## omitted, Monit will use 'user' facility by default. If you want to log to
  26. ## a standalone log file instead, specify the full path to the log file
  27. #
  28. # set logfile syslog facility log_daemon
  29. set logfile /var/log/monit.log
  30. #
  31. #
  32. ## Set the location of the Monit lock file which stores the process id of the
  33. ## running Monit instance. By default this file is stored in $HOME/.monit.pid
  34. #
  35. set pidfile /var/run/monit.pid
  36. #
  37. ## Set the location of the Monit id file which stores the unique id for the
  38. ## Monit instance. The id is generated and stored on first Monit start. By
  39. ## default the file is placed in $HOME/.monit.id.
  40. #
  41. # set idfile /var/.monit.id
  42. set idfile /var/lib/monit/id
  43. #
  44. ## Set the location of the Monit state file which saves monitoring states
  45. ## on each cycle. By default the file is placed in $HOME/.monit.state. If
  46. ## the state file is stored on a persistent filesystem, Monit will recover
  47. ## the monitoring state across reboots. If it is on temporary filesystem, the
  48. ## state will be lost on reboot which may be convenient in some situations.
  49. #
  50. # set statefile /var/.monit.state
  51. set statefile /var/lib/monit/state
  52. #
  53. ## Set the list of mail servers for alert delivery. Multiple servers may be
  54. ## specified using a comma separator. If the first mail server fails, Monit
  55. # will use the second mail server in the list and so on. By default Monit uses
  56. # port 25 - it is possible to override this with the PORT option.
  57. #
  58. # set mailserver mail.bar.baz, # primary mailserver
  59. # backup.bar.baz port 10025, # backup mailserver on port 10025
  60. # localhost # fallback relay
  61. #
  62. #
  63. ## By default Monit will drop alert events if no mail servers are available.
  64. ## If you want to keep the alerts for later delivery retry, you can use the
  65. ## EVENTQUEUE statement. The base directory where undelivered alerts will be
  66. ## stored is specified by the BASEDIR option. You can limit the queue size
  67. ## by using the SLOTS option (if omitted, the queue is limited by space
  68. ## available in the back end filesystem).
  69. #
  70. set eventqueue
  71. basedir /var/lib/monit/events # set the base directory where events will be stored
  72. # slots 100 # optionally limit the queue size
  73. #
  74. #
  75. ## Send status and events to M/Monit (for more informations about M/Monit
  76. ## see http://mmonit.com/). By default Monit registers credentials with
  77. ## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
  78. ## have to register Monit credentials manually in M/Monit. It is possible to
  79. ## disable credential registration using the commented out option below.
  80. ## Though, if safety is a concern we recommend instead using https when
  81. ## communicating with M/Monit and send credentials encrypted.
  82. #
  83. # set mmonit http://monit:monit@192.168.1.10:8080/collector
  84. # # and register without credentials # Don't register credentials
  85. #
  86. #
  87. ## Monit by default uses the following format for alerts if the the mail-format
  88. ## statement is missing::
  89. ## --8<--
  90.  
  91. set mail-format {
  92. from: me@example.com
  93. subject: $HOST monit alert -- $EVENT $SERVICE
  94. message: $EVENT Service $SERVICE
  95. Date: $DATE
  96. Action: $ACTION
  97. Host: $HOST
  98. Description: $DESCRIPTION
  99. }
  100. ## --8<--
  101. ##
  102. ## You can override this message format or parts of it, such as subject
  103. ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
  104. ## are expanded at runtime. For example, to override the sender, use:
  105. #
  106. # set mail-format { from: monit@foo.bar }
  107. #
  108. #
  109. ## You can set alert recipients whom will receive alerts if/when a
  110. ## service defined in this file has errors. Alerts may be restricted on
  111. ## events by using a filter as in the second example below.
  112. #
  113. # set alert sysadm@foo.bar # receive all alerts
  114. #
  115. ## Do not alert when Monit starts, stops or performs a user initiated action.
  116. ## This filter is recommended to avoid getting alerts for trivial cases.
  117. #
  118. set alert me@example.com not on { instance, action }
  119. #
  120. #
  121. ## Monit has an embedded HTTP interface which can be used to view status of
  122. ## services monitored and manage services from a web interface. The HTTP
  123. ## interface is also required if you want to issue Monit commands from the
  124. ## command line, such as 'monit status' or 'monit restart service' The reason
  125. ## for this is that the Monit client uses the HTTP interface to send these
  126. ## commands to a running Monit daemon. See the Monit Wiki if you want to
  127. ## enable SSL for the HTTP interface.
  128. #
  129. set httpd port 2812 and
  130. # use address localhost # only accept connection from localhost
  131. # allow localhost # allow localhost to connect to the server and
  132. # allow admin:monit # require user 'admin' with password 'monit'
  133. allow 0.0.0.0/0.0.0.0
  134.  
  135. ###############################################################################
  136. ## Services
  137. ###############################################################################
  138. ##
  139.  
  140. check process ssh_to_home matching "ssh -N -R"
  141. start program "/root/create_ssh_tunnel.sh"
  142. stop program /usr/bin/pkill -f "ssh -N -R"
  143. if failed host 192.168.88.25 port 2230 protocol ssh for 2 cycles then restart
  144. # if 5 restarts within 5 cycles then timeout
  145.  
  146. check process sshd with pidfile /var/run/sshd.pid
  147. start program "/etc/init.d/ssh start" with timeout 60 seconds
  148. stop program "/etc/init.d/ssh stop"
  149. if failed port 22 protocol ssh then restart
  150. # if 5 restarts within 5 cycles then timeout
  151.  
  152. check process openvpn with pidfile /var/run/openvpn.home1195.pid
  153. start program "/etc/init.d/openvpn start" with timeout 60 seconds
  154. stop program "/etc/init.d/openvpn stop"
  155. if failed host 192.168.6.1 port 80 for 2 cycles then restart
  156.  
  157. check host 1_myself with address 192.168.0.1
  158. start program "/sbin/ifup eth1" with timeout 60 seconds
  159. stop program "/sbin/ifdown eth1" with timeout 60 seconds
  160. if 5 restarts within 10 cycles then timeout
  161. if failed ping with timeout 4 seconds then restart
  162. noalert me@example.com
  163.  
  164. check host 2_home_server with address 192.168.88.25
  165. if failed ping timeout 4 seconds then alert
  166. noalert me@example.com
  167. depends on openvpn
  168.  
  169. check host 3_laptop with address 192.168.0.100
  170. if failed ping timeout 4 seconds then alert
  171. noalert me@example.com
  172.  
  173. check host 4_linux with address 192.168.0.99
  174. if failed ping timeout 4 seconds then alert
  175. noalert me@example.com
  176.  
  177. check device RootFS with path /
  178. if space usage is greater than 95% for 5 cycles then alert
  179.  
  180. check network tun0 with interface tun0
  181. if failed link then alert
  182. noalert me@example.com
  183.  
  184. check process piControl matching "piControl"
  185. start program "/bin/bash -c '/usr/bin/python /usr/local/bin/piControl.py &'"
  186. stop program /usr/bin/pkill -f "piControl.py"
  187. # if 5 restarts within 5 cycles then timeout
  188.  
  189. check process timeDate matching "timeDate"
  190. start program "/bin/bash -c '/usr/bin/python /usr/local/bin/timeDate.py &'"
  191. stop program /usr/bin/pkill -f "timeDate.py"
  192. # if 5 restarts within 5 cycles then timeout
  193.  
  194.  
  195. set mailserver smtp.example.com port 587
  196. username "me@example.com" password "example"
  197. using tlsv1 with timeout 120 seconds
  198.  
  199.  
  200.  
  201. ###############################################################################
  202. ## Includes
  203. ###############################################################################
  204. ##
  205. ## It is possible to include additional configuration parts from other files or
  206. ## directories.
  207. #
  208. # include /etc/monit.d/*
  209. #
Add Comment
Please, Sign In to add comment