File: example-agent.py

package info (click to toggle)
pyagentx 0.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 200 kB
  • sloc: python: 818; sh: 14; makefile: 3
file content (24 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pyagentx

# Updater class that set OID values
class NetSnmpPlaypen(pyagentx.Updater):
    def update(self):
        self.set_INTEGER('1.0', 1000)
        self.set_OCTETSTRING('3.0', 'String for NET-SNMP-EXAMPLES-MIB')

class MyAgent(pyagentx.Agent):
    def setup(self):
        # Register Updater class that responsd to
        # the tree under "netSnmpPlaypen": 1.3.6.1.4.1.8072.9999.9999
        self.register('1.3.6.1.4.1.8072.9999.9999', NetSnmpPlaypen)

# Main
pyagentx.setup_logging()
try:
    a = MyAgent()
    a.start()
except Exception as e:
    print("Unhandled exception:", e)
    a.stop()
except KeyboardInterrupt:
    a.stop()