Page 1 of 2

Monitoring a service or process

Posted: Mon Aug 04, 2014 2:00 pm
by lmeek
I have been asked to monitor a specific third party service
I can monitor the up/down state of the service but im looking for a way to get alerted based on memory/cpu usage.

Im not really sure where to go from here. I guess I should be using wmiPlus? If someone knows of a previously published writeup on the topic I can research it that way.
But my searching hasn't turned up anything useful.

Re: Monitoring a service or process

Posted: Mon Aug 04, 2014 2:07 pm
by tmcdonald
What platform is the service running on? It sounds like Windows based off of your WMI suggestion.
Are you looking to find out how much RAM and CPU that specific service is using?

Re: Monitoring a service or process

Posted: Mon Aug 04, 2014 2:18 pm
by lmeek
Nagios is running on Linux. But my enterprise is all Windows.
I used the preconfigure VM and purchased licensing.

Yes, I would like to be able to monitor CPU/RAM usage for that specific service and get alerted if it goes over a certain threshold.

Re: Monitoring a service or process

Posted: Mon Aug 04, 2014 10:26 pm
by Box293
A service will be a running executable. Here are some examples:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H 10.25.14.2 -u Administrator -p password -m checkproc -s cpu -a spoolsv%

OK (Sample Period 75 sec) - Found 1 Instance(s) of "spoolsv%" running. CPU_spoolsv(PID=504)=0.0%   |'Process Count'=1; 'Avg Utilisation CPU_spoolsv'=0.0%; 

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H 10.25.14.2 -u Administrator -p password -m checkproc -s memory -a spoolsv%

OK - Found 1 Instance(s) of "spoolsv%" running. Total Private Memory=5.617MB, Total Working Set=9.984MB, Total Virtual Memory=0.075GB\nProcesses Found are  spoolsv (PID=504|'Process Count'=1; 'Total Private Memory'=5890048Bytes; 'Total Working Set'=10469376Bytes; 'Total Virtual Memory'=80183296Bytes; 
For a full list of options including how to define warning and critical:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl --itexthelp

Re: Monitoring a service or process

Posted: Tue Aug 05, 2014 8:51 am
by lmeek
I'm pretty new to Nagios, and Linux environments. So this has been a double whammy for me.
What do I do with those commands?

Here?
Image

I'll gladly read some documentation on how to do these basics I just had a hard time finding it.

Re: Monitoring a service or process

Posted: Tue Aug 05, 2014 4:46 pm
by jomann
What you showed is exactly where you need to add to the definition to get it to run what you want. Whatever you change there will only affect the service you're changing it on. Basically take the ending command (the -s and -a) and put it in for whatever windows process you're trying to monitor. You can check to see if your command is running fine by doing the "Test Check Command" and it should show you the command it is running so you can see if everything is getting added to it properly.

Re: Monitoring a service or process

Posted: Wed Aug 06, 2014 11:30 am
by lmeek
I'm just not getting it. Would you be so kind as to post an example screenshot?
Ive tried every permutation of these commands in the screenshot above and it doesn't seem to be acknowledging them.

Re: Monitoring a service or process

Posted: Wed Aug 06, 2014 11:39 pm
by Box293
These two screenshots should clearly explain it.
Selection_092.png
Selection_093.png

Re: Monitoring a service or process

Posted: Thu Aug 07, 2014 8:32 am
by lmeek
That did it! The memory checker is working like a champ. But im having an issue with the CPU check.
its configured the same so not sure why this is happening.



Image

Error: UNKNOWN - Permission denied when trying to store the state data. Sometimes this happens if you have been testing the plugin from the command line as a different user to the Nagio process user. You will need to change the permissions on the file or remove

Re: Monitoring a service or process

Posted: Thu Aug 07, 2014 4:36 pm
by Box293
There are some files in /tmp that get created (probably when tested as root) and the nagios process cannot update them.

cwpss_checkcpu_1025142___.state
cwpss_checkproccpu_1025142_spoolsv__.state

Execute this command at the CLI and it should fix the problem:

Code: Select all

chmod a+rw /tmp/cwp*