fduran

Linux monitoring with monit

Apr 21st, 2011
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.95 KB | None | 0 0
  1. # monit monitoring http://mmonit.com/monit/
  2. # www.fduran.com
  3.  
  4. apt-get update; apt-get install monit
  5.  
  6. cp /etc/monit/monitrc /etc/monit/monitrc.orig
  7. # edit /etc/monit/monitrc see examples at http://mmonit.com/wiki/Monit/ConfigurationExamples
  8.  
  9. # Respawn:
  10.  
  11. # a) systems with /etc/inittab (System-V):
  12. # append to /etc/inittab:
  13. mo:2345:respawn:/usr/sbin/monit -Ic /etc/monit/monitrc
  14.  
  15. # restart, after changing /etc/monit/monitrc for example
  16. pkill monit; telinit q
  17.  
  18. # start/stop
  19. /etc/init.d/monit start|stop
  20.  
  21. # b) Ubuntu upstart: create /etc/init/monit.conf with:
  22.  
  23. # Run monit in standard run-levels
  24. start on stopped rc2
  25. start on stopped rc3
  26. start on stopped rc4
  27. start on stopped rc5
  28. stop on runlevel 0
  29. stop on runlevel 1
  30. stop on runlevel 6
  31. respawn
  32. exec /usr/sbin/monit -c /etc/monit/monitrc
  33.  
  34. # reload upstart configuration
  35. initctl reload-configuration
  36.  
  37. # start/stop:
  38. start monit
  39. stop monit
  40.  
  41. # config file /etc/monit/monitrc
  42. # mysql: may not have /var/run/mysqld/mysql.pid , create in my.cf --pid-file= file_name
  43. # upstart systems: start program = "/sbin/start apache2"
  44. # check for errors with /usr/sbin/monit -Ic /etc/monit/monitrc
  45.  
  46. set daemon  200
  47. set alert youremail@example.com
  48. set httpd port 2812 and
  49.      allow 0.0.0.0/0.0.0.0
  50.      allow admin:somepassword
  51. check system example.com
  52.     if loadavg (1min) > 4 then alert
  53.     if loadavg (5min) > 2 then alert
  54.     if memory usage > 75% then alert
  55.     if cpu usage (user) > 70% then alert
  56.     if cpu usage (system) > 30% then alert
  57.     if cpu usage (wait) > 20% then alert
  58. check process apache with pidfile /var/run/apache2.pid
  59.     start program = "/etc/init.d/apache2 start"
  60.     stop program  = "/etc/init.d/apache2 stop"
  61.     if cpu > 60% for 2 cycles then alert
  62.     if cpu > 80% for 5 cycles then restart
  63.     if failed host example.com port 80 protocol http
  64.        then restart
  65. check device datafs with path /dev/xvda1
  66.      if space usage > 80% for 5 times within 15 cycles then alert
Advertisement
Add Comment
Please, Sign In to add comment