snmpget-centos-APC-temperature-using-snmp
apt-get install snmp
snmpget -c public hostname system.sysDescr.0
get the sysdescr.0 variable using the "public" security level from system "zeus" -c = community string
snmpwalk -v1 -c public 192.168.1.10 sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: APC Web/SNMP Management Card
(MB:v3.8.6 PF:v5.0.3 PN:apc_hw05_aos_503.bin AF1:v5.0.3 AN1:apc_hw05_sumx_503.bin MN:AP9630 HR:05 SN: JA1018010654 MD:04/27/2010)
(Embedded PowerNet SNMP Agent SW v2.2 compatible)
Simple Network Management Protocol
is it better than ping? - yes depending on the device manufacturer
snmpwalk = walk the OID tree based on a starting OID or by default with no OID
snmpwalk -v1 -c public 192.168.1.10
an example APC (universal power supply) Management Information Base
ftp://ftp.apc.com/apc/public/software/pnetmib/mib/391/
The more advanced info require SNMP v2 (or v3) which require authentication... This crazy OID = Environment Temperature in degrees celsius
.1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1
.1.3.6.1.4.1.318.1.1.1.2.2.2.0 Internal Temperature in degree celsius
1.3.6.1.4.1.318.1.1.1.2.2.1.0 upsAdvBatteryCapacity (gauge, in %)
.1.3.6.1.4.1.318.1.1.1.4.2.3.0 upsAdvOutputLoad (gauge, in %)
.1.3.6.1.4.1.318.1.1.1.4.2.1.0 upsAdvOutputVoltage (gauge, in VAC)
.1.3.6.1.4.1.318.1.1.1.4.2.2.0 upsAdvOutputFrequency (gauge, in Hz)
.1.3.6.1.4.1.318.1.1.1.3.2.1.0 upsAdvInputLineVoltage (gauge, in VAC)
.1.3.6.1.4.1.318.1.1.1.3.2.4.0 upsAdvInputFrequency (gauge, in Hz)
.1.3.6.1.4.1.318.1.1.1.2.2.3.0 upsAdvBatteryRunTimeRemaining (timeticks)
BUT remember, these can change from device to device (oh so simple...)
"Walking" the "enterprise" list is the best way of finding out the exact details:
"enterprises" = .1.3.6.1.4.1.318 in apc only? APC 3000XL w/ web mgmt card
snmpwalk -v1 -c public 10.10.1.224 .1.3.6.1.4.1.318
snmpwalk -v1 -c public 192.168.1.10 enterprises
e.g. big list of the following...
SNMPv2-SMI::enterprises.318.1.4.2.2.1.9.3 = STRING: "Port 1:Temp 1"
SNMPv2-SMI::enterprises.318.1.1.10.1.2.2.1.22.1 = STRING: "Temp Sensor 1"
SNMPv2-SMI::enterprises.318.1.1.10.1.2.2.1.22.2 = STRING: "Temp Sensor 2"
get/picking a specific item
snmpget -v1 -c public 192.168.1.10 enterprises.318.2.1.6.1.0
SNMPv2-SMI::enterprises.318.2.1.6.1.0 = STRING: "09/14/2010"
aha, the current date! perhaps make your life a little easier...
http://support.ipmonitor.com/mibs/POWERNET-MIB/oids.aspx
This is an approx temperature in celsius...
snmpget -v1 -c public 192.168.1.10 enterprises.318.1.1.1.2.0
SNMPv2-SMI::enterprises.318.1.1.1.2.2.2.0 = Gauge32: 28
BUT better to see all that's available from this little section:
snmpwalk -v1 -c public 192.168.1.10 enterprises.318.1.1.1.2
SNMPv2-SMI::enterprises.318.1.1.1.2.1.1.0 = INTEGER: 2
SNMPv2-SMI::enterprises.318.1.1.1.2.1.2.0 = Timeticks: (0) 0:00:00.00
SNMPv2-SMI::enterprises.318.1.1.1.2.1.3.0 = STRING: "01/23/10"
SNMPv2-SMI::enterprises.318.1.1.1.2.2.1.0 = Gauge32: 100
SNMPv2-SMI::enterprises.318.1.1.1.2.2.2.0 = Gauge32: 28
SNMPv2-SMI::enterprises.318.1.1.1.2.2.3.0 = Timeticks: (1008000) 2:48:00.00
SNMPv2-SMI::enterprises.318.1.1.1.2.2.4.0 = INTEGER: 1
SNMPv2-SMI::enterprises.318.1.1.1.2.2.5.0 = INTEGER: 1
SNMPv2-SMI::enterprises.318.1.1.1.2.2.6.0 = INTEGER: 0
SNMPv2-SMI::enterprises.318.1.1.1.2.2.7.0 = INTEGER: 0
SNMPv2-SMI::enterprises.318.1.1.1.2.2.8.0 = INTEGER: 55
SNMPv2-SMI::enterprises.318.1.1.1.2.2.9.0 = INTEGER: 0
SNMPv2-SMI::enterprises.318.1.1.1.2.2.10.0 = INTEGER: 0
SNMPv2-SMI::enterprises.318.1.1.1.2.3.1.0 = Gauge32: 1000
SNMPv2-SMI::enterprises.318.1.1.1.2.3.2.0 = Gauge32: 288
SNMPv2-SMI::enterprises.318.1.1.1.2.3.4.0 = INTEGER: 550
SNMPv2-SMI::enterprises.318.1.1.1.2.3.5.0 = INTEGER: 0
SNMPv2-SMI::enterprises.318.1.1.1.2.3.6.0 = INTEGER: 0
Comparing this to my web GUI interface results....
Internal Temperature: 28.8 C
Runtime Remaining: 2 hours 48 minutes
I can see that I can poll the temperature using...
snmpget -v1 -c public 192.168.1.10 enterprises.318.1.1.1.2.3.2.0
SNMPv2-SMI::enterprises.318.1.1.1.2.3.2.0 = Gauge32: 288
WINDOWS SERVER SNMP, not just for UPS/Network devices and Linux
- Start -> Control Panel -> Add/Remove Programs -> Add/Remove Windows Components
- Management and Monitoring Tools -> Details -> Simple Network Management Protocol
- Checkbox then Next and Finish ...
- Windows does not assign any community string to the SNMP service and it only allow access from localhost or local devices.
- Now in compmgmt.msc you'll have Services = SNMP Service and SNMP Trap Service
- Double click on the SNMP Service -> Traps tab to configure the Agent...
- The community name acts as a combination password and identifier.
- type in "public" and click "Add to list"
- The Security tab allows you to configure what rights go with what community and which hosts to accept SNMP packets from...
- Add "public" to "Accesspted community names"
- If you choose "public" then be aware that it's very common (and therefore insecure)
- If you allow all hosts for testing purposes change it back to localhost or ip addresses.
If you care about security you may want to look into Configuring SNMP Security http://labmice.techtarget.com/windows2003/Network/defaut.htm