Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

How to automatically restart httpd when overloaded

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
duytoi
Posts: 12
Joined: Mon Jun 20, 2016 8:46 am

How to automatically restart httpd when overloaded
  • Quote

Post by duytoi » Thu Oct 20, 2016 1:41 am

Hello friends.

Service httpd on vps always overload, memory up to 1GB or more. It makes mysqld stop times lead to faulty

I'm using vestacp, please help me create a cron job to automatically check httpd if overloaded, it will automatically restart and thus mysqld

It as a cron job created automatically

This is my site https://sharelachuan.com

Regrads.

Duy Toi
Top

Elizine
Posts: 50
Joined: Wed Aug 12, 2015 12:11 pm
Contact:
Contact Elizine
Website

Re: How to automatically restart httpd when overloaded
  • Quote

Post by Elizine » Thu Oct 20, 2016 6:47 am

Usually once httpd is stopped, the load drops down within 60/100 seconds so there is hardly anytime down time, but it does give you time to investigate where the issue is, especially if it happens all the time.
To install, run the following in ssh and this will pull the file from my server over to yours.

Code: Select all

cd
wget http://www.craig-edmonds.com/special-tools/loadmonitor.txt
mv /root/loadmonitor.txt /root/hsws-loadmonitor.pl
chmod 755 /root/hsws-loadmonitor.pl
Then you need to add the cron to the cron tab so that it checks your server every 60 seconds.
Follow these instructions to edit the root cron file

1. open the cron file

Code: Select all

pico /var/spool/cron/root
2. add the following line to the cron file so it runs every minute

Code: Select all

* * * * * /root/hsws-loadmonitor.pl > /dev/null 2>&1
3. restart the cron with this command

Code: Select all

/etc/init.d/crond restart
Thats it!

The only thing you need to do now is change a couple of settings within the file to set your email address.

Do the following to edit your settings.

Code: Select all

pico /root/hsws-loadmonitor.pl
This will open the file and then you only need to edit the following settings:

my $contacts – the email address to send alerts to
my $from_address – the custom name of the server so you know which server its coming from
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: How to automatically restart httpd when overloaded
  • Quote

Post by mehargags » Thu Oct 20, 2016 8:14 am

I'm 200% sure your server is compromised, some site may be injected with malicious code.
or
your App is leaking memory and causing high load.

You should really try to find out the problem rather than restarting httpd automatically.
Top

duytoi
Posts: 12
Joined: Mon Jun 20, 2016 8:46 am

Re: How to automatically restart httpd when overloaded
  • Quote

Post by duytoi » Thu Oct 20, 2016 8:58 am

Thank mehargags and EliZine helped me.

I will follow up more time to figure out the cause of this situation on my server

Regards !

Duy Toi
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password