Using your own MIB with Datadog agent v5.14.x onwards

 

In our documentation found here, it was mentioned that the SNMP check can collect MIB data that is formatted via PySNMP. Also that you can use the build-pysnmp-mibs script that ships with pysnmp to generate such data.


build-pysnmp-mib script has been made obsolete since pysnmp 4.3 (Reference here); mibdump.py replaces it.

Since Datadog agent version 5.14, our PySNMP dependency has been upgraded from version 4.25 to 4.3.5 (Reference on our changelog). Meaning the build-pysnmp-mib which shipped with our agent from version 5.13.x and earlier has also been replaced with mibdump.py.

 

In Linux, find the location of mibdump.py:

# find /opt/datadog-agent/ -type f -name build-pysnmp-mib.py -o -name mibdump.py
/opt/datadog-agent/bin/mibdump.py

 

In Windows, the location would be:

C:\Program Files\Datadog\Datadog Agent\embedded\Scripts\mibdump.py


In Linux, below is the format to use the script:

export MIBSRC=/path/to/mib/files
export MIBDST=/path/to/converted/mib-py/

/opt/datadog-agent/bin/mibdump.py \
--mib-source $MIBSRC \
--mib-source http://mibs.snmplabs.com/asn1/@mib@ \
--destination-directory=$MIBDST \
--destination-format=pysnmp <MIB name to convert>

 

In Windows using Powershell:

PS> New-Variable -Name MIBSRC -Value file:///X:/path/to/mib/source
PS> New-Variable -Name MIBDST -Value X:\path\to\mib\destination
PS> & 'C:\Program Files\Datadog\Datadog Agent\embedded\python.exe' 'C:\Program Files\Datadog\Datadog Agent\embedded\Scripts\mibdump.py' `
--mib-source $MIBSRC `
--mib-source http://mibs.snmplabs.com/asn1/@mib@ `
--destination-directory=$MIBDST `
--destination-format=pysnmp <MIB name to convert>

 

A note regarding --mib-source http://mibs.snmplabs.com/asn1/@mib@ section. If your MIB has dependencies on other MIBs but are not in $MIBSRC, mibdump will download them from http://mibs.snmplabs.com/asn1/. Thus, using this requires Internet connection. In case there is no Internet Connection, the dependency MIBs would have to be downloaded separately from a box with Internet connection and transferred manually to $MIBSRC.

 

Example using the CISCO-TCP-MIB:

# /opt/datadog-agent/bin/mibdump.py --mib-source /path/to/mib/files/  --mib-source http://mibs.snmplabs.com/asn1/@mib@ --destination-directory=/opt/datadog-agent/pysnmp/custom_mibpy/ --destination-format=pysnmp CISCO-TCP-MIB

 Source MIB repositories: /path/to/mib/files/, http://mibs.snmplabs.com/asn1/@mib@
 Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@mib@
 Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
 Compiled MIBs destination directory: /opt/datadog-agent/pysnmp/custom_mibpy/
 MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMP-FRAMEWORK-MIB, SNMP-TARGET-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM, TRANSPORT-ADDRESS-MIB
 MIBs to compile: CISCO-TCP
 Destination format: pysnmp
 Parser grammar cache directory: not used
 Also compile all relevant MIBs: yes
 Rebuild MIBs regardless of age: no
 Dry run mode: no Create/update MIBs: yes
 Byte-compile Python modules: yes (optimization level no)
 Ignore compilation errors: no
 Generate OID->MIB index: no
 Generate texts in MIBs: no
 Keep original texts layout: no
 Try various file names while searching for MIB module: yes
 Created/updated MIBs: CISCO-SMI, CISCO-TCP-MIB (CISCO-TCP)
 Pre-compiled MIBs borrowed:
 Up to date MIBs: INET-ADDRESS-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, TCP-MIB
 Missing source MIBs:
 Ignored MIBs:
 Failed MIBs:

# ls /opt/datadog-agent/pysnmp/custom_mibpy/
CISCO-SMI.py CISCO-SMI.pyc CISCO-TCP-MIB.py CISCO-TCP-MIB.pyc

 

As with before, the agent to the path can then look for the converted MIB Python files by specifying the destination path with mibs_folder: in the SNMP yaml configuration.

 

Sources:

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.