Page 1 of 1

Check CPU usage in seconds

Posted: Mon Apr 18, 2016 6:42 am
by bostjanc
Hi guys.
Do you think it could be possible to monitor Windows process with nagios in scenario where you wish to get an alarm when process.exe consumes 50% of CPU more then 10 seconds.
Or when process consumes 3GB of memory more then n-seconds?
Any ideas how to achieve that?
with best regards

Re: Check CPU usage in seconds

Posted: Mon Apr 18, 2016 1:04 pm
by rkennedy
While it's possible, I wouldn't recommend it. Based on what you mention here, you'll be checking the Windows machine every few seconds, which I'd advise against for many reasons.

You could create a plugin, that runs a check for you over the CLI, and then stores that information. Now, have it wait x seconds, and execute the same check again. Have your plugin compare the results, and output them to Nagios. You would most likely need to write this yourself, or see if you can find something that works for you on our exchange @ https://exchange.nagios.org.

Re: Check CPU usage in seconds

Posted: Mon Apr 18, 2016 1:09 pm
by bwallace
I agree with rkennedy - I would not encourage any check to occur every few seconds or so, either. In fact, one minute is the smallest check frequency Nagios is capable of conducting.

The Nagios XI Windows server wizard enables you to set thresholds for memory, CPU, etc but does not allow for what you're talking about - if process abc.exe is using 50% CPU for a sustained 10 seconds.

I did a quick check at our exchange site for a plugin containing this functionality and did not find anything. You can have a look to see if I missed something, but I suspect you'd have to write this yourself, as rkennedy mentioned.
https://exchange.nagios.org/index.php?o ... 0processes

Re: Check CPU usage in seconds

Posted: Tue Apr 19, 2016 7:12 am
by nozlaf
as an alternative you could just trigger if CPU exceeded threshold then return the process list with the memory and cpu time in the list
if you look at the nsclient documentation and do a little massaging you should be able to get it to work

Code: Select all

https://docs.nsclient.org/reference/windows/CheckSystem.html#check-process
for the memory threshold you certainly can trigger if the process has exceeded the memory limit also included in the previous link

Re: Check CPU usage in seconds

Posted: Tue Apr 19, 2016 9:50 am
by rkennedy
To add to what @nozlaf mentioned, could always log the top mem / cpu processes locally as well. I wrote a few scripts you could use to do so here -
https://support.nagios.com/forum/viewto ... 39#p167539