System Management Configuration Guide for Cisco 8000 Series Routers, Cisco IOS XR Releases

PDF

Custom MIB Support Using SNMP Operation Script

Want to summarize with AI?

Log in

Use this concept to extend device monitoring by defining custom Management Information Bases (MIBs) that expose additional operational data through SNMP without requiring a software upgrade.


A custom MIB is a network management information base extension that

  • allows creation of user-defined managed objects and their OIDs,

  • retrieves real-time operational data using scripts triggered by SNMP requests, and

  • enables support for monitoring requirements not covered by built-in MIBs.

With this feature, you can define a custom script for a given OID. When an SNMP request for the custom OID is received, the associated script retrieves data from the operational database and returns it to the Network Management System (NMS) using SNMP protocol.

Table 1. Feature History Table

Feature Name

Release Information

Feature Description


Restrictions for custom MIB

The length of string data type OIDs must not cross 400 bytes.


Create a custom MIB using an SNMP script

Configure a custom MIB entry by mapping an SNMP script to a unique OID for LLDP state reporting.

This task enables SNMP management tools to access LLDP state information by defining and associating a custom OID with a Python script that retrieves LLDP operational data from the router.

Before you begin

  • Prepare your SNMP script to query the LLDP status (example provided below).

  • The custom OID must extend from the root: 1.3.6.1.4.1.9.9.999998.

Procedure

1.

Create a script to fetch required data from the operational database on the router.

2.

Fetch the process which executes the command.

Example:

Router#describe show lldp
The command is defined in lldp_cmds.parser

User needs ALL of the following taskids:

	ethernet-services (READ) or optical (READ) 

It will take the following actions:
  Spawn the process:
    lldp_command "-s" "-g"

The output lldp_command "-s" "-g" is used in this script.

Router#show_lldp_string.py
import iosxr.snmp
   import time
   import subprocess as sp
   import re
   oid = iosxr.snmp.snmp_get_oid()
   access_type = iosxr.snmp.snmp_get_access_type()
   value = sp.getoutput("lldp_command \"-s\" \"-g\"" )
   iosxr.snmp.snmp_send_response("1.3.6.1.4.1.9.9.999998.10", str(value), "OctetString")
3.

Copy the script file to this location: harddisk:/mirror/script-mgmt/snmp/.

4.

Generate the checksum of the script file.

Example:

Router:/harddisk:/mirror/script-mgmt/snmp]$sha256sum show_lldp_string.py
156345c2cbfc1a2725b5f5ecdfb23d30d9a25e894604890d88929d724946e7b3 show_lldp_string.py
5.

Enter the configuration mode of the router.

Example:

Router#configure
6.

Enable read-write community string, where public is the read-write community.

Example:

Router(config)#snmp-server community public RW
7.

Map the script file to the custom OID using the snmp-server script script-oid OID-number script-filename file-name command.

Example:

Router(config)#snmp-server script script-oid 1.3.6.1.4.1.9.9.999998.10 script-filename show_lldp_string.py
8.

Configure the checksum of the script file using the script snmp file-name checksum sha256 checksum-value command.

Example:

Router(config)#script snmp show_lldp_string.py checksum sha256
156345c2cbfc1a2725b5f5ecdfb23d30d9a25e894604890d88929d724946e7b3
Note

The root OID number 1.3.6.1.4.1.9.9.999998 must be used and you can write any Custom OID number after the root OID number.

9.

Verify that the SNMP has received get request for the custom OID.

Example:

Router#snmpwalk -v2c -c public 5.36.7.100 1.3.6.1.4.1.9.9.999998.10 
SNMPv2-SMI::enterprises.9.9.999998.10.0 = STRING: Global LLDP information:
        Status: ACTIVE
        LLDP Chassis ID: 0032.176e.a0df
        LLDP Chassis ID Subtype: MAC Address (IEEE 802-2001) Chassis Subtype
        LLDP System Name: POD-TN3
        LLDP advertisements are sent every 30 seconds
        LLDP hold time advertised is 120 seconds
        LLDP interface reinitialisation delay is 2 seconds