File: backend.py

package info (click to toggle)
python-pysnmp4 4.1.6a-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,016 kB
  • ctags: 1,826
  • sloc: python: 9,809; sh: 60; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 830 bytes parent folder | download
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
# SNMP agent backend e.g. Agent access to Managed Objects
from pysnmp.smi import builder, instrum, exval

print 'Loading MIB modules...',
mibBuilder = builder.MibBuilder().loadModules(
    'SNMPv2-MIB', 'SNMP-FRAMEWORK-MIB', 'SNMP-COMMUNITY-MIB'
    )
print 'done'

print 'Building MIB tree...',
mibInstrum = instrum.MibInstrumController(mibBuilder)
print 'done'

print 'Remote manager write/create access to MIB instrumentation: ',
print mibInstrum.writeVars(
    (((1,3,6,1,6,3,18,1,1,1,2,109,121,110,109,115), 'mycomm'),
     ((1,3,6,1,6,3,18,1,1,1,3,109,121,110,109,115), 'mynmsname'))
    )

print 'Remote manager read access to MIB instrumentation (table walk)'
oid, val = (), None
while 1:
    oid, val = mibInstrum.readNextVars(((oid, val),))[0]
    if exval.endOfMib.isSameTypeWith(val):
        break
    print oid, val