Page 1 of 1
CPU spikes - which process is causing it?
Posted: Thu Mar 01, 2018 4:56 am
by robatwork
Hi,
I imagine I can't be the only person who had this issue but I can't find a definitive answer for the current version of Nagios XI.
Almost every night at around 3am one of our servers CPUs goes critical for quite a while. Trying to troubleshoot this we have eliminated any obvious tasks that are occurring during the night, so I now want to know exactly which process is causing the CPU spike, as this server is running many services.
Is there a Nagios plugin or built in service that can simply tell me which process is causing the CPU to spike?
thanks
Re: CPU spikes - which process is causing it?
Posted: Thu Mar 01, 2018 6:01 pm
by cdienger
NCPA can be used to poll processes that are using more that X amount of cpu:
./check_ncpa.py -H server_ip -t 'token' -M 'processes' -q 'cpu_percent=80'
https://www.nagios.org/ncpa/getting-started.php covers how to install and the service check would look something like the below.
Depending on how long it spikes, you may want to lower to lower the check, retry and max check attempts on the Check Settings tab. You can also use the Check period option on the same tab to only run this check during the time frame that this occurs.
Re: CPU spikes - which process is causing it?
Posted: Fri Mar 02, 2018 7:17 am
by robatwork
Thanks - will have a look at NCPA
Re: CPU spikes - which process is causing it?
Posted: Fri Mar 02, 2018 8:34 am
by robatwork
OK got that working and it does show 2 tasks have gone critical for example, which is helpful.
I was after something a little more granular that could say for example what task it was, or at least the PID.
Any ideas?
many thanks
Rob
Re: CPU spikes - which process is causing it?
Posted: Fri Mar 02, 2018 10:18 am
by bolson
This plugin might be the ticket for you. It aggregates parent and child (worker) processes and returns the top CPU consumer.
https://exchange.nagios.org/directory/P ... op/details
Re: CPU spikes - which process is causing it?
Posted: Mon Mar 05, 2018 3:53 am
by robatwork
Thanks bolson I will run the rule over that plugin and report back.
Re: CPU spikes - which process is causing it?
Posted: Mon Mar 05, 2018 4:06 am
by robatwork
Hi bolson - I presume this won't run on a remote windows client as it's a bash script?
Excuse the fairly dumb question but I am new to nagios. I know I can run VBS and Python on the windows server....
Re: CPU spikes - which process is causing it?
Posted: Mon Mar 05, 2018 3:18 pm
by npolovenko
@robatwork, Yes, It can be problematic to run a shell script on windows. There is a PowerShell script that you can use though:
https://exchange.nagios.org/directory/P ... 29/details
This script will check the current CPU load (percentage and queue) and physical memory utilization on a windows host and alert based on your arguements. If alerting, it will tell you what process is using the most resources and give you the PID so you can kill it with psexec if the host is inaccessible via traditional methods.
Here's another plugin that does the same:
https://www.itefix.net/check_winprocess
You can choose either one.