Munin & Monit

Discussion in 'Server Operation' started by Hans, May 9, 2006.

  1. Hans

    Hans Moderator Moderator

    I have setup Munin & Monit on my Debian system according Falko's How to and i have a question about this.

    Before i did this it was never necessary to restart Postfix.
    Since i have installed Munin & Monit, every night at 0:00 hour Monit restarts Postfix, so a new PID-file is created.
    What is the reason for this?

    Hans
     
  2. Norman

    Norman Member HowtoForge Supporter

    Might it be possible that munin is bugged so it doesnt recognize a new day?
    I doubt that however.

    Another reason might simply be that the timeout is set very low in /etc/monitrc so it restarts postfix when there's a lot of cron-activity around midnight.

    Check your monit log for more info and then change your config accordingly to wait longer.
     
  3. Hans

    Hans Moderator Moderator

    This is the contents of my monitrc file

    check process proftpd with pidfile /var/run/proftpd.pid
    start program = "/etc/init.d/proftpd start"
    stop program = "/etc/init.d/proftpd stop"
    if failed port 21 protocol ftp then restart
    if 5 restarts within 5 cycles then timeout

    check process sshd with pidfile /var/run/sshd.pid
    start program "/etc/init.d/ssh start"
    stop program "/etc/init.d/ssh stop"
    if failed port 22 protocol ssh then restart
    if 5 restarts within 5 cycles then timeout

    check process mysql with pidfile /var/run/mysqld/mysqld.pid
    group database
    start program = "/etc/init.d/mysql start"
    stop program = "/etc/init.d/mysql stop"
    if failed host 127.0.0.1 port 3306 then restart
    if 5 restarts within 5 cycles then timeout

    check process apache with pidfile /var/run/apache2.pid
    group www
    start program = "/etc/init.d/apache2 start"
    stop program = "/etc/init.d/apache2 stop"
    if failed host www.myhostingcompany.tld port 80 protocol http
    and request "/monit/token" then restart
    if cpu is greater than 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if totalmem > 500 MB for 5 cycles then restart
    if children > 250 then restart
    if loadavg(5min) greater than 10 for 8 cycles then stop
    if 3 restarts within 5 cycles then timeout

    check process postfix with pidfile /var/spool/postfix/pid/master.pid
    group mail
    start program = "/etc/init.d/postfix start"
    stop program = "/etc/init.d/postfix stop"
    if failed port 25 protocol smtp then restart
    if 5 restarts within 5 cycles then timeout

    Seems to be ok, i guess or do you have any sugestions?

    Hans
     
  4. falko

    falko Super Moderator Howtoforge Staff

    It's not monit who restarts Postfix, it's ISPConfig (in order to generate thetraffic statistics). monit just sends you a notification that Postfix has been restarted.
     
  5. Hans

    Hans Moderator Moderator

    Falko,

    So with other words... restarting Postfix at night by ISPConfig is normal, which means that i can expect this every day?

    (My box is full of surprises) :D
     
  6. falko

    falko Super Moderator Howtoforge Staff

    Yes, that's right.
     
  7. nenad

    nenad Member

    What exactly "10" in this statement means:


    Code:
    if loadavg(5min) greater than 10 for 8 cycles then stop
     
  8. falko

    falko Super Moderator Howtoforge Staff

    It's the 5 min. load average. When you run
    Code:
    uptime
    , it's the value in the middle:

    Code:
    13:37:41 up 50 days, 13:43,  1 user,  load average: 0.10, [B][COLOR="Red"]0.12[/COLOR][/B], 0.05
     
  9. nenad

    nenad Member

    OK, then 0.12 means 12% of load?

    Then isn't 10 in

    just to small? 10% of load?
     
  10. falko

    falko Super Moderator Howtoforge Staff

    1 means 100%, so 10 means 1000%. Have a look here: http://en.wikipedia.org/wiki/Load_average
     
  11. nenad

    nenad Member

    Hi,

    is it possible to increase timeout for http protocol from 5 to 15 sec.?
    Code:
    check process apache with pidfile /var/run/apache2.pid
       group www
       start program = "/etc/init.d/apache2 start"
       stop program  = "/etc/init.d/apache2 stop"
       if failed host www.web-hosting.co.yu port 80 protocol http
            and request "/monit/token" then restart
       if cpu is greater than 60% for 2 cycles then alert
       if cpu > 80% for 10 cycles then restart
       if totalmem > 500 MB for 5 cycles then restart
       if children > 250 then restart
       if loadavg(5min) greater than 10 for 8 cycles then stop
       if 3 restarts within 5 cycles then timeout
    and is it possible to check apache localy without testing it through web acess ?
    sometimes, internet connection where my server resides is under heavy load, so timeouts could be bigger than 5 sec. , and it causes unnecesery resrtarts of apache...
     
    Last edited: Aug 18, 2006
  12. falko

    falko Super Moderator Howtoforge Staff

    Which timeout?
    Yes, use
    Code:
    check process apache with pidfile /var/run/apache2.pid
       group www
       start program = "/etc/init.d/apache2 start"
       stop program  = "/etc/init.d/apache2 stop"
       if failed host 127.0.0.1 port 80 protocol http
            and request "/monit/token" then restart
       if cpu is greater than 60% for 2 cycles then alert
       if cpu > 80% for 10 cycles then restart
       if totalmem > 500 MB for 5 cycles then restart
       if children > 250 then restart
       if loadavg(5min) greater than 10 for 8 cycles then stop
       if 3 restarts within 5 cycles then timeout
    then, but make sure that monit/token is in that webspace then.
     
  13. nenad

    nenad Member

    Code:
    Port: If failed 127.0.0.1:80 [DEFAULT] with timeout [SIZE="4"][COLOR="Red"][B]5[/B][/COLOR][/SIZE] seconds then restart else if recovered then alert
    That timeout. I guess it is port timeout.


    Isn't it enough just to use
    Code:
    if failed host 127.0.0.1 port 80 then restart
     
    Last edited: Aug 19, 2006
  14. falko

    falko Super Moderator Howtoforge Staff

    What's in /etc/default/monit?


    You can do that if you like.
     
  15. nenad

    nenad Member

    Code:
    # Defaults for monit initscript
    # sourced by /etc/init.d/monit
    # installed at /etc/default/monit by maintainer scripts
    # Fredrik Steen <[email protected]>
    
    # You must set this variable to for monit to start
    startup=1
    
    # To change the intervals which monit should run uncomment
    # and change this variable.
    CHECK_INTERVALS=60
    
    /etc/default/monit
     
  16. falko

    falko Super Moderator Howtoforge Staff

    I'm not quite sure how to change that, but you can have a look here: http://www.tildeslash.com/monit/doc/
     
  17. danfulton

    danfulton New Member

    I've followed the howto, but I can not get munin to display the apache stats,

    When I run the plugin directly I get,

    Can't locate object method "new" via package "LWP::UserAgent" at ./apache_accesses line 128.

    Has anyone managed to get the apache stats to display?

    Cheers

    Dan
     

Share This Page