summaryrefslogtreecommitdiff
path: root/examples/smi/agent
diff options
context:
space:
mode:
Diffstat (limited to 'examples/smi/agent')
-rw-r--r--examples/smi/agent/custom-managed-object.py5
-rw-r--r--examples/smi/agent/operations-on-managed-objects.py6
2 files changed, 8 insertions, 3 deletions
diff --git a/examples/smi/agent/custom-managed-object.py b/examples/smi/agent/custom-managed-object.py
index 50aee947..a6c3137b 100644
--- a/examples/smi/agent/custom-managed-object.py
+++ b/examples/smi/agent/custom-managed-object.py
@@ -55,9 +55,12 @@ if __name__ == '__main__':
def cbFun(varBinds, **context):
+
for oid, val in varBinds:
+
if exval.endOfMib.isSameTypeWith(val):
context['app']['stop'] = True
+
print('%s = %s' % ('.'.join([str(x) for x in oid]), not val.isValue and 'N/A' or val.prettyPrint()))
context['app']['varBinds'] = varBinds
@@ -69,6 +72,8 @@ if __name__ == '__main__':
}
print('Remote manager read access to MIB instrumentation (table walk)')
+
while not app_context['stop']:
mibInstrum.readNextMibObjects(*app_context['varBinds'], cbFun=cbFun, app=app_context)
+
print('done')
diff --git a/examples/smi/agent/operations-on-managed-objects.py b/examples/smi/agent/operations-on-managed-objects.py
index 75b9a765..704a6be5 100644
--- a/examples/smi/agent/operations-on-managed-objects.py
+++ b/examples/smi/agent/operations-on-managed-objects.py
@@ -10,12 +10,10 @@ from pysnmp.smi import builder
from pysnmp.smi import instrum
from pysnmp.smi import exval
from pysnmp.smi import error
-from pysnmp import debug
-
-#debug.setLogger(debug.Debug('all'))
def walkMib():
+
def cbFun(varBinds, **context):
err = context.get('error')
if err:
@@ -38,6 +36,7 @@ def walkMib():
}
print('Read whole MIB (table walk)')
+
while not app_context['stop']:
mibInstrum.readNextMibObjects(*app_context['varBinds'], cbFun=cbFun, app=app_context)
@@ -103,6 +102,7 @@ def cbFun(varBinds, **context):
err = context.get('errors', None)
if err:
print(err)
+
for oid, val in varBinds:
print('%s = %s' % ('.'.join([str(x) for x in oid]), not val.isValue and 'N/A' or val.prettyPrint()))