monitrc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. set daemon 60
  2. set logfile syslog facility log_daemon
  3. set mailserver localhost
  4. set mail-format { from: monit@server1.example.com }
  5. set alert root@localhost
  6. set httpd port 2812 and
  7. allow admin:PASSWD_TO_REPLACE
  8. # SSL ENABLE
  9. # PEMFILE /var/certs/monit.pem
  10. check process sshd with pidfile /var/run/sshd.pid
  11. start program "/usr/sbin/service ssh start"
  12. stop program "/usr/sbin/service ssh stop"
  13. if failed port 22 protocol ssh then restart
  14. if 5 restarts within 5 cycles then timeout
  15. check process apache with pidfile /var/run/apache2/apache2.pid
  16. group www
  17. start program = "/usr/sbin/service apache2 start"
  18. stop program = "/usr/sbin/service apache2 stop"
  19. if failed host localhost port 80 protocol http
  20. and request "/monit/token" then restart
  21. if cpu is greater than 60% for 2 cycles then alert
  22. if cpu > 80% for 5 cycles then restart
  23. if totalmem > 500 MB for 5 cycles then restart
  24. if children > 250 then restart
  25. if loadavg(5min) greater than 10 for 8 cycles then stop
  26. if 3 restarts within 5 cycles then timeout
  27. check process mysqld with pidfile /var/run/mysqld/mysqld.pid
  28. group mysql
  29. start program = "/usr/sbin/service mysqld start"
  30. stop program = "/usr/sbin/service mysqld stop"
  31. if failed host 127.0.0.1 port 3306 then restart
  32. if 5 restarts within 5 cycles then timeout
  33. # ---------------------------------------------------------------------------------------------
  34. # NOTE: Replace example.pid with the pid name of your server, the name depends on the hostname
  35. # ---------------------------------------------------------------------------------------------
  36. #check process proftpd with pidfile /var/run/proftpd.pid
  37. # start program = "/usr/sbin/service proftpd start"
  38. # stop program = "/usr/sbin/service proftpd stop"
  39. # if failed port 21 protocol ftp then restart
  40. # if 5 restarts within 5 cycles then timeout
  41. #
  42. #check process postfix with pidfile /var/spool/postfix/pid/master.pid
  43. # group mail
  44. # start program = "/usr/sbin/service postfix start"
  45. # stop program = "/usr/sbin/service postfix stop"
  46. # if failed port 25 protocol smtp then restart
  47. # if 5 restarts within 5 cycles then timeout
  48. #
  49. #check process nginx with pidfile /var/run/nginx.pid
  50. # start program = "/usr/sbin/service nginx start"
  51. # stop program = "/usr/sbin/service nginx stop"
  52. # if failed host 127.0.0.1 port 80 then restart
  53. #
  54. #check process memcached with pidfile /var/run/memcached.pid
  55. # start program = "/usr/sbin/service memcached start"
  56. # stop program = "/usr/sbin/service memcached stop"
  57. # if failed host 127.0.0.1 port 11211 then restart
  58. #
  59. #check process pureftpd with pidfile /var/run/pure-ftpd/pure-ftpd.pid
  60. # start program = "/usr/sbin/service pure-ftpd-mysql start"
  61. # stop program = "/usr/sbin/service pure-ftpd-mysql stop"
  62. # if failed port 21 protocol ftp then restart
  63. # if 5 restarts within 5 cycles then timeout
  64. #
  65. #check process named with pidfile /var/run/named/named.pid
  66. # start program = "/usr/sbin/service bind9 start"
  67. # stop program = "/usr/sbin/service bind9 stop"
  68. # if failed host 127.0.0.1 port 53 type tcp protocol dns then restart
  69. # if failed host 127.0.0.1 port 53 type udp protocol dns then restart
  70. # if 5 restarts within 5 cycles then timeout
  71. #
  72. #check process ntpd with pidfile /var/run/ntpd.pid
  73. # start program = "/usr/sbin/service ntp start"
  74. # stop program = "/usr/sbin/service ntp stop"
  75. # if failed host 127.0.0.1 port 123 type udp then restart
  76. # if 5 restarts within 5 cycles then timeout
  77. #
  78. #check process mailman with pidfile /var/run/mailman/mailman.pid
  79. # group mail
  80. # start program = "/usr/sbin/service mailman start"
  81. # stop program = "/usr/sbin/service mailman stop"
  82. #
  83. #check process amavisd with pidfile /var/run/amavis/amavisd.pid
  84. # group mail
  85. # start program = "/usr/sbin/service amavis start"
  86. # stop program = "/usr/sbin/service amavis stop"
  87. # if failed port 10024 protocol smtp then restart
  88. # if 5 restarts within 5 cycles then timeout
  89. #
  90. #check process courier-imap with pidfile /var/run/courier/imapd.pid
  91. # group mail
  92. # start program = "/usr/sbin/service courier-imap start"
  93. # stop program = "/usr/sbin/service courier-imap stop"
  94. # if failed host localhost port 143 type tcp protocol imap then restart
  95. # if 5 restarts within 5 cycles then timeout
  96. #
  97. #check process courier-imap-ssl with pidfile /var/run/courier/imapd-ssl.pid
  98. # group mail
  99. # start program = "/usr/sbin/service courier-imap-ssl start"
  100. # stop program = "/usr/sbin/service courier-imap-ssl stop"
  101. # if failed host localhost port 993 type tcpssl sslauto protocol imap then restart
  102. # if 5 restarts within 5 cycles then timeout
  103. #
  104. #check process courier-pop3 with pidfile /var/run/courier/pop3d.pid
  105. # group mail
  106. # start program = "/usr/sbin/service courier-pop start"
  107. # stop program = "/usr/sbin/service courier-pop stop"
  108. # if failed host localhost port 110 type tcp protocol pop then restart
  109. # if 5 restarts within 5 cycles then timeout
  110. #
  111. #check process courier-pop3-ssl with pidfile /var/run/courier/pop3d-ssl.pid
  112. # group mail
  113. # start program = "/usr/sbin/service courier-pop-ssl start"
  114. # stop program = "/usr/sbin/service courier-pop-ssl stop"
  115. # if failed host localhost port 995 type tcpssl sslauto protocol pop then restart
  116. # if 5 restarts within 5 cycles then timeout
  117. #
  118. #check process dovecot with pidfile /var/run/dovecot/master.pid
  119. # group mail
  120. # start program = "/usr/sbin/service dovecot start"
  121. # stop program = "/usr/sbin/service dovecot stop"
  122. # if failed host localhost port 993 type tcpssl sslauto protocol imap then restart
  123. # if 5 restarts within 5 cycles then timeout