Re: [pysnmp-users] Custom MIB files
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2016-12-03 12:38:56
|
My guess is that once you compiled MIB into .py form, you should make pysnmp using it by either: * moving your .py MIB into ~/.pysnmp/mibs or * configuring pysnmp to pick up .py MIBs from a non-default location (http://pysnmp.sourceforge.net/docs/api-reference.html#pysnmp.smi.rfc1902.ObjectIdentity.addMibSource). MIB files at snmplabs.com serve as a shared, community repository of originally ASN.1 MIB files, there should be no need to remove them. > On 02 Dec 2016, at 22:41, Jian Li <ji...@le...> wrote: > > Ilya, > > I modified my mib file and did a "mibdump.py --rebuild" with the modified mib file. But the generated python file did not take the modifications ( I am using ubuntu14.04 with python 2.7). Do I need to somehow delete the one online as well, > http://mibs.snmplabs.com:80/asn1/PACKETPOWER-EG4-MIB > > Thanks, > > Jian > > -----Original Message----- > From: Ilya Etingof [mailto:il...@gl...] > Sent: Thursday, November 17, 2016 5:45 PM > To: Jian Li > Cc: pys...@li... > Subject: Re: [pysnmp-users] Custom MIB files > > > I could not compile your MIB because it seems to import both SMIv1 and SMIv2 types. Once I changed the SMIv1 IMPORTS: > > DisplayString > FROM RFC1213-MIB > > for SMIv2 ones: > > DateAndTime, DisplayString, RowStatus, TruthValue, DisplayString > FROM SNMPv2-TC > > It compiled successfully. > > As for your other question — your code looks OK for as long as you actually iterate the generator you’ve created because this is when actual I/O happens: > > gen = nextCmd(…) > for rsp in gen: > print(rsp) > > And SNMP agent at 169.254.81.145 is responding. You may also debug your script against public SNMP simulator: > > http://snmpsim.sourceforge.net/public-snmp-simulator.html > > Though it does not implement your MIB. > >> On 17 Nov 2016, at 22:18, Jian Li <ji...@le...> wrote: >> >> Ilya, >> >> Please find the attached MIB file. Thank you very much for your help. >> >> I was able to use mibdump.py to compile that MIB file to python modules. There is another question I want to ask you about pysnmp as well, I did not get any response for the following command, do I do something obviously wrong? The snmp agent is configured and I was able to get correct response for ObjectIdentity('SNMPv2-MIB', 'system') >> >> nextCmd(SnmpEngine(), >> CommunityData('public', mpModel=1), >> UdpTransportTarget(('169.254.81.145', 161)), >> ContextData(), >> ObjectType(ObjectIdentity(' PACKETPOWER-EG4-MIB, ' packetPower')) >> >> Thanks, >> >> Jian >> >> -----Original Message----- >> From: Ilya Etingof [mailto:il...@gl...] >> Sent: Thursday, November 17, 2016 3:08 PM >> To: Jian Li >> Cc: pys...@li... >> Subject: Re: [pysnmp-users] Custom MIB files >> >> >> Could you please share your MIB (e.g. CUSTOM-EG4-MIB)? I suspect it has syntax errors, in particular it may miss SNMPv2-SMI import. >> >>> On 15 Nov 2016, at 16:34, Jian Li <ji...@le...> wrote: >>> >>> I tried to add the MIB files to a python script, using PySNMP addAsn1MibSource(‘file:///path’). However I got the following error, >>> >>> pysnmp.smi.error.MibNotFoundError: CUSTOM-EG4-MIB compilation error(s): missing; missing; missing; missing; no module "SNMPv2-SMI" in symbolTable at MIB CUSTOM-EG4-MIB >>> >>> Would really appreciate your help to get it resolved. >>> >>> Thanks, >>> >>> Jian >> <PACKETPOWER-EG4-MIB> > |