pysnmp icon indicating copy to clipboard operation
pysnmp copied to clipboard

SNMP Agent developing problems

Open EliGwz opened this issue 4 years ago • 1 comments

Hi,

I am now working on developing a SNMP agent which is going to run on linux system and I have encountered several problems.

I have already had an ASN.1 MIB file and compiled it to .py and .pyc file, but I need to integrate this step into my programme. How can I use mibdump in my code without using it outside the programme?

Another problem is that I can run my SNMP agent successfully in terminal, but after I use pyinstaller.exe -F Untitled-1.py command to build it to .exe file, the agent cannot run successfully and exit immediately.

Besides, in a sending trap function, the IDE warned me ntforg: ntforg Too many positional arguments for constructor call, but ntforg.NotificationOriginator only got one parameter "self._snmpContext". I cannot just delete it.

    def sendTrap(self):
        print "Sending trap"
        ntfOrg = ntforg.NotificationOriginator(self._snmpContext)
        errorIndication = ntfOrg.sendNotification(
            self._snmpEngine,
            'test-notification',
            ('MY-MIB', 'testTrap'),
            ())

Looking forward to your help, thank you so much.

EliGwz avatar Nov 08 '19 10:11 EliGwz

I have already had an ASN.1 MIB file and compiled it to .py and .pyc file, but I need to integrate this step into my programme. How can I use mibdump in my code without using it outside the programme?

You do not have to run mibdump by hand at all. Something similar is done automatically by pysnmp whenever needed (pysnmp imports pysmi to perform one-time MIBs compilation on startup).

Another problem is that I can run my SNMP agent successfully in terminal, but after I use pyinstaller.exe -F Untitled-1.py command to build it to .exe file, the agent cannot run successfully and exit immediately.

Perhaps you should enable some sort of debugging with pyinstaller or your app or pysnmp itself to see the cause of the crash. It's likely related to MIB modules loading.

Besides, in a sending trap function, the IDE warned me ntforg: ntforg Too many positional arguments for constructor call, but ntforg.NotificationOriginator only got one parameter "self._snmpContext". I cannot just delete it.

Could you share which pysnmp version are you using? It's best to use the lasted released one. If the problem persists and you could come up with a minimal reproducer - that would be awesome!

etingof avatar Nov 16 '19 07:11 etingof