How to get the name of the Oid (#Snmp)?

2019-03-05 13:55发布

问题:

Ok, following the advice of Lex Li and I try to get Oid name using an other lib : #SnmpLib

Here the sample :

public static void Main(string[] args)
{

    string oid = ".1.3.6.1.4.1";
    IObjectRegistry registry = new ReloadableObjectRegistry(@"C:\Users\Fnizz\Desktop\MIBS_BARCO\");
    IObjectTree tree = registry.Tree;
    var o = tree.Search(ObjectIdentifier.Convert(oid));
    string textual = o.AlternativeText;
    Console.WriteLine(textual);
    if (o.GetRemaining().Count == 0)
    {
        Console.WriteLine(o.Definition.Type.ToString());
    }

    Console.ReadKey();
}

But instead of to get the value .iso.org.dod.internet.private.enterprises I get this one : .iso.3.6.1.4.1

回答1:

You must use #SNMP MIB Compiler (Compiler.exe) to compile your MIB documents first. If there is any dependency missing, it will tell. Only when all dependencies are there, the Compiler can compile your documents without an error.

The compiler generates *.module files in modules folder. Then you need to put these files (*.module) into C:\Users\Fnizz\Desktop\MIBS_BARCO\ folder.

The object registry is able to load them and perform the name resolution correctly. The object registry does not under MIB documents directly, so feeding it with MIB documents will not work.



标签: c# snmp