SNMP Walk, SNMPGET, SNMPTRANSLATE

Snmpwalk is a versatile tool that simplifies the process of retrieving and discovering SNMP data.

Snmpwalk is a command-line utility used to retrieve a subtree of management values from a network device using the Simple Network Management Protocol (SNMP).

Used to retrieve information from network devices using the Simple Network Management Protocol (SNMP).


Why Use snmpwalk?

1. Discovering Available OIDs: 
SNMPwalk helps discover the available Object Identifiers (OIDs) on a network device. This is useful for understanding what metrics and data are accessible through SNMP.
Command: snmpwalk -v 2c -c public 34.30.100.68

This command will output all OIDs available on the device with the IP 34.30.100.68, along with their values.

-v 2cThis option specifies the SNMP version to use. In this case, 2c stands for SNMP version 2c, which is a common version that supports community-based security.

-c publicThis option specifies the SNMP community string, which acts like a password. public is a common default community string used for read-only access.


2. Testing SNMP Connectivity and Configuration
snmpwalk can be used to verify that SNMP is correctly configured on both the client and server sides.
Command: snmpwalk -v 2c -c public 34.30.100.68

3. Gathering Comprehensive Data
Instead of querying individual OIDs one by one, snmpwalk retrieves a bulk set of data, providing a comprehensive view of a specific subtree of the MIB.
Command:: snmpwalk -v 2c -c public 34.30.100.68 .1.3.6.1.2.1.25.3.3.1.2

This command retrieves the CPU load for all processors on the target device, providing a broader understanding of the device's performance.

Practical Example:
Let's say you want to monitor CPU utilization on a network device using Zabbix. You can use snmpwalk to discover the exact OIDs related to CPU load:
snmpwalk -v 2c -c public 34.30.100.68 .1.3.6.1.2.1.25.3.3.1.2

The output:
HOST-RESOURCES-MIB::hrProcessorLoad.196608 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.196609 = INTEGER: 1

Here hr: host resource

Here OID .1.3.6.1.2.1.25.3.3.1.2.196608 represents the load on the first CPU, and .1.3.6.1.2.1.25.3.3.1.2.196609 represents the load on the second CPU. 

Here, 196608 is likely the identifier assigned by the SNMP agent to the first CPU. The next CPU is 196609.

Note: The SNMP agent on the device assigns a unique identifier to each processor in the system. This identifier is not necessarily sequential and can be based on internal indexing of the device.


SNMPGET Vs SNMPWALK Vs SNMPTRANSLATE

snmpget:

  • Purpose: Retrieve the value of a single SNMP object/single OID. 
  • Usage: It is used to query a specific OID to get its current value.
  • Output: Provides the value of the requested OID.
  • When to Use: When you need to fetch the value of a specific OID, such as a single metric or configuration parameter.

Example1:

To get the system uptime:

snmpget -v 2c -c public 34.30.100.68 .1.3.6.1.2.1.1.3.0

Output:

DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (123456) 14:25:36.00

Example2:
When you know the exact OID and want to retrieve its value:
snmpget -v 2c -c public 34.30.100.68 .1.3.6.1.2.1.25.3.3.1.2.196608

Output:
HOST-RESOURCES-MIB::hrProcessorLoad.196608 = INTEGER: 1


Snmpwalk:

Purpose: Retrieve a subtree of SNMP objects.
Usage: It is used to retrieve a sequence of OIDs and their values starting from a given OID, effectively "walking" the SNMP tree.
Output: Provides the values of all OIDs within the subtree of the starting OID.
When to Use: When you need to explore a range of OIDs, such as discovering what metrics are available under a specific branch.

When you want to discover all the available OIDs under a certain branch, such as all CPU load metrics:

snmpwalk -v 2c -c public 34.30.100.68 .1.3.6.1.2.1.25.3.3.1.2

Output:
HOST-RESOURCES-MIB::hrProcessorLoad.196608 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.196609 = INTEGER: 1

Note: Subtree: A portion of the MIB tree starting from a specific node (OID) and including all descendant nodes.


snmptranslate

It is commonly used to translate between numeric OIDs and their human-readable names, and to provide various other functionalities related to MIB browsing and manipulation.

Uses: 

1. Translating OIDs: 

Numeric to Textual: Translate a numeric OID to its human-readable name.

snmptranslate .1.3.6.1.2.1.1.1.0

Output:
SNMPv2-MIB::sysDescr.0

Textual to Numeric: Translate a human-readable name to its numeric OID.
snmptranslate -On SNMPv2-MIB::sysDescr.0

Output:
.1.3.6.1.2.1.1.1.0

2. Getting MIB Object Information

Object Details: Get detailed information about a MIB object.
snmptranslate -Td SNMPv2-MIB::sysDescr

Output:
SNMPv2-MIB::sysDescr
sysDescr OBJECT-TYPE
  -- FROM       SNMPv2-MIB, RFC1213-MIB
  -- TEXTUAL CONVENTION DisplayString
  SYNTAX       OCTET STRING (0..255)
  DISPLAY-HINT "255a"
  MAX-ACCESS   read-only
  STATUS       current
  DESCRIPTION  "A textual description of the entity.  This value should
               include the full name and version identification of the
               system's hardware type, software operating-system, and
               networking software."
  ::= { system 1 }


3. Browsing the MIB Tree

Display All Children of a Node: List all child nodes of a given OID.

snmptranslate -Tp -IR system

Output:
+--system(1)
   |
   +-- -R-- String    sysDescr(1)
   +-- -R-- ObjID     sysObjectID(2)
   +-- -R-- TimeTicks sysUpTime(3)
   +-- -R-- String    sysContact(4)
   +-- -R-- String    sysName(5)
   +-- -R-- String    sysLocation(6)
   +-- -RW- INTEGER   sysServices(7)
   +-- -R-- TimeTicks sysORLastChange(8)
   +-- -R-- sequence  sysORTable(9)

Command Options:

Here are some useful options for snmptranslate:

  • -On: Output the numeric OID.
  • -Of: Output the full OID path.
  • -Os: Output a simplified form of the OID.
  • -Td: Display detailed information about the MIB object.
  • -Tp: Display the MIB tree.
  • -IR: Perform an instance lookup for the provided OID


MIB TREE

The Management Information Base (MIB) tree is a hierarchical structure that organizes and defines the managed objects in a network device. Each node in the tree represents a managed object, which can be a piece of information, a configuration setting, or a statistic that can be monitored or managed via the Simple Network Management Protocol (SNMP). These managed objects are identified uniquely by Object Identifiers (OIDs).

Subtree: A subtree in a Management Information Base (MIB) refers to a branch of the hierarchical structure that contains a specific OID and all of its descendant OIDs. The MIB is organized in a tree-like format, where each node represents an Object Identifier (OID) that corresponds to a particular piece of information that can be monitored or managed via SNMP.


 

Comments

Popular posts from this blog

How to enable the syslog monitoring-Zabbix

Zabbix installation: Distribution setup

API & API in Zabbix