Snmp
This page describes some usages of the snmpwalk and snmpget commands that come with the net-snmp software.
snmpwalk
This example, taken from the man page, shows every in the system MIB on host hostname. You can replace system with enterprises to see what is there, also.
$ snmpwalk -Os -c public -v 2c hostname system
$ snmpwalk -Os -c public -v 2c franco system sysDescr.0 = STRING: FreeBSD franco.foster.dmz 5.5-RELEASE-p16 FreeBSD 5.5-RELEASE-p16 #24: Thu Oct 4 05:02:07 PDT 2007 root@franco.foster.dmz:/usr/obj/usr/src/sys/FRANCO1 i386 sysObjectID.0 = OID: netSnmpAgentOIDs.8 sysUpTimeInstance = Timeticks: (4077608) 11:19:36.08 sysContact.0 = STRING: mark@foster.cc sysName.0 = STRING: franco.foster.dmz sysLocation.0 = STRING: garage ...
If the example above doesn't work for you, try it without "system"
This example queries (using SNMPv2) the tree corresponding to the proc check commands defined in snmpd.conf
$ snmpwalk -v 2c hostname -c public .1.3.6.1.4.1.2021.2.1 UCD-SNMP-MIB::prIndex.1 = INTEGER: 1 UCD-SNMP-MIB::prIndex.2 = INTEGER: 2 UCD-SNMP-MIB::prNames.1 = STRING: crond UCD-SNMP-MIB::prNames.2 = STRING: sshd UCD-SNMP-MIB::prMin.1 = INTEGER: 1 UCD-SNMP-MIB::prMin.2 = INTEGER: 25 UCD-SNMP-MIB::prMax.1 = INTEGER: 1 UCD-SNMP-MIB::prMax.2 = INTEGER: 1 UCD-SNMP-MIB::prCount.1 = INTEGER: 1 UCD-SNMP-MIB::prCount.2 = INTEGER: 5 UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0 UCD-SNMP-MIB::prErrorFlag.2 = INTEGER: 1 UCD-SNMP-MIB::prErrMessage.1 = STRING: UCD-SNMP-MIB::prErrMessage.2 = STRING: Too few sshd running (# = 5) UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0 UCD-SNMP-MIB::prErrFix.2 = INTEGER: 0 UCD-SNMP-MIB::prErrFixCmd.1 = STRING: UCD-SNMP-MIB::prErrFixCmd.2 = STRING:
snmpget
Query a specific OID. (One that happens to spit out Nagios compatible expression)
$ snmpget -v 2c hostname -c public .1.3.6.1.4.1.5001.100.101.1 SNMPv2-SMI::enterprises.5001.100.101.1 = STRING: "OK: mailq reports queue is empty|unsent=0;2;4;0"
$ snmpget -v 2c hpux.host -c public .1.3.6.1.4.1.11.2.13.2.9.0 SNMPv2-SMI::enterprises.11.2.13.2.9.0 = STRING: "@(#) HP OpenView Emanate SNMP Agent. sys HPUX 11.X"
Note that the above command only works if the HP-UX system is running the default SnmpMaster/SnmpMib2/SnmpHpunix combination. If you've installed net-snmp instead, the OID won't be found...
SNMPv2-SMI::enterprises.11.2.13.2.9.0 = No Such Object available on this agent at this OID
SNMP Installation
Debian & Ubuntu
aptitude install snmp snmpd
Then edit /etc/snmp/snmpd.conf to change the COMMUNITY string(s).
Also edit /etc/default/snmpd to remove 127.0.0.1 from SNMPDOPTS...
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
Now restart service with /etc/init.d/snmpd restart