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 »

the zip file may have been corrupted.
i have re uploaded it (and also tested the dll on 2 computers).
re download it (sorry...).

http://erwan.labalec.fr/snmptools/snmptools2.zip

/Erwan
Last edited by erwan.l on Wed Apr 11, 2012 11:00 am, edited 1 time in total.
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Yeeessss, all works perfectly :) Thanks, thanks, thanks! :)

Here that I have written in counters.ini:
[1.3.6.1.4.1.15.51.1.1]
type=string
counter=1
[1.3.6.1.4.1.15.51.1.2]
type=string
counter=2

[1.3.6.1.4.1.15.51.2.1]
type=string
counter=Total Sessions
[1.3.6.1.4.1.15.51.2.2]
type=string
counter=Active Sessions

[1.3.6.1.4.1.15.51.3.1]
counter=Terminal Services\Total Sessions
[1.3.6.1.4.1.15.51.3.2]
counter=Terminal Services\Active Sessions
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Glad I could help :)

Eventually, post your graphs and template for others to benefit from your work.

And, thanks a lot for your time & debugging : it does help a lot to improve that tool.

Regards,
Erwan.
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Probably one more defect...
In your program SNMP v.2 protocol is not supported, only v.1 I on was pushed on this thought with the message in a forum: http://forums.cacti.net/viewtopic.php?t=27666
Having looked in an initial code cacti (the file snmp.php) can be found such fragment:
if ($version == "1") {
$temp_array = @snmprealwalk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
}elseif ($version == "2") {
$temp_array = @snmp2_real_walk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
}else{

And so if version 1 all works, and at version 2 $temp_array it is empty.
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hello Viras,
The SNMP agent, hosted by the MS SNMP service, actually does not deal with the snmp version.

Whatsmore, the snmpwalk command line currently works with both version :
snmpwalk -v 2c -c public 127.0.0.1 1.3.6.1.4.1.15
or
snmpwalk -v 1 -c public 127.0.0.1 1.3.6.1.4.1.15
Both work and return the same value.

Reading the post you are mentionning, I suspect an issue at the cacti level (or one of its component).

Still, I'll do extensive check to exclude any error within snmptools.
Basically, if the request fails but you see 'SnmpExtensionQuery' in the log file, then it is an snmptools bug.
If the request fails and you dont see 'SnmpExtensionQuery', then its an issue at the snmp service or within cacti.
Last edited by erwan.l on Sun Aug 31, 2008 5:51 am, edited 1 time in total.
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

version 2.0.0.3 released.
http://erwan.labalec.fr/snmptools/snmptools2.zip

In previous versions, the dll was exporting these 2 functions :
SnmpExtensioninit (when the agent is loaded by the snmp service)
SnmpExtensionQuery (when the agent is receiving a request)

SnmpExtensionQuery only support snmp v1 type : get, getnext and set.

I have now added a 3rd exported function :
SnmpExtensionQueryEx which will support other v2 types (get, getnext, settest, setundo, setcommit, setcleanup).

details here : http://msdn.microsoft.com/en-us/library ... S.85).aspx .

The agent still support only get & getnext requests but at least it will accept other types, and will also log it eventually.

I dont believe this is linked to the issue with snmp v2 from cacti (since simple v2 types were supported from the command line) but at least the code is cleaner :)

Regards,
Erwan.
Last edited by erwan.l on Wed Apr 11, 2012 11:00 am, edited 1 time in total.
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

All the same does not work.
That I did:
1. The menu "Devices"
2. Has chosen the server
3. Has at the very bottom pressed "Verbose Query"
Attachments
log-v1.txt
log-v1
(2.42 KiB) Downloaded 313 times
log-v2.txt
log-v2
(42.67 KiB) Downloaded 444 times
conters.txt
counters.ini
(798 Bytes) Downloaded 354 times
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

nice one Viras.
Indeed there was a bug when walking the oid's (the last oid was not handled correctly).

version 2.0.0.4 released.
http://erwan.l.free.fr/snmptools/snmptools2.zip

I was looking on a issue linked to snmp v1 or v2 where actually there was a bug in the logic.

Thanks for the debugging !

Regards,
Erwan.
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Thanks for the program!

Errors have disappeared, but version 2 does not work. Cacti here it is not guilty, as causes standard function snmp2_real_walk. A problem or in snmp service, or in your program.
Attachments
log-v2.txt
log-v2
(7.17 KiB) Downloaded 286 times
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

indeed, I cant use a dataquery in snmp v2 where it works fine in snmp v1.

in v2 i get
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.15.51.1'
+ No SNMP data returned

where in v1 i get
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.15.51.1'
+ Located input field 'memIndex' [walk]

wierd thing is that snmpwalk works fine via the command line and the snmptools log looks identical in both cases:
snmpwalk -v 2c -c public 127.0.0.1 1.3.6.1.4.1.15.51.1
SNMPv2-SMI::enterprises.15.51.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.15.51.1.2 = INTEGER: 2

working on it.

/erwan
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Try to use snmpbulkwalk...
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

Here my first work server.
Attachments
CPU Time
CPU Time
ts cpu time.png (34.21 KiB) Viewed 6059 times
Number of sessions
Number of sessions
ts sessions.png (24.18 KiB) Viewed 6059 times
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Very nice :)
I like what you did with the snmp query : did not know about this before.
I learned something :)

Need to fix that snmpv2 thing now.
snmpbulkwalk from the command line work fine as well.

I need to dig into cacti to see how the data is queryed.

Thanks,
Erwan
viras
Posts: 16
Joined: Sun Aug 24, 2008 4:21 am

Post by viras »

/usr/local/share/cacti/lib/snmp.php
function cacti_snmp_walk
line 253-256

if ($version == "1") {
$temp_array = @snmprealwalk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
}elseif ($version == "2") {
$temp_array = @snmp2_real_walk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
}else{
ky
Posts: 5
Joined: Wed Sep 03, 2008 2:01 pm

Trouble w/64bit on Server 2003 SP2

Post by ky »

Erwan,

*Awesome* tool, once I get it working. :) Our environment is primarily 64bit (Server 2003 SP2) and I have done the following to get set up:

-Renamed snmptools64.dll to snmptools.dll, moved it to proper dir.
-Configured counters.ini
-Turned on debugging, imported reg file, restarted SNMP.

I am able to query 1.3.6.1.4.1.15 (snmptools by erwan.l@free.fr), I can query anything that defines type=string in counters.ini, but I am not able to get any data from the performance counters.

For these definitions:
[1.3.6.1.4.1.15.1]
counter=PhysicalDisk\Avg. Disk Queue Length\_Total
[1.3.6.1.4.1.15.6]
counter=Processor\% Processor Time

I get this in the log:
14:07:11:465 , SnmpExtensionQueryEx
14:07:11:465 , nRequestType=SNMP_EXTENSION_GET
14:07:11:465 , GetRequest: OID=1.3.6.1.4.1.15 (7)
14:07:11:465 , result=snmptools by erwan.l@free.fr asn_type=4
14:07:11:465 , GetRequest OK
14:15:30:029 , SnmpExtensionQueryEx
14:15:30:029 , nRequestType=SNMP_EXTENSION_GET
14:15:30:029 , GetRequest: OID=1.3.6.1.4.1.15.1 (8)
14:15:30:029 , path=PhysicalDisk\Avg. Disk Queue Length\_Total
14:15:30:029 , PhysicalDisk\Avg. Disk Queue Length\_Total
14:15:30:029 , makepathA : C0000BBD
14:15:30:029 , length(str_result)=0
14:15:30:029 , GetRequest Failed
14:20:54:316 , SnmpExtensionQueryEx
14:20:54:316 , nRequestType=SNMP_EXTENSION_GET
14:20:54:316 , GetRequest: OID=1.3.6.1.4.1.15.6 (8)
14:20:54:316 , path=Processor\% Processor Time
14:20:54:316 , Processor\% Processor Time\
14:20:54:316 , makepathA : C0000BBD
14:20:54:316 , length(str_result)=0
14:20:54:316 , GetRequest Failed

Any suggestions?

Thanks in advance, can't wait to get this going!
-Kyle
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests