[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Killing PID of high-memory Apache instance
From: |
Martin Pala |
Subject: |
Re: Killing PID of high-memory Apache instance |
Date: |
Tue, 21 Feb 2017 17:41:09 +0100 |
Yes, the "total cpu" test operates on aggregated CPU usage of apache parent
process and all its children - the "restart" action which is used in the test
will restart the whole apache.
You can use the exec action with custom script that will find and kill the
child with highest cpu usage.
Example:
1.) Create the script for example as /usr/local/bin/killapache.sh and make it
executable with chmod 755:
--8<--
#!/bin/bash
ps -eo pid,pcpu,cmd | grep apache | sort -k2nr | head -1 | cut -f2 -d' ' |
xargs -i kill {}
--8<--
2.) Monit configuration:
--8<--
check process apache with pidfile /var/run/httpd.pid
[…]
if total cpu > 80% for 5 cycles then exec "/usr/local/bin/killapache.sh"
--8<--
Note: i didn't fully test the above example, may need some modifications.
Best regards,
Martin
> On 15 Feb 2017, at 22:44, Moore-Levesque, John H (CGI Federal)
> <address@hidden> wrote:
>
> My understanding of this configuration here:
>
> check process apache with pidfile /var/run/httpd.pid
> […]
> if total cpu > 80% for 5 cycles then restart
>
> Is that monit will kill restart Apache if the CPU usage of all the processes
> (parent and children) is over 80% for 5 cycles. Is it possible to have monit
> instead kill a single Apache PID with high CPU or memory usage? Or is it
> all-or-nothing?
>
> John H. Moore-Levesque | Consultant
> EPA CAM (ITS-EPA II) | CGI Federal
> 2800 Meridian Parkway, Suite 150, Durham, NC 27713
> T: 919-294-0080 | M: 303-718-9787
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general