While SNMP stands for Simple Network Management Protocol it's far from being simple sometimes.
A "walk" allows you to interrogate a device.
snmpwalk -v 2c -c public 10.25.7.13 -m all 1.3.6.1.4.1.14823
Adding -O f
makes is display the full translated OID:
Command:
snmpwalk -v 2c -c public 10.25.7.13 -O f -m all 1.3.6.1.4.1.2021
Output:
.iso.org.dod.internet.private.enterprises.ucdavis.memory.memIndex.0 = INTEGER: 0
.iso.org.dod.internet.private.enterprises.ucdavis.memory.memErrorName.0 = STRING: swap
.iso.org.dod.internet.private.enterprises.ucdavis.memory.memTotalSwap.0 = INTEGER: 2031608 kB
Adding -O n
makes is display the full numeric OID:
Command:
snmpwalk -v 2c -c public 10.25.7.13 -O n -m all 1.3.6.1.4.1.2021
Output:
.1.3.6.1.4.1.2021.4.1.0 = INTEGER: 0
.1.3.6.1.4.1.2021.4.2.0 = STRING: swap
.1.3.6.1.4.1.2021.4.3.0 = INTEGER: 2031608 kB
SNMP Regular Expression
Use a regular expression to check if a string exists (this will go critical if "online" is not found).
check_snmp -H
10.25.7.13
-P 2c -c public -t 30 -o 1.3.6.1.4.1.789.1.5.11.1.5.1026 -r \online
SNMP Trap Daemon (snmptrapd)
snmptrapd is a daemon that listens for SNMP Traps and then places them
into a spool folder for another process (like snmptt) to do something
with them.
The options you can define in snmptrapd.conf are explained on this page:
http://www.net-snmp.org/docs/man/snmptrapd.conf.html
Logging
Here's how to enable logging of snmptrapd into a file.
Edit the file /etc/snmp/snmptrapd.conf
Add this line to the end of the file:
logOption f /var/log/snmptrapd.log
Save the file and restart the service.
service snmptrapd restart
Now everything is logged in /var/log/snmptrapd.log
I've logged a bug here about how some of the logging is not working as expected:
https://sourceforge.net/p/net-snmp/bugs/2610/Output The OID Numerically (Disable Trap Translation)
Edit the file /etc/snmp/snmptrapd.conf
Add this line to the end of the file:
outputOption n
Save the file and restart the service.
service snmptrapd restart
Now traps will not be translated:
1427757479
snmpsender.box293.local
UDP: [10.25.5.20]:51125->[10.25.5.30]
.1.3.6.1.2.1.1.3.0 0:1:25:53.71
.1.3.6.1.6.3.1.1.4.1.0 .1.3.6.1.4.1.8072.2.3.0.1
.1.3.6.1.4.1.8072.2.3.2.1 123456
For a full list of options, refer to the OUTPUT OPTIONS on this page:
http://www.net-snmp.org/docs/man/snmpcmd.html
Send Test Trap
You can send a trap from a command line to test all is working OK.
snmptrap -v 2c -c public snmpreceiver "" NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification netSnmpExampleHeartbeatRate i 123456
OR
snmptrap -v 2c -c public snmpreceiver "" .1.3.6.1.4.1.8072.2.3.0.1 .1.3.6.1.4.1.8072.2.3.2.1 i 123456
SNMP Translate
This command will take a MIB file you give it and output all the objects and their relevant OID's.
Command:
snmptranslate -m /usr/share/snmp/mibs/IBM-SYSTEM-MIB.txt -Tz
Output:
"org" "1.3"
"dod" "1.3.6"
"internet" "1.3.6.1"
"directory" "1.3.6.1.1"
"mgmt" "1.3.6.1.2"
"experimental" "1.3.6.1.3"
"private" "1.3.6.1.4"
"enterprises" "1.3.6.1.4.1"
"ibm" "1.3.6.1.4.1.2"
"ibmProd" "1.3.6.1.4.1.2.6"
"ibmServer" "1.3.6.1.4.1.2.6.159"
"ibmSystemAgentVersion" "1.3.6.1.4.1.2.6.159.0"
"ibmSystem" "1.3.6.1.4.1.2.6.159.1"
"ibmSystemMIB" "1.3.6.1.4.1.2.6.159.1.1"
"ibmSystemTrap" "1.3.6.1.4.1.2.6.159.1.1.0"
"win32" "1.3.6.1.4.1.2.6.159.1.1.2"
"win32Event" "1.3.6.1.4.1.2.6.159.1.1.2.0"
"win32WMI" "1.3.6.1.4.1.2.6.159.1.1.2.10"
"win32SMBIOS" "1.3.6.1.4.1.2.6.159.1.1.2.20"
"ibmSystemAgent" "1.3.6.1.4.1.2.6.159.1.1.10"
"ibmSystemAgentUpObjs" "1.3.6.1.4.1.2.6.159.1.1.10.0"
"ibmSystemMgmtHwIPEndPointUp" "1.3.6.1.4.1.2.6.159.1.1.10.0.3"
"ibmSystemEventSubsystem" "1.3.6.1.4.1.2.6.159.1.1.20"
"ibmSystemHealth" "1.3.6.1.4.1.2.6.159.1.1.30"
"ibmSystemHealthUp" "1.3.6.1.4.1.2.6.159.1.1.30.0"
"ibmSystemStorageUp" "1.3.6.1.4.1.2.6.159.1.1.30.0.1"
"ibmSystemPhysicalDiskUp" "1.3.6.1.4.1.2.6.159.1.1.30.0.1.1"
"ibmSystemLogicalDiskUp" "1.3.6.1.4.1.2.6.159.1.1.30.0.1.2"
"ibmSystemVitalProductData" "1.3.6.1.4.1.2.6.159.1.1.40"
"ibmSystemSMART" "1.3.6.1.4.1.2.6.159.1.1.50"
"ibmSystemAssetID" "1.3.6.1.4.1.2.6.159.1.1.60"
"ibmSystemAlertOnLAN" "1.3.6.1.4.1.2.6.159.1.1.70"
"ibmSystemLMSensor" "1.3.6.1.4.1.2.6.159.1.1.80"
"ibmSystemLMSensorUp" "1.3.6.1.4.1.2.6.159.1.1.80.0"
"ibmSystemVoltageUp" "1.3.6.1.4.1.2.6.159.1.1.80.0.1"
"ibmSystemTemperatureUp" "1.3.6.1.4.1.2.6.159.1.1.80.0.2"
"ibmSystemTachometerUp" "1.3.6.1.4.1.2.6.159.1.1.80.0.3"
"ibmSystemITDirector" "1.3.6.1.4.1.2.6.159.1.1.90"
"ibmSystemSmbios" "1.3.6.1.4.1.2.6.159.1.1.100"
"ibmSystemNetwork" "1.3.6.1.4.1.2.6.159.1.1.110"
"ibmSystemNetworkUp" "1.3.6.1.4.1.2.6.159.1.1.110.0"
"ibmSystemMemory" "1.3.6.1.4.1.2.6.159.1.1.120"
"ibmSystemMemoryUp" "1.3.6.1.4.1.2.6.159.1.1.120.0"
"ibmSystemPower" "1.3.6.1.4.1.2.6.159.1.1.130"
"ibmSystemPowerUp" "1.3.6.1.4.1.2.6.159.1.1.130.0"
"ibmSystemProcessor" "1.3.6.1.4.1.2.6.159.1.1.140"
"ibmSystemProcessorUp" "1.3.6.1.4.1.2.6.159.1.1.140.0"
"ibmSystemSmartDisk" "1.3.6.1.4.1.2.6.159.1.1.150"
"ibmSystemSmartDiskUp" "1.3.6.1.4.1.2.6.159.1.1.150.0"
"ibmSystemRaid" "1.3.6.1.4.1.2.6.159.1.1.200"
"ibmSystemRaidUp" "1.3.6.1.4.1.2.6.159.1.1.200.0"
"ibmSystemAgentPlatform" "1.3.6.1.4.1.2.6.159.1.1.2000"
"ibmSystemAgentPlatformInfo" "1.3.6.1.4.1.2.6.159.1.1.2000.0"
"ibmSystemAgentV2" "1.3.6.1.4.1.2.6.159.1.1.2010"
"ibmSystemAssetIDV2" "1.3.6.1.4.1.2.6.159.1.1.2060"
"ibmSystemLMSensorV2" "1.3.6.1.4.1.2.6.159.1.1.2080"
"ibmSystemNetworkV2" "1.3.6.1.4.1.2.6.159.1.1.2110"
"ibmSystemMemoryV2" "1.3.6.1.4.1.2.6.159.1.1.2120"
"ibmSystemPowerV2" "1.3.6.1.4.1.2.6.159.1.1.2130"
"ibmSystemProcessorV2" "1.3.6.1.4.1.2.6.159.1.1.2140"
"ibmQLogic" "1.3.6.1.4.1.2.6.159.1.1.2310"
"ibmBrocade" "1.3.6.1.4.1.2.6.159.1.1.2320"
"ibmStorage" "1.3.6.1.4.1.2.6.159.3"