SMP CPU load monitoring on Win2k

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

SMP CPU load monitoring on Win2k

Post by bulek »

I have quite powerfull server for my cacti installation. It is four processor Win2k server. I always wanted to add CPU load graph to cacti. I thought - easy, just add proper SNMP MIB and start monitoring. Unfortunately it turned out that Microsoft does not support more than one processor (!!!). In case of multi-processor environment I can monitor the load but values returned are either 0 or 100.

I decided to write a VBScript code that is able to read load from all of four CPUs (actually it works for 2-way and 8-way as well):

cpumon.vbs:

Code: Select all

On Error Resume Next
strComputer = "."
strOutput = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem in colItems
    strOutput = strOutput & objItem.LoadPercentage & " "
Next
Wscript.StdOut.Write(strOutput)
Data Input entry looks as follows: "cscript cpumon.vbs //nologo". There are no input arguments and there are four (or other number deppending on number of your CPUs) output values.

Two components are needed to run the script: WSH and WMI. You can download them from MS web site.

-bulek
Guest

Post by Guest »

are you sure?

I have a dual processor win2k server. And I just tested snmp, and it seems to be working.

HOST-RESOURCES-MIB::hrProcessorLoad.1 = INTEGER: 46
HOST-RESOURCES-MIB::hrProcessorLoad.2 = INTEGER: 5
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

Well... as far as I remember I was receiving either 0 or 100%. Also I found this problem described in many places like:
http://www.hrbac.cz/mrtg/
http://www.geocities.com/Area51/Rampart/9209/#A5

In general MS admits their SNMP counters are unreliable on SMP machines:
http://support.microsoft.com/default.as ... us;q146004

Maybe you had more luck with new net-snmp MIB.

- bulek
sachar
Posts: 14
Joined: Sun Apr 21, 2002 9:52 pm

Post by sachar »

I might be that. But strange enough cacti does show it a a NAN value when trying to graph it. Having this with a lot of SNMP data.

When looking at the graph, it all looks a bit high.

http://hobbes.sa-char.net/cacti/graph.p ... &rraid=all
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

I need a bit of help with this script on the first post as I am doing something wrong.
  • I have created the cpumon.vbs script and copied it to <path_cacti>/scripts
    I then created a new 'Data Input Method' with the Input Type of 'Script/Command' and the input string of 'cscript <path_cacti>/scripts/cpumon.vbs //nologo'
    I then created two Output fields called CPU1 and CPU2 and saved everything
    Next I created a Data Template and selected the newly created Data Input Method
    Then I created a very simply Graph Template with my 1 Data Source item
    Finally I associated the Graph Template with the device
The problem is that no RRA file gets created and therefore no graph gets produced either. Does anyone have a dummies guide for getting a simply WMI connection working with Cacti?

Thanks.
laffen
Cacti User
Posts: 56
Joined: Tue Jul 13, 2004 2:57 am
Location: Norway

Post by laffen »

bulek wrote:Well... as far as I remember I was receiving either 0 or 100%. Also I found this problem described in many places like:
http://www.hrbac.cz/mrtg/
http://www.geocities.com/Area51/Rampart/9209/#A5

In general MS admits their SNMP counters are unreliable on SMP machines:
http://support.microsoft.com/default.as ... us;q146004

Maybe you had more luck with new net-snmp MIB.

- bulek
For Windows installations, have a look at http://www.snmp-informant.com/. The standard version is free and includes counters for memory, processor, logical disk, network interface.
DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

Post by DevilSun »

You guys... :roll: ...use WMI. Microsoft is putting all their stuff in WMI and are doing it well. I'm doing CPU load on a 4 proc machine and it's perfectly accurate all the time. I posted the scripts on here a long time ago in the scripts directory.
ajeskey
Cacti User
Posts: 93
Joined: Mon Mar 28, 2005 4:31 pm
Location: Boston, MA

Post by ajeskey »

I just finished this up this weekend.

http://forums.cacti.net/viewtopic.php?t=7149
I am doing 8way machines with this just fine, you'll just need SNMP-Informant

And as for WMI, get support for Win32::OLE under *nix, then you can start spewing that as the default answer to anything windows based.
DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

Post by DevilSun »

I'm sorry ajeskey, I thought that everyone else who got the WMI stuff to get to run under *nix using nsclient or whatever was a good enough example. Maybe they can hold your hand and spoon you from the left.

As far as this thread, it was posted originally as the person using VBScript and WMI, and has success using it, getting valid values, like most everyone else using it -- who's off base?
ajeskey
Cacti User
Posts: 93
Joined: Mon Mar 28, 2005 4:31 pm
Location: Boston, MA

Post by ajeskey »

I'll take my response to private message, since obviously DevilSun does not know when someone is pointing out faults on software suport and not at the person sending the message.
DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

Post by DevilSun »

Ok, so I'm glad we've all come to the agreement that SNMP in Windows sucks.

If you're doing Windows monitoring using Windows, WMI works fine.

If you're doing Windows monitoring using *nix, SNMP-Informant might work better for you unless you *nix guys can find a decent WMI solution that works for you.

I guess I'm just confused as to when this turned into *nix monitoring windows box problem thread, but so be it. Good luck with your monitoring!!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests