Last active
March 28, 2017 15:10
-
-
Save jonnystorm/7136bff23cca0f84219d6cd4cdaeabfc to your computer and use it in GitHub Desktop.
Resolve MIB name to OID in Elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change MIB extensions from .txt to .mib | |
copy -r /usr/share/snmp/mibs /home/jstorm/mibs | |
cd /home/jstorm/mibs | |
rename '\.txt$' .mib * | |
# Replace instances of RowStatus with INTEGER in MIBs. | |
# Otherwise, expect compilation errors. | |
# Compile dependencies before target MIB (IP-FORWARD-MIB, in this case). | |
iex> :snmpc.compile('IANAifType-MIB', [i: ['/home/jstorm/mibs']]) | |
{:ok, './IANAifType-MIB.bin'} | |
iex> :snmpc.compile('IF-MIB', [i: ['/home/jstorm/mibs']]) | |
{:ok, './IF-MIB.bin'} | |
iex> :snmpc.compile('IP-MIB', [i: ['/home/jstorm/mibs']]) | |
{:ok, './IP-MIB.bin'} | |
iex> :snmpc.compile('IANA-RTPROTO-MIB', [i: ['/home/jstorm/mibs']]) | |
{:ok, './IANA-RTPROTO-MIB.bin'} | |
iex> :snmpc.compile('IP-FORWARD-MIB', [i: ['/home/jstorm/mibs']]) | |
{:ok, './IP-FORWARD-MIB.bin'} | |
# Start :snmpm, load the compiled MIB, and resolve name. | |
iex> :snmpm.start | |
:ok | |
iex> :snmpm.load_mib('IP-FORWARD-MIB') | |
:ok | |
iex> :snmpm.name_to_oid(:ipCidrRouteTable) | |
{:ok, [[1, 3, 6, 1, 2, 1, 4, 24, 4]]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment