2

I have a Windows Server 2003 machine with SNMP turned on. I want to be able to query the battery level of the server since it is connected to an APC UPS through a USB cable.

So far I can do:

snmpwalk -Os -c public -v 1 192.168.128.2 1.3.6.1.4.1.318

And get:

enterprises.318.1.1.1.4.1.1.0 = INTEGER: 1
enterprises.318.1.2.1.1.1.0 = STRING: "PowerChute Business Edition Agent, (C) 2001 APC."

However I'm nowhere near getting an actual OID that has the percentage of battery remaining. Any ideas?

JorgeO
  • 170
  • 7

2 Answers2

1

You can get better information from WMI. The Win32_Battery class should get you what you need.

I recommend downloading scriptomatic2 from Microsoft to see what that class provides and some starter code to get you going. (For best results, copy the Scriptomatic executable to that machine and run it from there so that it can read the system's CIM namespace.)

gWaldo
  • 11,957
  • 8
  • 42
  • 69
  • These answer sound interesting. But since im doing the query from linux it would be harder to use Windows Management Instrumentation protocol. – JorgeO Aug 22 '11 at 15:38
  • Brutal... Yes, that would be a problem. You can do this from Perl/Python/Ruby, but you may need some black-magic to get it going. (In perl, you want Win32::OLE) – gWaldo Aug 22 '11 at 16:31
1

The OID is: .1.3.6.1.4.1.318.1.1.1.2.2.1.0
Furthermore, to get the value in bash so you can use it within a script do:

# snmp query that returns battery level
BATTERY=`snmpwalk -Os -c public -v 1 192.168.0.107 .1.3.6.1.4.1.318.1.1.1.2.2.1.0 | sed 's/.*: //g'`
# snmp query that returns input voltage
INPUT_VOLTAGE=`snmpwalk -Os -c public -v 1 192.168.0.107 .1.3.6.1.4.1.318.1.1.1.3.2.1.0 | sed 's/.*: //g'`
JorgeO
  • 170
  • 7