Re: [pysnmp-users] Custom MIB files
Brought to you by:
elie
From: Jian Li <ji...@le...> - 2016-12-05 21:46:04
|
Ilya, So PacketPower actually put the MIB file on-line? I am fine to use the local file option for now, and wait for them to get it updated online. The local file option worked for me. Now I see the modifications in the python file. Thanks a lot for your help. Thanks, Jian -----Original Message----- From: Ilya Etingof [mailto:il...@gl...] Sent: Monday, December 5, 2016 3:58 PM To: Jian Li Cc: pys...@li... Subject: Re: [pysnmp-users] Custom MIB files Jian, I can replace the on-line version of the MIB file if it is somehow outdated or broken. If you want to use an alternative version locally, just point `mibdump` to your local directory by passing the: --mib-source file:///local-directory --mib-source 'http://mibs.snmplabs.com/asn1/@mib@' option to it. The second --mib-source may be needed for `mibdump` to pick up dependent MIBs from the web server if you do not have them locally. On 12/05/2016 09:50 PM, Jian Li wrote: > Ilya, > > Some more info for the mibdump.py issue I am experiencing. > > This is the MIB I am trying to modify with a local MIB text file, > /mibs.snmplabs.com/asn1/PACKETPOWER-EG4-MIB/. > When I do /mibdump.py > --rebuild///local-directory/PACKKETPOWER-EG4-MIB.txt/ it always takes > the content from the online PACKETPOWER-EG4-MIB without any > modifications in my local MIB text file ( I was trying to add more > constraint values for channelId in that file) to the generated > ~/.pysnmp/mibs/PACKETPOWER-EG4-MIB.py > > So, how did /PACKETPOWER-EG4-MI/ get online? Is it possible to either > delete or modify it? > > Thanks, > > Jian > > -----Original Message----- > From: Ilya Etingof [mailto:il...@gl...] > Sent: Saturday, December 3, 2016 7:39 AM > To: Jian Li > Cc: pys...@li...<mailto:pys...@li...> > Subject: Re: [pysnmp-users] Custom MIB files > > > 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... <mailto:ji...@le...<mailto:ji...@le...%20<mailto: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...<mailto:pys...@li...> > <mailto: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... <mailto:ji...@le...<mailto:ji...@le...%20<mailto: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...<mailto:pys...@li...> > <mailto: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... <mailto:ji...@le...<mailto:ji...@le...%20<mailto: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> >> > > |