The MIBs used by these tools normally reside in the /usr/share/snmp/mibs/ directory. Therefore, if we have ever to install new MIBs (e.g. for a VMware ESXi) we will have to leave them into that directory.
[root@centos ~]# ls -l /usr/share/snmp/mibs/
total 2364
...
-r--r--r-- 1 root root 8259 feb 16 12:09 SNMPv2-CONF.mib
-rw-r--r-- 1 root root 8263 feb 16 11:19 SNMPv2-CONF.txt
-r--r--r-- 1 root root 31588 feb 16 12:09 SNMPv2-MIB.mib
-rw-r--r-- 1 root root 29305 feb 16 11:19 SNMPv2-MIB.txt
snmpget
The snmpget command provides information about a specific OID.
For instance, to request the name of the device (system.sysName OID, belonging to the SNMPv2-MIB module) we will run the following order:
[root@centos ~]# snmpget -v 2c -c centos-community 192.168.1.10 SNMPv2-MIB::system.sysName.0
SNMPv2-MIB::sysName.0 = STRING: centos
We can also use abbreviations as follows:
[root@centos ~]# snmpget -v 2c -c centos-community 192.168.1.10 system.sysName.0
SNMPv2-MIB::sysName.0 = STRING: centos
[root@centos ~]# snmpget -v 2c -c centos-community 192.168.1.10 sysName.0
SNMPv2-MIB::sysName.0 = STRING: centos
Also say that multiple queries and use the OID in numeric format can be done.
[root@centos ~]# snmpget -v 2c -c centos-community 192.168.1.10 sysName.0 sysUpTime.0
SNMPv2-MIB::sysName.0 = STRING: centos
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (69808) 0:11:38
[root@centos ~]# snmpget -v 2c -c centos-community 192.168.1.10 .1.3.6.1.2.1.1.5.0
SNMPv2-MIB::sysName.0 = STRING: centos
snmptranslate
The snmptranslate command allows to make translations of OIDs from numeric format to variable and vice versa.
[root@centos ~]# snmptranslate .1.3.6.1.2.1.2.2.1.4.2
IF-MIB::ifMtu.2
[root@centos ~]# snmptranslate -On IF-MIB::ifMtu.2
.1.3.6.1.2.1.2.2.1.4.2
In order to get the complete OID, we must use the -Of parameter.
[root@centos ~]# snmptranslate -Of IF-MIB::ifMtu.2
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry
For example it can happend that we don't remember the complete OID name. In this case, the -Ib parameter will provide us the best match.
[root@centos ~]# snmptranslate -Ib 'i*tu'
IF-MIB::ifMtu
But if we want to get all the matches that fit with the selected pattern, we will use the -TB option.
[root@centos ~]# snmptranslate -TB 'sys.*ime'
SNMPv2-MIB::sysORUpTime
SNMPv2-MIB::sysUpTime
DISMAN-EVENT-MIB::sysUpTimeInstance
IP-MIB::ipSystemStatsDiscontinuityTime
Finally, also say that the snmptranslate command is very useful to show the entire OIDs tree or all branches that hang of a particular OID.
[root@centos ~]# snmptranslate -Tp -IR | more
+--iso(1)
|
+--org(3)
|
+--dod(6)
|
+--internet(1)
...
[root@centos ~]# snmptranslate -Tp -IR system
+--system(1)
|
+-- -R-- String sysDescr(1)
| Textual Convention: DisplayString
| Size: 0..255
+-- -R-- ObjID sysObjectID(2)
+-- -R-- TimeTicks sysUpTime(3)
| |
| +--sysUpTimeInstance(0)
...
snmpwalk
The snmpwalk command is utilized to perform a series of followed GETNEXTS instructions, and thus to obtain for example all the values of a specific branch.
[root@centos ~]# snmpwalk -v 2c -c centos-community 192.168.1.10 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux server 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 EST 2010 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (342908) 0:57:09.08
SNMPv2-MIB::sysContact.0 = STRING: Root (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: centos
...