Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from superuser.com Aug 19 '11 at 23:33

This question came from our site for computer enthusiasts and power users.

2 Answers 2

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.)

share|improve this answer
    
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
up vote 1 down vote accepted

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'`
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.