How to monitor process CPU usage on Windows box via Nagios?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
mcfuzz
Posts: 12
Joined: Thu Oct 27, 2011 9:10 pm

How to monitor process CPU usage on Windows box via Nagios?

Post by mcfuzz »

Hi all,

I've been scouring the well for quite a few days now trying to figure out an easy way to check for any process's CPU utilization on a Windows box either using nsclient++ or SNMP from a linux based NAGIOS host. I figured out how to check for the memory utilization of a single process via SNMP but checking CPU utilization alludes me... I found a script - check_snmp_process.pl which can return CPU utilization by using either the -F or -u parameter (http://nagios.manubulon.com/snmp_process.html) - alas it fails since it just returns "UNKNOWN" all the time :(


Does anyone have an idea or can lead me in the right direction?

Thanks!
mcfuzz
Posts: 12
Joined: Thu Oct 27, 2011 9:10 pm

Re: How to monitor process CPU usage on Windows box via Nagi

Post by mcfuzz »

Bump! Anyone? :(
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: How to monitor process CPU usage on Windows box via Nagi

Post by jsmurphy »

Unfortunately I don't know of any (easy) way to accomplish monitoring the CPU of a single process... you may be able to do something with WMI or by writing your own custom script for NSClient to execute.

In order for the SNMP script you linked to work, you will need to ensure some kind of SNMP agent is installed on the windows server... which is something I've never personally done so I'm afraid I can't be much more help than that.
raggmopp
Posts: 17
Joined: Fri Oct 28, 2011 8:42 am

Re: How to monitor process CPU usage on Windows box via Nagi

Post by raggmopp »

There is the check_nt and a version of nrpe for winblows. Allows for checks on disk queue, HD usage, memory usage, CPU Load, Paging file, etc. Plus you can make your own.
mcfuzz
Posts: 12
Joined: Thu Oct 27, 2011 9:10 pm

Re: How to monitor process CPU usage on Windows box via Nagi

Post by mcfuzz »

raggmopp wrote:There is the check_nt and a version of nrpe for winblows. Allows for checks on disk queue, HD usage, memory usage, CPU Load, Paging file, etc. Plus you can make your own.
The check_nt plugin only checks the general CPU utilization :(
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: How to monitor process CPU usage on Windows box via Nagi

Post by mguthrie »

Not sure if this would do it or not, but this is from a search on exchange.nagios.org
http://exchange.nagios.org/directory/Pl ... TK/details
mcfuzz
Posts: 12
Joined: Thu Oct 27, 2011 9:10 pm

Re: How to monitor process CPU usage on Windows box via Nagi

Post by mcfuzz »

mguthrie wrote:Not sure if this would do it or not, but this is from a search on exchange.nagios.org
http://exchange.nagios.org/directory/Pl ... TK/details

:\ it doesn't quite do the trick. I have to actually feed it argument - such as "Tell me if you this process ran for more than 1 hour" - and then it'd spit out "OK" "critical" "warning" etc... not an actual response as far as how much it ran for, how much RAM it is utilizing...
raggmopp
Posts: 17
Joined: Fri Oct 28, 2011 8:42 am

Re: How to monitor process CPU usage on Windows box via Nagi

Post by raggmopp »

The check_nt does more than CPU. It will do disk usage, memory, paging file

Another solution, one that I did, is to install cygwin. Then you can install the nrpe and create UN*X like shell scripts for monitoring.
If you cannot install cygwin, look again at check_nt. I did a google search using only 'check_nt' as the search parameter. The 1st choice you that the check_nt works in conjunction with the NSClient.
mcfuzz
Posts: 12
Joined: Thu Oct 27, 2011 9:10 pm

Re: How to monitor process CPU usage on Windows box via Nagi

Post by mcfuzz »

raggmopp wrote:The check_nt does more than CPU. It will do disk usage, memory, paging file

Another solution, one that I did, is to install cygwin. Then you can install the nrpe and create UN*X like shell scripts for monitoring.
If you cannot install cygwin, look again at check_nt. I did a google search using only 'check_nt' as the search parameter. The 1st choice you that the check_nt works in conjunction with the NSClient.
The box does have Cygwin installed on it already... hrmm... would you mind providing some pointers...? Maybe share a script?

Thanks :D
raggmopp
Posts: 17
Joined: Fri Oct 28, 2011 8:42 am

Re: How to monitor process CPU usage on Windows box via Nagi

Post by raggmopp »

The following page will give you the instructions for installing and configuring NSClient++.
As can be seen, cpu, memory, disk space, service states, etc. are available from NSClient++ (via check_nt)
http://nagios.sourceforge.net/docs/3_0/ ... ndows.html

The NRPE for WIN instructions can be found here
http://itbod.wordpress.com/2010/08/10/h ... dows-host/
or here
http://www.miwi-dv.com/nrpent/

The NAG server is RH5. This WIN client is 2003 SP2. This WIN client used to be a backup server running NetBackup - we have since migrated to a RH system for NBU.

The scripts below are an example of monitoring outside NSClient++ as I am also using nrpe for some custom stuff.
This example provides a check of how many tapes are in the library when running NetBackup. I setup 2 different scripts for custom monitors

Developing the scripts required a little more work - not much. Mainly had to create 2 scripts, one for WIN so it could call and execute the shell script and the shell script itself

check_alltapes.cmd
@echo off
set CYGWIN=binmode tty ntsec
e:\cygwin\bin\bash -l alltapes


alltapes
#!/bin/bash
#set -xv
#Nagios Return codes
#OK = 0
#WARN = 1
#CRIT = 2
#UNK = 3
# threshold parameters
WARN=15
CRIT=10
NUM=`/d/Program\ Files/VERITAS/Volmgr/bin/vmquery -rn 0 -bx | sed '1,3d' | wc -l`

#echo $NUM
#echo $WARN
#echo $CRIT

if [ ${NUM} -gt ${WARN} ]
then
echo "Number of tapes in library = $NUM | \=$NUM;$WARN;$CRIT;0;500"
exit 0
elif [ ${NUM} -le ${WARN} ] && [ ${NUM} -gt ${CRIT} ]
then
echo "Number of tapes in library = $NUM | \=$NUM;$WARN;$CRIT;0;500"
exit 1
else [ ${NUM} -le ${CRIT} ]
echo "Number of tapes in library = $NUM | \=$NUM;$WARN;$CRIT;0;500"
exit 2
fi


The locations for my install is different, I am working of the E: drive. Shouldn't matter where you install, as long as you make the mods for the PATH

I did this some years back (early 2010) but it has been running reliably. And since I am not into WIN, I too had to do lots of searching and experimenting.
The only problem I have found was that the NSClient++ would die off occasionally, putting the restart in the services makes sure the process would restart.

I hope I got you started. Let me know if more information is required.
A google search turned up lots of posts about NAG on WIN. There is even a "winrpe" available for WIN. (This was not available when I did this install, you may want to check it out.)
Locked