XHanch Studio Log in | Register | Cart

Forum

[How to] Automatica...
 
Notifications
Clear all

[How to] Automatically restart httpd service when server overloads

1 Posts
1 Users
0 Reactions
1,394 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

Sometimes, your server can be overloaded itself and crashed due to some reasons. Even you have warning system for server load, but if you are asleep in the middle of the night, your server will have a long downtime as well.

So, how to prevent CPU overload on your server and bring your server back to normal use automatically?

Here, there is a script below run via cron job every 60 seconds and detects the current server load. If the server load is above 25 then it will automatically stop the httpd server, send you a notification email. It will also check whether your httpd service is down. In this case, the httpd service will automatically restarted.

This solution requires 4 different files to be installed on your server
click here to download related files (8kb zip format)

Extract that package and copy the above files in /home/root/ on your server:
- apache-load-checker.sh
- apache-load-checker-notification-stopped.php
- apache-load-checker-notification-restarted.php
Then copy yhis file to /home/etc/cron.d
- apache-load-checker-cron

Just edit the files with your own email alerts and other else if necessary.

 
Posted : 15/03/2011 7:17 am
Share:

× Close Menu