Windows performance counters & VBS/WMI via SNMP

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hello Ky,
I spot one error (and should be able to fix it) on that line :
makepathA : C0000BBD

Alternative right now is to use type exec with counter=c:\yourscript.vbs.

There are examples in the zip file.

In the meantime, I'll check out that error.
Coding on 64bits is much harder than I thought :)

Regards,
Erwan.

edit 1: you can use the perf32.exe (called from the 64bits snmptools agent) included in the zip file.
counters.ini should then be something like this

[1.3.6.1.4.1.15.8]
type=exec
counter=c:\perf32.exe "Processor\% Processor Time\_Total"

edit 2: I realise the counter in your log file is wrong :
14:20:54:316 , path=Processor\% Processor Time
14:20:54:316 , Processor\% Processor Time\

you are missing the instance name?
it should be something like this :Processor\% Processor Time\_Total
ky
Posts: 5
Joined: Wed Sep 03, 2008 2:01 pm

Post by ky »

That wasn't the best log file to use, I was playing around trying to get it to work the other day. I still get the same behavior when I use the proper counter definition.

As for perf32, that works great. The only problem is, I can't query something that has parenthesis in the name...

SQLServer:Databases\DataFile(s) Size (KB)\_Total returns "null" but SQLServer:Databases\Active Transactions\_Total works just fine. It appears a lot of SQL counters use () in their name....

Thanks again for the help, this is going to be quite handy.
-Kyle
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hello Ky,
I have reuploaded snmptools2.zip with a modification for the makepath error.
Redownload it and give it a try.
http://erwan.l.free.fr/snmptools/snmptools2.zip

Regarding perf32.exe, nice bug : I'll fix it quickly.

Thanks for the debugging !

Regards,
Erwan.

edit : about perf32.exe, you may find the right counter syntax with the following command lines :
perf32 /enumobjects
perf32 "SQLServer:Databases" /enumobjectitems
MadX
Posts: 31
Joined: Wed Apr 23, 2008 7:10 pm

hi erwan

Post by MadX »

hi erwan how r you, i hop u r doing fine

i`m trying to grapho a remote windows host pinging to yahoo for example, so if i write in the counters.ini :

[1.3.6.1.4.1.15.5]
type=exec
counter=cmd /c ping yahoo.com -n 1

the return for this is the full result of the pinging progress like this

snmpget -v 2c -c public host.eee.cc 1.3.6.1.4.1.15.5

Pinging yahoo.com [206.190.60.37] with 32 bytes of data:
Reply from 206.190.60.37: bytes=32 time=211ms TTL=53

Ping statistics for 206.190.60.37:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 211ms, Maximum = 211ms, Average = 211ms

so how can i get this to work and only graph the 211ms if in the above example
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hello Madx,
A vbs script would be easier I believe.

Call the attached script like that : cscript c:\wmi_ping.vbs www.yahoo.com

You then get something like this :
cscript /nologo c:\wmi_ping.vbs www.yahoo.com
49

Regards,
Erwan.
Attachments
wmi_ping.txt
(411 Bytes) Downloaded 272 times
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Hello MadX
try this command:
ping -n 1 google.com |findstr /i ttl | sed -r "{s/(.*)=([0-9]*)(.*)=(.*)/\2/}"

BUT you must download small programm sed for windows.
http://gnuwin32.sourceforge.net/packages/sed.htm

direct link:
sed: http://gnuwin32.sourceforge.net/downlin ... in-zip.php
sed dll: http://gnuwin32.sourceforge.net/downlin ... ep-zip.php
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Ky,
The mssqlserver works fine other here :

08:35:28:359 , GetRequest: OID=1.3.6.1.4.1.15.8 (8)
08:35:28:359 , path=SQLServer:Databases\data file(s) size (kb)\iptools
08:35:28:375 , MakePath ok :\SQLServer:Databases(iptools)\Data File(s) Size (KB)
08:35:29:390 , Value=1024 asn_type=2
08:35:29:390 , GetRequest OK

can you send me your log with a similar counter?

Viras : nice one indeed.
Plus, le wmi_ping class is only available starting with xp & w2k3 so the sed alternative is handy!

/erwan
ky
Posts: 5
Joined: Wed Sep 03, 2008 2:01 pm

Post by ky »

Erwan,

I updated the DLL and am getting the following:

For this counter.ini:
[1.3.6.1.4.1.15.1]
type=exec
counter=c:\perf32.exe "SQLServer:General Statistics\User Connections"
[1.3.6.1.4.1.15.2]
counter=SQLServer:General Statistics\User Connections

I get "410" for 15.1, and "0" for 15.2. Here's the log:.

12:56:50:070 , SnmpExtensionQueryEx
12:56:50:070 , nRequestType=SNMP_EXTENSION_GET
12:56:50:070 , GetRequest: OID=1.3.6.1.4.1.15.1 (8)
12:56:51:257 , Value=410 asn_type=2
12:56:51:257 , GetRequest OK
12:58:49:759 , SnmpExtensionQueryEx
12:58:49:759 , nRequestType=SNMP_EXTENSION_GET
12:58:49:759 , GetRequest: OID=1.3.6.1.4.1.15.2 (8)
12:58:49:759 , path=SQLServer:General Statistics\User Connections
12:58:49:759 , MakePath2 : ok
12:58:49:759 , MakePath ok :\SQLServer:General Statistics\User Connections
12:58:50:759 , Value=0 asn_type=2
12:58:50:759 , GetRequest OK

I notice a leading ":" on the MakePath line... Any thoughts?

-Kyle
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hi Ky,

I believe this one is right
12:56:50:070 , GetRequest: OID=1.3.6.1.4.1.15.1 (
12:56:51:257 , Value=410 asn_type=2
(although this is a lot of users!)

not this one
12:58:49:759 , MakePath ok :\SQLServer:General Statistics\User Connections
12:58:50:759 , Value=0 asn_type=2

I have been reported that 64bits applied to counters does not work yet :
integer values always report 0 and float values report out of range figures.

About the leading ":", it is only a log display issue.

The good thing is that you have a workaround to get performance values against a windows server 64bits via snmp (using perf32.exe).
Bad thing is that I need to understand how pointers work in 64bits dev :(

Soon, snmptools 64bits will natively support performance counters without having to use a 32bits executable.

Regards,
Erwan

edit1 : you may try
[1.3.6.1.4.1.15.2]
flag=raw
counter=SQLServer:General Statistics\User Connections

in order to retrieve a raw value instead of a formatted value.
This will always return int64 values. (not float thus).
Maybe the pdh API in use then will behave better.

/Erwan
ky
Posts: 5
Joined: Wed Sep 03, 2008 2:01 pm

Post by ky »

Erwan,

You're correct, 410 is right (it also shows up as 410 in perfmon). That's our main SQL server for our ERP software so that's about normal.

Things are working great with perf32, I'm getting all kinds of good data into cacti now. Thanks again for all your help and work on this. That's gonna be a pretty popular tool I predict! :)

-Kyle
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

64 bits support

Post by erwan.l »

Hi Ky,
I'm glad to see it is working for you in 64bits mode.

Note that you can use the 32bits version under win64 (I just found this out).

Delete (or rename) the old snmptools registry key and create that one :
(and put the snmptools.dll 32bits version in your windows folder, not system32).
more details here : http://erwan.l.free.fr/snmptools/#64bits .

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\snmptools\currentversion]
"counters"="c:\\counters.ini"
"debug"="1"
"pathname"="%systemroot%\\snmptools.dll"

This way you can benefit from the more debugged 32bits version.

On the other side, the 64bits is native and is almost complete.
For performance counters returning dword values (not float) and not requiring calculations (like your sql number of users), add the following flag :

[1.3.6.1.4.1.15.2]
flag=raw,hi
counter=SQLServer:General Statistics\User Connections

This will return the correct raw performance counter value and specifically the hi part (dword) part of the int64 value.
This is a limited workaround for a bug in the snmptools64.dll and 32bits values in 64bits variables.

Regards,
Erwan.

edit1 : you need latest version 2.0.0.5 .

edit2 : Ky, dont hesitate to post graphs you get via snmptools.
This could help other users.

edit3 : note that by default, the snmp agent will take 1 sec to return as it will collect two set of datas (for counters that require calculation).
you can have the snmp agent return the value immediately like this :

[1.3.6.1.4.1.15.2]
flag=raw,hi,norefresh
counter=SQLServer:General Statistics\User Connections
MadX
Posts: 31
Joined: Wed Apr 23, 2008 7:10 pm

Thank you all

Post by MadX »

Thank you erwan for help, u 2 viras

any way this is the graph for pinging 3 different targets, so i can check my ping to yahoo.com and to gateways of my double DSL Lines.
Attachments
Captureok.JPG
Captureok.JPG (62.56 KiB) Viewed 6693 times
ky
Posts: 5
Joined: Wed Sep 03, 2008 2:01 pm

Post by ky »

Erwan,

I gave the WOW6432 method a shot, first deleting the original keys and starting from there. After getting the .dll in place, importing the regagentWOW6432.reg, and restarting the SNMP service I got no response (no log with debug=1, no response to 1.3.6.1.4.1.15, etc). I did notice the [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents] key is not in the WOW6432 registry file, does it need to be to work properly? I switched back to 64bit and all is well again.

As far as the flag=raw,hi workaround goes I am having some strange behavior.

For this:
[1.3.6.1.4.1.15.9]
counter=Processor\% Processor Time\_Total

I get 1.31878521153509E-282 (not correct).

For this:
[1.3.6.1.4.1.15.9]
flag=raw,hi
counter=Processor\% Processor Time\_Total

I get -533325531 (not correct).


I think I'll just stick with the 64bit version and try to help you with the debugging process.

I will definitely post some graphs once I get everything situated. Thanks as always.
-Kyle
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hi Ky,
Thanks for your feedback.

Indeed, so far, the 64bits version works only with the flag=raw,hi and only with dword values (not float ones), which makes it limited so far...

For instance, the following counter will work under win64 with these flags:
counter=LogicalDisk\Free Megabytes\_Total. (dword value).

About snmptools, as any snmp agent, it needs 2 part in the registry :

1/ (the name of the agent to load and where in the registy to find the pathname)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents]
"snmptools"="SOFTWARE\\snmptools\\CurrentVersion"

2/ (the path where to find the agent and some other agent details)
[HKEY_LOCAL_MACHINE\SOFTWARE\snmptools\currentversion]
"Pathname"="%systemroot%\\snmptools.dll"
"counters"="c:\\counters.ini"

This is is true on win32 and win64 platform.

But on win64, you can also load 32bits agents by altering step 2 above and modifying this key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\snmptools\currentversion]
"counters"="c:\\counters.ini"

This will tell windows to load the agent using the 32bits snmp.exe (will show as snmp *32 in the tasklist).

And you are right : I checked the registry file, it was wrong :(
I exported it from my win64 server (where the 32bits agent is working) but I forgot to also export the first part...
I updated the zip file and reuploaded it.

Thanks for pointing this out as it may help other using the 32bits version on win64.

Thanks also for sticking to the 64bits version so that I may have a chance to fix the counters value bug.
In the meantime, I am glad that perf32.exe does its job :)

Regards,
Erwan.
sjw7
Posts: 11
Joined: Tue Jul 01, 2008 8:35 am

Post by sjw7 »

Hi erwan.l

Thankyou for creating this dll as it is exactly the thing we have been looking for.

I have come across an issue though and im not sure if its to do with snmptools or with cacti.

We have cacti 0.8.7b and I am using the 32bit version of snmptools with our 64bit 2003 servers because i was getting some strange results with the 64bit version of the dll.

The odd thing happens when i set Cacti to poll using spine. The Cacti log shows the following

09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1506] SNMP: v2: 172.16.11.154, dsname: pmProcTime1, oid: .1.3.6.1.4.1.15.2.1.2, value: 0
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1507] WARNING: Result from SNMP not valid. Partial Result: ...
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1507] SNMP: v2: 172.16.11.154, dsname: pmProcTime2, oid: .1.3.6.1.4.1.15.2.1.3, value: U
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1508] WARNING: Result from SNMP not valid. Partial Result: ...
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1508] SNMP: v2: 172.16.11.154, dsname: pmProcTimeTot, oid: .1.3.6.1.4.1.15.2.1.1, value: U
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1509] WARNING: Result from SNMP not valid. Partial Result: ...
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1509] SNMP: v2: 172.16.11.154, dsname: pmPrivBytesSqlSvr, oid: 1.3.6.1.4.1.15.3.2.1, value: U
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1510] WARNING: Result from SNMP not valid. Partial Result: ...
09/10/2008 09:50:10 AM - SPINE: Poller[0] Host[136] DS[1510] SNMP: v2: 172.16.11.154, dsname: pmProcTimeSqlSvr, oid: 1.3.6.1.4.1.15.3.1.1, value: U

when i switch on debug mode in snmptools the log file shows the following.

09:50:10:448 , Value=0 asn_type=2
09:50:10:448 , GetRequest OK
09:50:10:448 , SnmpExtensionQueryEx
09:50:10:448 , nRequestType=SNMP_EXTENSION_GET
09:50:10:463 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
09:50:10:463 , path=Processor\% Processor Time\0
09:50:10:463 , MakePath ok :\Processor(0)\% Processor Time
09:50:11:463 , Value=0 asn_type=2
09:50:11:463 , GetRequest OK
09:50:11:463 , nRequestType=SNMP_EXTENSION_GET
09:50:11:463 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
09:50:11:463 , path=Processor\% Processor Time\0
09:50:11:479 , MakePath ok :\Processor(0)\% Processor Time
09:50:12:479 , Value=4.68261975013121 asn_type=4
09:50:12:479 , GetRequest OK
09:50:12:479 , nRequestType=SNMP_EXTENSION_GET
09:50:12:479 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
09:50:12:495 , path=Processor\% Processor Time\0
09:50:12:495 , MakePath ok :\Processor(0)\% Processor Time
09:50:13:495 , Value=3.120039746035 asn_type=4
09:50:13:495 , GetRequest OK
09:50:13:526 , nRequestType=SNMP_EXTENSION_GET
09:50:13:541 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
09:50:13:557 , path=Processor\% Processor Time\0
09:50:13:573 , MakePath ok :\Processor(0)\% Processor Time
09:50:14:588 , Value=1.55745974193878 asn_type=4
09:50:14:588 , GetRequest OK
09:50:14:604 , nRequestType=SNMP_EXTENSION_GET
09:50:14:604 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
09:50:14:619 , path=Processor\% Processor Time\0
09:50:14:619 , MakePath ok :\Processor(0)\% Processor Time
09:50:15:635 , Value=1.55745974193878 asn_type=4
09:50:15:635 , GetRequest OK

However if i switch over to using cmd.php i see the following type of entries in the cacti log. (i have not included every entry here)

09/10/2008 10:13:31 AM - CMDPHP: Poller[0] Host[136] DS[1509] SNMP: v2: 172.16.11.154, dsname: pmPrivBytesSqlSvr, oid: 1.3.6.1.4.1.15.3.2.1, output: 1804632064
09/10/2008 10:13:31 AM - CMDPHP: Poller[0] DEBUG: SQL Exec: "insert into poller_output (local_data_id, rrd_name, time, output) values (1509, 'pmPrivBytesSqlSvr', '2008-09-10 10:13:24', '1804632064')"
09/10/2008 10:13:33 AM - CMDPHP: Poller[0] Host[136] DS[1510] SNMP: v2: 172.16.11.154, dsname: pmProcTimeSqlSvr, oid: 1.3.6.1.4.1.15.3.1.1, output: 1.56258000409621
09/10/2008 10:13:33 AM - CMDPHP: Poller[0] DEBUG: SQL Exec: "insert into poller_output (local_data_id, rrd_name, time, output) values (1510, 'pmProcTimeSqlSvr', '2008-09-10 10:13:24', '1.56258000409621')"
09/10/2008

and the snmptools log shows the following.

10:13:24:908 , SnmpExtensionQueryEx
10:13:24:923 , nRequestType=SNMP_EXTENSION_GET
10:13:24:923 , GetRequest: OID=1.3.6.1.4.1.15.2.1.2 (10)
10:13:24:923 , path=Processor\% Processor Time\0
10:13:24:923 , MakePath ok :\Processor(0)\% Processor Time
10:13:25:923 , Value=3.120039746035 asn_type=4
10:13:25:923 , GetRequest OK
10:13:26:111 , SnmpExtensionQueryEx
10:13:26:111 , nRequestType=SNMP_EXTENSION_GET
10:13:26:126 , GetRequest: OID=1.3.6.1.4.1.15.2.1.3 (10)
10:13:26:126 , path=Processor\% Processor Time\1
10:13:26:126 , MakePath ok :\Processor(1)\% Processor Time
10:13:27:126 , Value=0 asn_type=2
10:13:27:126 , GetRequest OK
10:13:27:376 , SnmpExtensionQueryEx
10:13:27:392 , nRequestType=SNMP_EXTENSION_GET
10:13:27:392 , GetRequest: OID=1.3.6.1.4.1.15.2.1.1 (10)
10:13:27:392 , path=Processor\% Processor Time\_Total
10:13:27:408 , MakePath ok :\Processor(_Total)\% Processor Time
10:13:28:408 , Value=0.776169739890686 asn_type=4
10:13:28:408 , GetRequest OK
10:13:29:907 , SnmpExtensionQueryEx
10:13:29:923 , nRequestType=SNMP_EXTENSION_GET
10:13:29:923 , GetRequest: OID=1.3.6.1.4.1.15.3.2.1 (10)
10:13:29:923 , path=Process\Private Bytes\sqlservr
10:13:29:923 , MakePath ok :\Process(sqlservr)\Private Bytes
10:13:30:939 , Value=1804632064 asn_type=2
10:13:30:939 , GetRequest OK
10:13:32:204 , SnmpExtensionQueryEx
10:13:32:204 , nRequestType=SNMP_EXTENSION_GET
10:13:32:204 , GetRequest: OID=1.3.6.1.4.1.15.3.1.1 (10)
10:13:32:220 , path=Process\% Processor Time\sqlservr
10:13:32:220 , MakePath ok :\Process(sqlservr)\% Processor Time
10:13:33:220 , Value=1.56258000409621 asn_type=4
10:13:33:220 , GetRequest OK

This is all correct and i get graphs. The only problem is that we need to use spine because of the number of items being monitored and things get missed if i use cmd.php.

It looks as though spine is sending query requests to the server correctly but is not recieving back correct responses. The only difference i can see is that spine is sending a group of requests at the same time where as cmd.php sends them a second or two appart. Is snmptools getting confused by multiple requests at the same time and then just responds to all requests with the result of the first one?

If you can provide any help it would be much appreciated as this dll you have created is of massive benefit to us.

Many thanks in advance

Simon
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests