GithubHelp home page GithubHelp logo

opx-snmp's Introduction

opx-snmp

This file describes the SNMP agent implementation for OpenSwitch OPX. The engine used is PySNMP, which is a lightweight Python-based extensible agent with rich functionality. The agent implementation is also available in Python. Version 2 is currently supported, and will continue to be the default version of the agent. Version 3 support will be available in the next release. The infrastructure supports implementation of any number of standard and proprietary MIBs, and users can extend it to support traps, snmpsets, and so on.

Code organization

The SNMP agent code is organized into three areas:

  • Engine code - provided by PySNMP libraries and users generally don't make changes to it
  • Core agent - single Python file SNMPAgent serves as the glue between the PySNMP engine and user-specific handlers that fetch data from the backend. When a user implements a new MIB, they can make minimal code changes (a few lines) here.
  • Handlers - files contain all switch-specific code to get data from the lower protocol layers of the switch. When new MIBs are introduced, this is where the bulk of the code changes are expected.

Code location on switch

Compiled MIBS: /usr/lib/python2.7/dist-packages/opx-snmp Handlers: /usr/lib/python2.7/dist-packages/opx-snmp Handlers utilities: /usr/lib/python2.7/dist-packages/opx-snmp Core agent: /usr/sbin/SNMPAgent

Implemented MIBs

  • Interface table

Add your own MIB

  1. Compile your standard or proprietary MIB using the compiler provided by PySNMP mibdump.py. This generates an xyz-mib.py file, which is a Python-ized form of the MIB that the PySNMP engine can understand.

  2. Place the generated xyz-mib.py file in a location known to PySNMP (in the /usr/lib/python2.7/dist-packages/opx-snmp directory).

  3. Replace all references to MibTableColumn with CustomMibTableColumn in the generated xyz-mib.py file. Use the IF-MIB.py file in the same directory as the example. This step ensures that when a get or getnext request is received, it is redirected to your custom function, so that you can call the appropriate handler routine.

  4. Load the MIB to make the agent aware of it. Enhance the loadMibs() function in the core agent SNMPAgent to include your new MIB file.

  5. Write your own handler functions to get data from the backend for the MIB you are implementing. Use the /usr/lib/python2.7/dist-packages/opx-snmp/if_handlers.py file as an example. The 'handlers' dictionary at the end of the file is important. Place your new xyz_handler.py file in the same directory.

  6. If any common utilities will be implemented that other handler files can take advantage of, place them in handler_utils.py file in the same directory.

  7. Make the agent aware of your new handler functions. Enhance the section under "load handlers" in SNMPAgent file to do this.

  8. Restart the agent. You should now be able to do snmpget, snmpgetnext, and snmpwalk on this agent.

(c) 2018 Dell Inc. or its subsidiaries. All Rights Reserved.

opx-snmp's People

Contributors

gunasekaran-t avatar heucke avatar hpersh-dell avatar mikelazar avatar nchervela avatar tejaswi-goel avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opx-snmp's Issues

snmpwalk is not possible: OID not increasing

If i start an snmpwalk it breaks with:

# snmpwalk -v 2c -cpublic localhost .1.3.6.1.2.1
iso.3.6.1.2.1.1.1.0 = STRING: "Platform:S4248FBL-ON, NOS:OPXunstable"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.674
iso.3.6.1.2.1.1.3.0 = Timeticks: (10703) 0:01:47.03
iso.3.6.1.2.1.1.4.0 = STRING: "OpenSwitch.net"
iso.3.6.1.2.1.1.5.0 = STRING: "OPX"
iso.3.6.1.2.1.1.6.0 = STRING: "Santa Clara, CA"
iso.3.6.1.2.1.1.7.0 = INTEGER: 6
iso.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00
iso.3.6.1.2.1.2.2.1.1.66 = INTEGER: 66
iso.3.6.1.2.1.2.2.1.1.66 = INTEGER: 66
Error: OID not increasing: iso.3.6.1.2.1.2.2.1.1.66
 >= iso.3.6.1.2.1.2.2.1.1.66

opx-snmp: service dies if prtg searches for available snmp data

journal show the following error

Oct 01 19:32:00 r3 SNMPAgent[10224]: SNMPAgent: version is v2
Oct 01 19:32:00 r3 SNMPAgent[10224]: Starting agent
Oct 01 19:32:00 r3 SNMPAgent[10224]: Traceback (most recent call last):
Oct 01 19:32:00 r3 SNMPAgent[10224]:   File "/usr/sbin/SNMPAgent", line 293, in <module>
Oct 01 19:32:00 r3 SNMPAgent[10224]:     agent.serve_forever()
Oct 01 19:32:00 r3 SNMPAgent[10224]:   File "/usr/sbin/SNMPAgent", line 284, in serve_forever
Oct 01 19:32:00 r3 SNMPAgent[10224]:     self._snmpEngine.transportDispatcher.runDispatcher()
Oct 01 19:32:00 r3 SNMPAgent[10224]:   File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher
Oct 01 19:32:00 r3 SNMPAgent[10224]:     raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())))
Oct 01 19:32:00 r3 SNMPAgent[10224]: pysnmp.error.PySnmpError: poll error: Traceback (most recent call last):
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher
Oct 01 19:32:00 r3 SNMPAgent[10224]:     use_poll=True, map=self.__sockMap, count=1)
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/lib/python2.7/asyncore.py", line 220, in loop
Oct 01 19:32:00 r3 SNMPAgent[10224]:     poll_fun(timeout, map)
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/lib/python2.7/asyncore.py", line 201, in poll2
Oct 01 19:32:00 r3 SNMPAgent[10224]:     readwrite(obj, flags)
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite
Oct 01 19:32:00 r3 SNMPAgent[10224]:     obj.handle_error()
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite
Oct 01 19:32:00 r3 SNMPAgent[10224]:     obj.handle_read_event()
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event
Oct 01 19:32:00 r3 SNMPAgent[10224]:     self.handle_read()
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read
Oct 01 19:32:00 r3 SNMPAgent[10224]:     self._cbFun(self, transportAddress, incomingMessage)
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun
Oct 01 19:32:00 r3 SNMPAgent[10224]:     self, transportDomain, transportAddress, incomingMessage
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun
Oct 01 19:32:00 r3 SNMPAgent[10224]:     self, transportDomain, transportAddress, wholeMsg
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 433, in receiveMessage
Oct 01 19:32:00 r3 SNMPAgent[10224]:     PDU, maxSizeResponseScopedPDU, stateReference)
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 161, in processPdu
Oct 01 19:32:00 r3 SNMPAgent[10224]:     errorStatus, errorIndex = 'noSuchName', sys.exc_info()[1]['idx'] + 1
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/error.py", line 31, in __getitem__
Oct 01 19:32:00 r3 SNMPAgent[10224]:     return self.__outArgs[key]
Oct 01 19:32:00 r3 SNMPAgent[10224]: ;KeyError: 'idx'
Oct 01 19:32:00 r3 SNMPAgent[10224]: caused by <type 'exceptions.KeyError'>: 'idx'
Oct 01 19:32:00 r3 systemd[1]: opx-pysnmp.service: Main process exited, code=exited, status=1/FAILURE
Oct 01 19:32:00 r3 systemd[1]: opx-pysnmp.service: Unit entered failed state.
Oct 01 19:32:00 r3 systemd[1]: opx-pysnmp.service: Failed with result 'exit-code'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.