Do I need different MIB with those OID?
<p>I got this legacy <code>powershell</code> script that retrieve information via SNMP, I'm trying to port it in Python using <code>snimpy</code>.</p>

<pre><code>$PrintersIP = '10.100.7.47', '10.100.7.48'
Function Get-SNMPInfo ([String[]]$Printers) {
    Begin {
        $SNMP = New-Object -ComObject olePrn.OleSNMP
    }
    Process {
        Foreach ($IP in $Printers) {
            $SNMP.Open($IP,"public",2,3000)
            [PSCustomObject][Ordered]@{
                Name        = $SNMP.Get(".1.3.6.1.2.1.1.5.0")
                IP          = $IP
                UpTime      = [TimeSpan]::FromSeconds(($SNMP.Get(".1.3.6.1.2.1.1.3.0"))/100)
                Model       = $SNMP.Get(".1.3.6.1.2.1.25.3.2.1.3.1")
                Description = $SNMP.Get(".1.3.6.1.2.1.1.1.0")
                #Contact     = $SNMP.Get(".1.3.6.1.2.1.1.4.0")
                #SN          = $SNMP.Get(".1.3.6.1.2.1.43.5.1.1.17.1")
                #Location    = $SNMP.Get(".1.3.6.1.2.1.1.6.0")
                #TonerName   = $SNMP.Get("43.11.1.1.6.1.1")
            }
        }
    }
    End {
        $SNMP.Close()
    }
}
Get-SNMPInfo $PrintersIP | ft -AutoSize *
</code></pre>

<h3>Snimpy usage</h3>

<p>From the <a href="https://snimpy.readthedocs.io/en/latest/usage.html#regular-python-module" rel="nofollow">section <em>Usage</em> of the official documentation</a> they use the <code>load</code> method to load MIB a file.</p>

<pre><code>from snimpy.manager import Manager as M
from snimpy.manager import load

load("IF-MIB")
m = M("localhost")
print(m.ifDescr[0])
</code></pre>

<h3>Finding <em><code>OID</code> name</em></h3>

<p>I can't find the <code>OID</code> name for some of the identifiers. For instance:</p>

<ul>
<li><a href="http://oid-info.com/get/1.3.6.1.2.1.1.5.0" rel="nofollow"><code>1.3.6.1.2.1.1.5.0</code></a> â nothing ;</li>
<li><a href="http://oid-info.com/get/1.3.6.1.2.1.1.5" rel="nofollow"><code>1.3.6.1.2.1.1.5</code></a> â <code>sysName</code>.</li>
</ul>

<h3>Question</h3>

<ul>
<li>Depending on the <em><code>OID</code>'s name</em> I'm trying to use, do I need to load different MIB file ? (e.g. <code>Printer-MIB</code>, <code>IF-MIB</code>, etc.)</li>
<li>Where can I find the missing <em><code>OID</code>'s name</em></li>
</ul>

<p>If you use the load() method then scalars and row names from it will be made available as an instance attributes hence you're able to query for 'sysContact' etc, but as the 'sysDescr' and 'sysName' are not part of the IF-MIB you will not be able to get it.</p>

<p>You will need to load in the relevant MIB such as SNMPv2-MIB or attempt to get the value via the OID directly. </p>

<p><strong>UPDATE:</strong>
I've had a look and snimpy and it loooks like pysnmp is doing the collection, so you could always user that directly. The sample below is collecting a new different SNMP values some by OID and others via the named variable within the MIB (you will need to have the relevant MIB available if you want to get via the name). This sample is pretty much taken from the <a href="http://pysnmp.sourceforge.net/docs/tutorial.html" rel="nofollow">pySNMP documentation</a></p>

<pre><code>from pysnmp.entity.rfc3413.oneliner import cmdgen

cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
    cmdgen.CommunityData('public'),
    cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
    '1.3.6.1.2.1.1.1.0',            # sysDescr
    '1.3.6.1.2.1.1.2.0',            # sysObjectId
    '1.3.6.1.2.1.1.3.0',            # upTime
    '1.3.6.1.2.1.1.4.0',            # Contact
    '1.3.6.1.2.1.1.5.0',            # sysName
    '1.3.6.1.2.1.1.6.0',            # Location
    cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),     #.1.3.6.1.2.1.1.1.0 sysDescr
    cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0)     #.1.3.6.1.2.1.1.5.0 sysName
)



# Check for errors and print out results
if errorIndication:
    print(errorIndication)
else:
    if errorStatus:
        print('%s at %s' % (
            errorStatus.prettyPrint(),
            errorIndex and varBinds[int(errorIndex)-1] or '?'
            )
        )
    else:
        for name, val in varBinds:
            print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
</code></pre>

python powershell snmp mib snimpy