问题原文
原帖链接 · ibyte · CC BY-SA 4.0
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.
已采纳解答
原帖链接 · Dre · CC BY-SA 4.0
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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
