Server Fault Asked by user2672052 on December 16, 2021
I’m trying to figure out some issues on my server where my CPU is reaching 100% utilization every other day. This causes all my websites and http services to fail.
How can I configure monit to restart the httpd service when my cpu hits 100% for say 10 cycles?
I’m still new to linux and centos. Learning my way around it and I’ve tried to research this for a while, but I could not find a proper answer to this.
Thanks for looking
Update
Thanks for your response. When the CPUs are running at 100%, I’ve run the top command and I can see that user nobody is consuming all of it on httpd service. I have a few apps that use php scripts, but their error logs all seem fine.
I’m suspecting a particular wordpress theme is causing this error due to a loop while updating the website. This particular website also shows me a loopback test failed error while all other wordpress sites on the same server are running fine.
So, until I can find out the culprit, I simply want to restart the service httpd when CPU utilization reaches say 95% for 10 cycles.
I hope that is enough clarity for someone to kindly give me a solution.
How can I configure monit to restart the httpd service when my cpu hits 100% for say 10 cycles?
I would use this line in Monit to get what you are looking for:
if cpu > 100% for 10 cycles then restart
Altogether it could look something like this:
check process httpd with pidfile /path/to/your/pid
group mail
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu > 100% for 10 cycles then restart
Though this should do as you requested, I'm not sure this will give you the results you are looking for as Apache may have several processes running at any one time.
For your Wordpress woes, Wordpress Query Monitor might help you to track down the culprit.
Answered by Dre on December 16, 2021
How can I configure monit to restart the httpd service when my cpu hits 100% for say 10 cycles?
This causes all my websites and http services to fail.
Probably use
check process apache with pidfile /path/to/pid
start "/sbin/service/apache2 start"
stop "/sbin/service/apache2 stop"
if failed host 127.0.0.1 port 80
for 10 cycles
then restart
of course, there will be more information on M/Monit wiki.
Answered by mforsetti on December 16, 2021
It's very little information you're providing about the stack and issue. You're not even providing the info what service/app is consuming 100% CPU. If you're even thinking about restarting httpd when you're cpu reaches 100% is not a solution, it's stupid.
Use utilities like htop, iotop and sar to figure out what's using the resources. But according to what I see my crystal ball guess is mod_php in httpd.
Answered by Geeky Masters on December 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP