SNMP protocol provides useful features to monitor and configure network and server systems remotely. Monitoring features are much popular than configuration.
snmpwalk is a function provided by SNMP protocol to get metrics of remote system in bulk.
Get All OIDS
We will first look the simplest usage of the
snmpwalk command. We just provide minimum options to the
snmpwalk. We will provide following options as minimum
- `-v 2c` version information 2 community
- `-c`the public or private secret
- `IP ADDRESS`
$ snmpwalk -v 2c -c public localhost
Get Specific OIDS
In previous example we have listed all existing and configured OIDs. But this is not useful for all cases. We may need to filter and specify only OIDS we need. We will add to the end of the command the OIDs we want to get. In this example we only want OID of contact information.
$ snmpwalk -v 2c -c public localhost iso.220.127.116.11.18.104.22.168
Specify MIB Library Path For External MIBs
Normally Linux provide a lot of default MIBs but in some cases the remote system vendor may provide 3rd party MIBs. We can use these MIBs in order to get OIDs of remote system. We will specify the MIBs location with
$ snmpwalk -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.22.214.171.124.126.96.36.199
Change Default Timeout or Set New Timeout
snmpwalk there is default timeout where the command will wait for a response from remote systems. We can change this default timeout value and set whatever we want the
-t option by providing the value of timeout. In this example we will set timeout as 10 seconds.
$ snmpwalk -t 10 -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.188.8.131.52.184.108.40.206
Set Default Retry Count
If there are network related problem and packet loss we may require to retry
snmpwalk command. This will resend request after specified timout value. We will use
-r option in order to set retry count. In this example we will retry 1 time. So the total timeout for single host will be 20 seconds .
$ snmpwalk -r 1 -t 10 -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.220.127.116.11.18.104.22.168