1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
This directory contains two example agents together with associated MIBs:
- "simple_agent.py" is the first example you should look at. It
demonstrates registering the various supported SNMP object types including
tables. For those interested in SNMP v3 it also shows registering variables
in contexts.
The simple agent uses net-snmp's check_and_process() call to wait for SNMP
requests in a blocking manner. Data is only updated inbetween SNMP requests.
For a different, more real-life usable approach see the next example.
- "threading_agent.py" should be looked at next. It registers just a
single DisplayString SNMP variable but demonstrates how to use Python's
threading module to separate the data update process from the SNMP request
processing so that both can execute independently.
For both examples, shell scripts are included that should make it a waltz to
play with the agents. The scripts take care of everything required to set up a
custom, minimal snmpd instance that runs under your ordinary user account and
separate from any system-wide running snmpd:
- "run_simple_agent.sh" does exactly that. Run it and it will even tell you
example SNMP commands that can be used to test that everything works.
- "run_simple_agent_over_tcpsocket.sh" runs the same example, "simple_agent.py",
but uses a TCP port instead of a Unix domain socket for the AgentX
communication.
- "run_threading_agent.py" runs "threading_agent.py" (doh!).
If instead you want to run the example agents (or later on your own agents)
against your system-wide snmpd instance, your /etc/snmp/snmpd.conf (the path
may vary) must be configured appropriately. See the comments at the beginning
of simple_agent.py for more info.
|