Need to relax monit's watch on Apache

Discussion in 'Installation/Configuration' started by schwim, Sep 9, 2025.

  1. schwim

    schwim Member HowtoForge Supporter

    Hello there,

    Over the last couple of days, my server has been getting hit with a lot of bot traffic. It's a low-spec virtual and it struggles when one of the forums is getting thousands of registration attempts per hour.

    Monit was restarting Apache every couple of minutes and then disabling monitoring causing me to have to manually start apache quite often. Commenting the unmonitor line helped with that but I'm still getting apache restarts every 2-3 minutes because the server is responding more slowly than monit expects.

    Is there a way to change the way this config handles slow apache responses so I don't get so many restarts or am I just better off unmonitoring it and handling it manually?

    Code:
    check process apache with pidfile /var/run/apache2/apache2.pid
     group www
     start program = "/usr/sbin/service apache2 start"
     stop program = "/usr/sbin/service apache2 stop"
     if failed host localhost port 80 protocol http
     and request "/monit/token" then restart
     if cpu is greater than 80% for 2 cycles then alert
     if cpu > 90% for 5 cycles then restart
     if totalmem > 1500 MB for 5 cycles then restart
     if children > 250 then restart
     if loadavg(5min) greater than 20 for 8 cycles then stop
    # if 5 restarts within 5 cycles then timeout
    
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Check why Monit restarts Apache, and then increase the value responsible for the restart.
     
  3. schwim

    schwim Member HowtoForge Supporter

    Sorry I meant to include this. It's failing on the port 80 check and I don't know how to increase any value for how long it waits for a response.

     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Maybe this can help, from ChatGPT:

     
  5. schwim

    schwim Member HowtoForge Supporter

    Thank you for the help. Did you understand from it's instructions whether the "set timeout 15 seconds" should go into the monit config file ot is it supposed to go elsewhere? I'm doing a search through the monit documentation and can't find any thing regarding "set timeout".
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    ahrasis likes this.

Share This Page