summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorelie <elie>2015-05-31 19:35:10 +0000
committerelie <elie>2015-05-31 19:35:10 +0000
commitbea11dfe16e6714737b6f5016697206a038f051b (patch)
tree439ca11bab4cacb13f6438d50ad8500e902fdd82 /examples
parent8a7fa29b9b4cd263db4b283704bda1c09eb002e6 (diff)
downloadpysnmp-bea11dfe16e6714737b6f5016697206a038f051b.tar.gz
Major overhaul related to PySMI integration and Standard SNMP Applications
API redesign: * MibVariable becomes ObjectIdentity and moves to pysnmp.smi.rfc1902 * ObjectType and NotificationType classes resempling corresponding MIB MACROs implemented * SNMP Standard Applications and examples modified to support ObjectType and NotificationType parameters
Diffstat (limited to 'examples')
-rw-r--r--examples/v3arch/agent/ntforg/inform-multiple-protocols.py26
-rw-r--r--examples/v3arch/agent/ntforg/inform-v2c.py28
-rw-r--r--examples/v3arch/agent/ntforg/inform-v3.py24
-rw-r--r--examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py22
-rw-r--r--examples/v3arch/agent/ntforg/trap-v1.py25
-rw-r--r--examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py27
-rw-r--r--examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py25
-rw-r--r--examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py27
-rw-r--r--examples/v3arch/agent/ntforg/trap-v2c-with-objects.py83
-rw-r--r--examples/v3arch/agent/ntforg/trap-v2c.py27
-rw-r--r--examples/v3arch/agent/ntforg/trap-v3.py25
-rw-r--r--examples/v3arch/manager/cmdgen/getnext-v2c-with-mib-compilation-and-lookup.py88
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py21
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-transports-and-protocols.py21
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-v2c-with-mib-lookup.py7
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextengineid.py8
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextname.py9
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-v3.py7
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/trap-async-multiple-transports-and-protocols.py23
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/trap-v1-with-custom-values.py16
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/trap-v1-with-default-values.py9
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/trap-v2c-with-mib-lookup.py3
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/trap-v3-with-custom-engineid.py4
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-snmp-engines.py12
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-transports-and-protocols.py20
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-threaded-multiple-transports-and-protocols.py20
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v1.py4
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-mib-compilation-and-lookup.py (renamed from examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-asn1-mib-lookup.py)9
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v3-over-ipv6-with-mib-lookup.py4
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-index.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-multiple-indices.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/get-v3-with-mib-lookup.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-over-ipv6-with-mib-lookup.py4
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-with-custom-mib-path-and-options.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.py4
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-v1-with-custom-mibs-location.py6
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-v1.py10
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-v3-over-ipv6-with-mib-lookup.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-options.py2
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/set-v2c-with-value-type-mib-lookup.py5
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid-and-contextname.py5
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid.py5
-rw-r--r--examples/v3arch/oneliner/manager/cmdgen/set-v3-with-value-type-mib-lookup.py5
44 files changed, 357 insertions, 325 deletions
diff --git a/examples/v3arch/agent/ntforg/inform-multiple-protocols.py b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py
index a3fbb8d..8f70ef9 100644
--- a/examples/v3arch/agent/ntforg/inform-multiple-protocols.py
+++ b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py
@@ -18,7 +18,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -80,9 +80,6 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Error/confirmation receiver
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
errorStatus, errorIndex, varBinds, cbCtx):
@@ -94,18 +91,15 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# Build and submit notification message to dispatcher
sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
- # Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')) ],
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator'))
+ ],
cbFun
)
diff --git a/examples/v3arch/agent/ntforg/inform-v2c.py b/examples/v3arch/agent/ntforg/inform-v2c.py
index 08993b0..9c52655 100644
--- a/examples/v3arch/agent/ntforg/inform-v2c.py
+++ b/examples/v3arch/agent/ntforg/inform-v2c.py
@@ -15,7 +15,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -59,9 +59,6 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Error/confirmation receiver
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
errorStatus, errorIndex, varBinds, cbCtx):
@@ -73,19 +70,16 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# Build and submit notification message to dispatcher
sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
- # Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ],
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ],
cbFun
)
diff --git a/examples/v3arch/agent/ntforg/inform-v3.py b/examples/v3arch/agent/ntforg/inform-v3.py
index facebe3..ef5355a 100644
--- a/examples/v3arch/agent/ntforg/inform-v3.py
+++ b/examples/v3arch/agent/ntforg/inform-v3.py
@@ -13,7 +13,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -54,11 +54,8 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6))
# *** SNMP engine configuration is complete by this line ***
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Create Notification Originator App instance.
-ntfOrg = ntforg.NotificationOriginator(snmpContext)
+ntfOrg = ntforg.NotificationOriginator()
# Error/confirmation receiver
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -71,18 +68,11 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# Build and submit notification message to dispatcher
sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
- # Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ],
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds: SNMPv2-MIB::coldStart, ...
+ [ ((1,3,6,1,6,3,1,1,5,1), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ],
cbFun
)
diff --git a/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py
index 2bfa05d..04dcd56 100644
--- a/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py
+++ b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py
@@ -13,7 +13,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -57,22 +57,16 @@ config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
- # Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
- # Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1)))
+ ]
)
print('Notification is scheduled to be sent')
diff --git a/examples/v3arch/agent/ntforg/trap-v1.py b/examples/v3arch/agent/ntforg/trap-v1.py
index f21bde5..2ac5071 100644
--- a/examples/v3arch/agent/ntforg/trap-v1.py
+++ b/examples/v3arch/agent/ntforg/trap-v1.py
@@ -17,7 +17,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
#from pysnmp import debug
@@ -64,28 +64,21 @@ config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
- # Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name: Generic Trap #6 (enterpriseSpecific)
- # and Specific Trap 432
- '1.3.6.1.4.1.20408.4.1.1.2.0.432',
- # instance Index
- None,
- # additional var-binds
- [
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
# Uptime value with 12345
(v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'),
v2c.TimeTicks(12345)),
+ # trap OID: Generic Trap #6 (enterpriseSpecific)
+ # and Specific Trap 432
+ (v2c.ObjectIdentifier('1.3.6.1.6.3.1.1.5.1'),
+ v2c.ObjectIdentifier('1.3.6.1.4.1.20408.4.1.1.2.0.432')),
# Agent Address with '127.0.0.1'
(v2c.ObjectIdentifier('1.3.6.1.6.3.18.1.3.0'),
v2c.IpAddress('127.0.0.1')),
diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py
index 329268f..709e972 100644
--- a/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py
+++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py
@@ -16,7 +16,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -74,25 +74,20 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ]
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ]
)
print('Notifications are scheduled to be sent')
diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py
index 0ca3d70..cd6432b 100644
--- a/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py
+++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py
@@ -16,7 +16,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -70,22 +70,23 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# *** SNMP engine configuration is complete by this line ***
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Create Notification Originator App instance.
-ntfOrg = ntforg.NotificationOriginator(snmpContext)
+ntfOrg = ntforg.NotificationOriginator()
# Build and submit notification message to dispatcher
-ntfOrg.sendNotification(
+ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # Trap OID (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # ( (oid, value), ... )
- ( ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) )
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ]
)
print('Notifications are scheduled to be sent')
diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py
index ea204f2..e2589da 100644
--- a/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py
+++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py
@@ -15,7 +15,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp, udp6
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -73,25 +73,20 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
- # Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ]
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ]
)
print('Notification is scheduled to be sent')
diff --git a/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py
index e4ac2e0..ad17348 100644
--- a/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py
+++ b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py
@@ -8,28 +8,24 @@
# * over IPv4/UDP
# * send TRAP notification
# * to a Manager at 127.0.0.1:162
-# * with TRAP ID ACCOUNTING-CONTROL-MIB::acctngFileFull as MIB symbol
+# * with TRAP ID IF-MIB::ifLink as MIB symbol
#
-# The ACCOUNTING-CONTROL-MIB::acctngFileFull NOTIFICATION-TYPE implies
-# including three other var-binds into the TRAP describing the incident
-# occurred. These var-binds are:
-# ACCOUNTING-CONTROL-MIB::acctngFileMaximumSize.0
-# ACCOUNTING-CONTROL-MIB::acctngFileNameSuffix.0
-# ACCOUNTING-CONTROL-MIB::acctngFileName.0
+# The IF-MIB::ifLink NOTIFICATION-TYPE implies including four other
+# var-binds into the notification message describing the incident
+# occurred. These var-binds are:
+# IF-MIB::ifIndex."x"
+# IF-MIB::ifAdminStatus."x"
+# IF-MIB::ifOperStatus."x"
+# IF-MIB::ifDescr."x"
#
-# To run this example make sure to have ACCOUNTING-CONTROL-MIB.py in
-# search path.
+# Where "x" is MIB table index (instance index).
+#
+# To run this example make sure to have IF-MIB.py in search path.
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
-from pysnmp.proto.api import v2c
-
-# Create SNMP engine instance
-snmpEngine = engine.SnmpEngine()
-
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
+from pysnmp.entity.rfc3413 import ntforg
+from pysnmp.smi import rfc1902, view
#
# Here we fill in some values for Managed Objects Instances (invoked
@@ -37,33 +33,19 @@ snmpContext = context.SnmpContext(snmpEngine)
# In real Agent app, these values should already be initialized during
# Agent runtime.
#
+instanceIndex = (1,)
+objects = {
+ ('IF-MIB', 'ifIndex'): instanceIndex[0],
+ ('IF-MIB', 'ifAdminStatus'): 'up',
+ ('IF-MIB', 'ifOperStatus'): 'down',
+ ('IF-MIB', 'ifDescr'): 'eth0'
+}
-mibInstrumCtl = snmpContext.getMibInstrum('')
-( MibScalarInstance, ) = mibInstrumCtl.mibBuilder.importSymbols(
- 'SNMPv2-SMI',
- 'MibScalarInstance'
- )
-( acctngFileFull,
- acctngFileMaximumSize,
- acctngFileNameSuffix,
- acctngFileName ) = mibInstrumCtl.mibBuilder.importSymbols(
- 'ACCOUNTING-CONTROL-MIB',
- 'acctngFileFull',
- 'acctngFileMaximumSize',
- 'acctngFileNameSuffix',
- 'acctngFileName'
- )
-
-mibInstrumCtl.mibBuilder.exportSymbols(
- '__ACCOUNTING-CONTROL-MIB',
- MibScalarInstance(acctngFileMaximumSize.name, (0,), acctngFileMaximumSize.syntax.clone(123)),
- MibScalarInstance(acctngFileNameSuffix.name, (0,), acctngFileNameSuffix.syntax.clone('.log')),
- MibScalarInstance(acctngFileName.name, (0,), acctngFileName.syntax.clone('mylogfile')),
-)
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
-#
-# End of Agent's Managed Object Instances initialization
-#
+# MIB view controller is used for MIB lookup purposes
+mibViewController = view.MibViewController(snmpEngine.getMibBuilder())
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public', transportTag='all-my-managers')
@@ -107,16 +89,13 @@ ntfOrg = ntforg.NotificationOriginator()
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
- # Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name
- ('ACCOUNTING-CONTROL-MIB', 'acctngFileFull'),
- # MIB scalar/table instances of NOTIFICATION-TYPE objects
- (0,)
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ rfc1902.NotificationType(
+ rfc1902.ObjectIdentity('IF-MIB', 'linkUp'),
+ instanceIndex=instanceIndex,
+ objects=objects
+ ).resolveWithMib(mibViewController)
)
print('Notification is scheduled to be sent')
diff --git a/examples/v3arch/agent/ntforg/trap-v2c.py b/examples/v3arch/agent/ntforg/trap-v2c.py
index 4e3465b..d63a371 100644
--- a/examples/v3arch/agent/ntforg/trap-v2c.py
+++ b/examples/v3arch/agent/ntforg/trap-v2c.py
@@ -15,7 +15,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance
@@ -58,9 +58,6 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
- # Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Error/confirmation receiver
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
errorStatus, errorIndex, varBinds, cbCtx):
@@ -73,18 +70,16 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ],
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ],
cbFun
)
diff --git a/examples/v3arch/agent/ntforg/trap-v3.py b/examples/v3arch/agent/ntforg/trap-v3.py
index bff341a..266d91e 100644
--- a/examples/v3arch/agent/ntforg/trap-v3.py
+++ b/examples/v3arch/agent/ntforg/trap-v3.py
@@ -13,7 +13,7 @@
#
from pysnmp.entity import engine, config
from pysnmp.carrier.asynsock.dgram import udp
-from pysnmp.entity.rfc3413 import ntforg, context
+from pysnmp.entity.rfc3413 import ntforg
from pysnmp.proto.api import v2c
# Create SNMP engine instance with specific (and locally unique)
@@ -62,24 +62,19 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6))
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
- # Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
- 'my-notification',
- # SNMP Context
- snmpContext,
- # contextName
- '',
- # notification name (SNMPv2-MIB::coldStart)
- (1,3,6,1,6,3,1,1,5,1),
- # instance Index
- None,
- # additional var-binds: ( (oid, value), ... )
- [ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ]
+ 'my-notification', # notification targets
+ None, '', # contextEngineId, contextName
+ # var-binds
+ [
+ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
+ ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ # additional var-binds: ( (oid, value), ... )
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ]
)
print('Notification is scheduled to be sent')
diff --git a/examples/v3arch/manager/cmdgen/getnext-v2c-with-mib-compilation-and-lookup.py b/examples/v3arch/manager/cmdgen/getnext-v2c-with-mib-compilation-and-lookup.py
new file mode 100644
index 0000000..a8c5b35
--- /dev/null
+++ b/examples/v3arch/manager/cmdgen/getnext-v2c-with-mib-compilation-and-lookup.py
@@ -0,0 +1,88 @@
+#
+# GETNEXT Command Generator
+#
+# Send a series of SNMP GETNEXT requests
+# with SNMPv1, community 'public'
+# over IPv4/UDP
+# to an Agent at 195.218.195.228:161
+# for two OIDs in tuple form
+# stop on end-of-mib condition for both OIDs
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1
+#
+from pysnmp.entity import engine, config
+from pysnmp.carrier.asynsock.dgram import udp
+from pysnmp.entity.rfc3413 import cmdgen
+from pysnmp.smi import compiler, view, rfc1902
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+# Attach MIB compiler to SNMP Engine (MIB Builder)
+compiler.addMibCompiler(snmpEngine.getMibBuilder())
+
+# Used for MIB objects resolution
+mibViewController = view.MibViewController(snmpEngine.getMibBuilder())
+
+#
+#
+# SNMPv1/2c setup
+#
+
+# SecurityName <-> CommunityName mapping
+config.addV1System(snmpEngine, 'my-area', 'public')
+
+# Specify security settings per SecurityName (SNMPv1 - 0, SNMPv2c - 1)
+config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1)
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpSocketTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds'
+)
+
+# Error/response receiver
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBindTable, cbCtx):
+ if errorIndication:
+ print(errorIndication)
+ return
+ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
+ # so we ignore noSuchName error here
+ if errorStatus and errorStatus != 2:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
+ )
+ )
+ return # stop on error
+ for varBindRow in varBindTable:
+ for varBind in varBindRow:
+ print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]), varBind[1]).resolveWithMib(mibViewController).prettyPrint())
+ return 1 # signal dispatcher to continue
+
+# Prepare initial request to be sent
+cmdgen.NextCommandGenerator().sendVarBinds(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ [ rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController),
+ rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController) ],
+ cbFun
+)
+
+# Run I/O dispatcher which would send pending queries and process responses
+snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
index 088b72b..2dfbc55 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
@@ -26,19 +26,19 @@
#
from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.entity import engine
-from pysnmp.entity.rfc3413 import context
from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher
-from pysnmp.proto import rfc1902
# List of targets in the following format:
# ( ( authData, transportTarget ), ... )
targets = (
# 1-st target (SNMPv2c over IPv4/UDP)
( ntforg.CommunityData('public'),
- ntforg.UdpTransportTarget(('localhost', 1162)) ),
+ ntforg.UdpTransportTarget(('localhost', 1162)),
+ ntforg.ContextData() ),
# 2-nd target (SNMPv3 over IPv4/UDP)
( ntforg.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
- ntforg.UdpTransportTarget(('localhost', 162)) )
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
)
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -69,19 +69,18 @@ snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B')
ntfOrg = ntforg.AsyncNotificationOriginator()
-for authData, transportTarget in targets:
+for authData, transportTarget, contextData in targets:
snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \
snmpEngineA or snmpEngineB
sendPduHandle = ntfOrg.sendNotification(
snmpEngine,
authData,
transportTarget,
- context.SnmpContext(snmpEngine),
- ntforg.null,
- 'inform',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ( rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
- rfc1902.OctetString('my name') ), ),
+ contextData,
+ 'inform', # NotifyType
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ),
cbInfo=(cbFun, snmpEngine)
)
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-transports-and-protocols.py b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-transports-and-protocols.py
index a19bc11..fc4a358 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-transports-and-protocols.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-transports-and-protocols.py
@@ -12,19 +12,19 @@
# * include managed object information specified as var-bind objects pair
#
from pysnmp.entity.rfc3413.oneliner import ntforg
-from pysnmp.entity.rfc3413 import context
from pysnmp.entity import engine
-from pysnmp.proto import rfc1902
# List of targets in the followin format:
# ( ( authData, transportTarget ), ... )
targets = (
# 1-st target (SNMPv2c over IPv4/UDP)
( ntforg.CommunityData('public'),
- ntforg.UdpTransportTarget(('localhost', 162)) ),
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
# 2-nd target (SNMPv3 over IPv4/UDP)
( ntforg.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
- ntforg.UdpTransportTarget(('localhost', 162)) )
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
)
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -43,17 +43,16 @@ snmpEngine = engine.SnmpEngine()
ntfOrg = ntforg.AsyncNotificationOriginator()
-for authData, transportTarget in targets:
+for authData, transportTarget, contextData in targets:
sendPduHandle = ntfOrg.sendNotification(
snmpEngine,
authData,
transportTarget,
- context.SnmpContext(snmpEngine),
- ntforg.null,
- 'inform',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ( rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
- rfc1902.OctetString('my name') ), ),
+ contextData,
+ 'inform', # NotifyType
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ),
cbInfo=(cbFun, None)
)
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-v2c-with-mib-lookup.py b/examples/v3arch/oneliner/agent/ntforg/inform-v2c-with-mib-lookup.py
index ca51d28..330b6b2 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-v2c-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-v2c-with-mib-lookup.py
@@ -19,8 +19,11 @@ errorIndication, errorStatus, errorIndex, varBinds = ntfOrg.sendNotification(
ntforg.CommunityData('public'),
ntforg.UdpTransportTarget(('localhost', 162)),
'inform',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ntforg.MibVariable('SNMPv2-MIB', 'sysName', 0), 'my system' ),
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds(
+ ( ntforg.ObjectIdentity('SNMPv2-MIB', 'sysName', 0), 'my system' )
+ ),
lookupNames=True, lookupValues=True
)
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextengineid.py b/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextengineid.py
index 60ab7b2..5e8c053 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextengineid.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextengineid.py
@@ -20,17 +20,15 @@ from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.proto import rfc1902
snmpEngine = engine.SnmpEngine()
-snmpContext = context.SnmpContext(
- snmpEngine,contextEngineId=rfc1902.OctetString(hexValue='8000000004030201')
-)
-ntfOrg = ntforg.NotificationOriginator(snmpEngine, snmpContext)
+ntfOrg = ntforg.NotificationOriginator(snmpEngine)
errorIndication, errorStatus, errorIndex, varBinds = ntfOrg.sendNotification(
ntforg.UsmUserData('usr-md5-none', 'authkey1'),
ntforg.UdpTransportTarget(('localhost', 162)),
'inform',
- '1.3.6.1.6.3.1.1.5.2'
+ ntforg.NotificationType(ntforg.ObjectIdentity('1.3.6.1.6.3.1.1.5.2')),
+ contextEngineId=rfc1902.OctetString(hexValue='8000000004030201')
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextname.py b/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextname.py
index 1d1085e..dfe0ad0 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextname.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-v3-with-custom-contextname.py
@@ -15,22 +15,17 @@
# the ContextName being used.
#
from pysnmp.entity import engine
-from pysnmp.entity.rfc3413 import context
from pysnmp.entity.rfc3413.oneliner import ntforg
snmpEngine = engine.SnmpEngine()
-snmpContext = context.SnmpContext(snmpEngine)
-# register default collection of Managed Objects under new contextName
-snmpContext.registerContextName('my-context', snmpContext.getMibInstrum())
-
-ntfOrg = ntforg.NotificationOriginator(snmpEngine, snmpContext)
+ntfOrg = ntforg.NotificationOriginator(snmpEngine)
errorIndication, errorStatus, errorIndex, varBinds = ntfOrg.sendNotification(
ntforg.UsmUserData('usr-md5-none', 'authkey1'),
ntforg.UdpTransportTarget(('localhost', 162)),
'inform',
- '1.3.6.1.6.3.1.1.5.2',
+ ntforg.NotificationType(ntforg.ObjectIdentity('1.3.6.1.6.3.1.1.5.2')),
contextName='my-context'
)
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-v3.py b/examples/v3arch/oneliner/agent/ntforg/inform-v3.py
index 41d996e..f9abe91 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-v3.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-v3.py
@@ -19,8 +19,11 @@ errorIndication, errorStatus, errorIndex, varBinds = ntfOrg.sendNotification(
ntforg.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
ntforg.UdpTransportTarget(('localhost', 162)),
'inform',
- '1.3.6.1.6.3.1.1.5.2',
- ('1.3.6.1.2.1.1.5.0', rfc1902.OctetString('system name'))
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).addVarBinds(
+ ('1.3.6.1.2.1.1.5.0', rfc1902.OctetString('system name'))
+ )
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/agent/ntforg/trap-async-multiple-transports-and-protocols.py b/examples/v3arch/oneliner/agent/ntforg/trap-async-multiple-transports-and-protocols.py
index a075fda..c9e955e 100644
--- a/examples/v3arch/oneliner/agent/ntforg/trap-async-multiple-transports-and-protocols.py
+++ b/examples/v3arch/oneliner/agent/ntforg/trap-async-multiple-transports-and-protocols.py
@@ -12,7 +12,6 @@
# * include managed object information specified as var-bind objects pair
#
from pysnmp.entity.rfc3413.oneliner import ntforg
-from pysnmp.entity.rfc3413 import context
from pysnmp.entity import engine
from pysnmp.proto import rfc1902
@@ -21,27 +20,31 @@ from pysnmp.proto import rfc1902
targets = (
# 1-st target (SNMPv1 over IPv4/UDP)
( ntforg.CommunityData('public', mpModel=0),
- ntforg.UdpTransportTarget(('localhost', 162)) ),
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
# 2-nd target (SNMPv2c over IPv4/UDP)
( ntforg.CommunityData('public'),
- ntforg.UdpTransportTarget(('localhost', 162)) )
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
)
snmpEngine = engine.SnmpEngine()
ntfOrg = ntforg.AsyncNotificationOriginator()
-for authData, transportTarget in targets:
+for authData, transportTarget, contextData in targets:
ntfOrg.sendNotification(
snmpEngine,
authData,
transportTarget,
- context.SnmpContext(snmpEngine),
- ntforg.null,
- 'trap',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ( rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
- rfc1902.OctetString('my name') ), )
+ contextData,
+ 'trap', # NotifyType
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds(
+ ( rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
+ rfc1902.OctetString('my name') )
+ )
)
snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-custom-values.py b/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-custom-values.py
index e2ba44a..7db778e 100644
--- a/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-custom-values.py
+++ b/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-custom-values.py
@@ -15,6 +15,9 @@
#
from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.proto import rfc1902
+#from pysnmp import debug
+
+#debug.setLogger(debug.Debug('mibview'))
ntfOrg = ntforg.NotificationOriginator()
@@ -22,11 +25,14 @@ errorIndication = ntfOrg.sendNotification(
ntforg.CommunityData('public', mpModel=0),
ntforg.UdpTransportTarget(('localhost', 162)),
'trap',
- '1.3.6.1.4.1.20408.4.1.1.2.0.432',
- ('1.3.6.1.2.1.1.3.0', 12345),
- ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'),
- ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
- ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'),
+ ).addVarBinds(
+ ('1.3.6.1.2.1.1.3.0', 12345),
+ ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'),
+ ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
+ ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ )
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-default-values.py b/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-default-values.py
index 4a845f4..beab6e7 100644
--- a/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-default-values.py
+++ b/examples/v3arch/oneliner/agent/ntforg/trap-v1-with-default-values.py
@@ -22,9 +22,12 @@ errorIndication = ntfOrg.sendNotification(
ntforg.CommunityData('public', mpModel=0),
ntforg.UdpTransportTarget(('localhost', 162)),
'trap',
- '1.3.6.1.6.3.1.1.5.2',
- ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
- ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).addVarBinds(
+ ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
+ ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ )
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/agent/ntforg/trap-v2c-with-mib-lookup.py b/examples/v3arch/oneliner/agent/ntforg/trap-v2c-with-mib-lookup.py
index 7d01883..502b3a0 100644
--- a/examples/v3arch/oneliner/agent/ntforg/trap-v2c-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/agent/ntforg/trap-v2c-with-mib-lookup.py
@@ -18,8 +18,7 @@ errorIndication = ntfOrg.sendNotification(
ntforg.CommunityData('public'),
ntforg.UdpTransportTarget(('localhost', 162)),
'trap',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ntforg.MibVariable('SNMPv2-MIB', 'sysName', 0), 'new name' )
+ ntforg.NotificationType(ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart'))
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/agent/ntforg/trap-v3-with-custom-engineid.py b/examples/v3arch/oneliner/agent/ntforg/trap-v3-with-custom-engineid.py
index 7aa72f4..60cb0a6 100644
--- a/examples/v3arch/oneliner/agent/ntforg/trap-v3-with-custom-engineid.py
+++ b/examples/v3arch/oneliner/agent/ntforg/trap-v3-with-custom-engineid.py
@@ -30,7 +30,9 @@ errorIndication = ntfOrg.sendNotification(
privProtocol=ntforg.usmAesCfb128Protocol),
ntforg.UdpTransportTarget(('127.0.0.1', 162)),
'trap',
- ntforg.MibVariable('SNMPv2-MIB', 'authenticationFailure')
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')
+ )
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-snmp-engines.py b/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-snmp-engines.py
index 1b7d156..94c1f54 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-snmp-engines.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-snmp-engines.py
@@ -35,18 +35,18 @@ targets = (
# 1-st target (SNMPv1 over IPv4/UDP)
( cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 2-nd target (SNMPv2c over IPv4/UDP)
( cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 1161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 3-nd target (SNMPv3 over IPv4/UDP)
( cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 2161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) )
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) )
# N-th target
# ...
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-transports-and-protocols.py b/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-transports-and-protocols.py
index d70617d..d169377 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-transports-and-protocols.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-async-multiple-transports-and-protocols.py
@@ -22,29 +22,29 @@ targets = (
# 1-st target (SNMPv1 over IPv4/UDP)
( cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 2-nd target (SNMPv2c over IPv4/UDP)
( cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 3-nd target (SNMPv2c over IPv4/UDP) - same community and
# different transport address.
( cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('localhost', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysContact', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysContact', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysName', 0) ) ),
# 4-nd target (SNMPv3 over IPv4/UDP)
( cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 5-th target (SNMPv3 over IPv6/UDP)
( cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# N-th target
# ...
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-threaded-multiple-transports-and-protocols.py b/examples/v3arch/oneliner/manager/cmdgen/get-threaded-multiple-transports-and-protocols.py
index df22afb..5d589f9 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-threaded-multiple-transports-and-protocols.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-threaded-multiple-transports-and-protocols.py
@@ -28,29 +28,29 @@ targets = (
# 1-st target (SNMPv1 over IPv4/UDP)
( cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 2-nd target (SNMPv2c over IPv4/UDP)
( cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 3-nd target (SNMPv2c over IPv4/UDP) - same community and
# different transport address.
( cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('localhost', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysContact', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysContact', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysName', 0) ) ),
# 4-nd target (SNMPv3 over IPv4/UDP)
( cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# 5-th target (SNMPv3 over IPv6/UDP)
( cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysLocation', 0) ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ) ),
# N-th target
# ...
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v1.py b/examples/v3arch/oneliner/manager/cmdgen/get-v1.py
index f05c5f8..664df9d 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v1.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v1.py
@@ -16,8 +16,8 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0'),
- cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0)
+ cmdgen.ObjectIdentity('iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0'),
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)
)
# Check for errors and print out results
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-asn1-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-mib-compilation-and-lookup.py
index a8f1e73..2c69699 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-asn1-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v2c-with-mib-compilation-and-lookup.py
@@ -9,16 +9,13 @@
# * for IF-MIB::ifInOctets.1 MIB object
#
from pysnmp.entity.rfc3413.oneliner import cmdgen
-from pysnmp import debug
-
-#debug.setLogger(debug.Debug('mibbuild'))
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifInOctets', '1').addAsn1Sources('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/<mib>'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifInOctets', 1).addMibCompiler('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/<mib>'),
lookupNames=True, lookupValues=True
)
@@ -33,5 +30,5 @@ else:
)
)
else:
- for name, val in varBinds:
- print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+ for oid, val in varBinds:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v3-over-ipv6-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/get-v3-over-ipv6-with-mib-lookup.py
index 452c811..b766fad 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v3-over-ipv6-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v3-over-ipv6-with-mib-lookup.py
@@ -6,7 +6,7 @@
# * with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols
# * over IPv6/UDP
# * to an Agent at [::1]:161
-# * for three OIDs: one passed as a MibVariable object while others are
+# * for three OIDs: one passed as a ObjectIdentity object while others are
# * in string form
#
from pysnmp.entity.rfc3413.oneliner import cmdgen
@@ -16,7 +16,7 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
- cmdgen.MibVariable('1.3.6.1.2.1.1.1.0'),
+ cmdgen.ObjectIdentity('1.3.6.1.2.1.1.1.0'),
'1.3.6.1.2.1.1.2.0',
'1.3.6.1.2.1.1.3.0'
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-index.py b/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-index.py
index 35fe0df..c641993 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-index.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-index.py
@@ -16,7 +16,7 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.UsmUserData('usr-none-none'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifInOctets', '1'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifInOctets', 1),
lookupNames=True, lookupValues=True
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-multiple-indices.py b/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-multiple-indices.py
index 74f31b0..8bc4562 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-multiple-indices.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v3-table-object-by-multiple-indices.py
@@ -17,7 +17,7 @@ errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
authProtocol=cmdgen.usmHMACSHAAuthProtocol,
privProtocol=cmdgen.usmAesCfb128Protocol ),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('TCP-MIB', 'tcpConnLocalAddress', '0.0.0.0', 22, '0.0.0.0', 0)
+ cmdgen.ObjectIdentity('TCP-MIB', 'tcpConnLocalAddress', '0.0.0.0', 22, '0.0.0.0', 0)
)
# Check for errors and print out results
diff --git a/examples/v3arch/oneliner/manager/cmdgen/get-v3-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/get-v3-with-mib-lookup.py
index 5392c0c..47f025f 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/get-v3-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/get-v3-with-mib-lookup.py
@@ -15,7 +15,7 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifInOctets', '1')
+ cmdgen.ObjectIdentity('IF-MIB', 'ifInOctets', 1)
)
# Check for errors and print out results
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-over-ipv6-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-over-ipv6-with-mib-lookup.py
index 7291ee8..99df3c1 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-over-ipv6-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-over-ipv6-with-mib-lookup.py
@@ -22,8 +22,8 @@ errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.bulkCmd(
cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
1, 25,
- cmdgen.MibVariable('IP-MIB', 'ipAdEntAddr'),
- cmdgen.MibVariable('IF-MIB', 'ifEntry'),
+ cmdgen.ObjectIdentity('IP-MIB', 'ipAdEntAddr'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifEntry'),
lookupNames=True, lookupValues=True, maxRows=20
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-with-custom-mib-path-and-options.py b/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-with-custom-mib-path-and-options.py
index a0f0f29..4ca6b6e 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-with-custom-mib-path-and-options.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getbulk-v3-with-custom-mib-path-and-options.py
@@ -22,7 +22,7 @@ errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.bulkCmd(
cmdgen.UsmUserData('usr-none-none'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
0, 50,
- cmdgen.MibVariable('TCP-MIB', 'tcpConnTable').addMibSource('/tmp/mymibs'),
+ cmdgen.ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/tmp/mibs'),
lexicographicMode=True, maxRows=100, maxCalls=10,ignoreNonIncreasingOid=True
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.py
index af3a40f..80ff0fe 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.py
@@ -29,11 +29,11 @@ targets = (
# 3-nd target (SNMPv3 over IPv4/UDP)
( cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- ( cmdgen.MibVariable('SNMPv2-MIB', 'system'), ) ),
+ ( cmdgen.ObjectIdentity('SNMPv2-MIB', 'system'), ) ),
# 4-th target (SNMPv3 over IPv6/UDP)
( cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
- ( cmdgen.MibVariable('IF-MIB', 'ifTable'), ) )
+ ( cmdgen.ObjectIdentity('IF-MIB', 'ifTable'), ) )
# N-th target
# ...
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v1-with-custom-mibs-location.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v1-with-custom-mibs-location.py
index 42e8f46..e693562 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-v1-with-custom-mibs-location.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v1-with-custom-mibs-location.py
@@ -21,7 +21,7 @@
# found relative to $PYTHONPATH. Besides searching MIBs as Python modules
# (which could be egg-ed or not), pysnmp can also search for stand-alone
# files in given directories. The latter could be specified by
-# MibVariable.addMibSource() calls. New search path entries are added
+# ObjectIdentity.addMibSource() calls. New search path entries are added
# in front of existing ones in search path.
#
from pysnmp.entity.rfc3413.oneliner import cmdgen
@@ -31,8 +31,8 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifDescr').addMibSource('/tmp/mymibs'),
- cmdgen.MibVariable('IF-MIB', 'ifType')
+ cmdgen.ObjectIdentity('IF-MIB', 'ifDescr').addMibSource('/tmp/mymibs'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifType')
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v1.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v1.py
index 2a69895..7be99e2 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-v1.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v1.py
@@ -18,11 +18,11 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.CommunityData('public', mpModel=0),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifDescr'),
- cmdgen.MibVariable('IF-MIB', 'ifType'),
- cmdgen.MibVariable('IF-MIB', 'ifMtu'),
- cmdgen.MibVariable('IF-MIB', 'ifSpeed'),
- cmdgen.MibVariable('IF-MIB', 'ifPhysAddress')
+ cmdgen.ObjectIdentity('IF-MIB', 'ifDescr'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifType'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifMtu'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifSpeed'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifPhysAddress')
)
if errorIndication:
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-over-ipv6-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-over-ipv6-with-mib-lookup.py
index 6354572..847ba25 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-over-ipv6-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-over-ipv6-with-mib-lookup.py
@@ -19,7 +19,7 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.Udp6TransportTarget(('::1', 161)),
- cmdgen.MibVariable('IF-MIB', 'ifEntry'),
+ cmdgen.ObjectIdentity('IF-MIB', 'ifEntry'),
lookupNames=True, lookupValues=True
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py
index 25352de..2d62e85 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py
@@ -19,7 +19,7 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', ''),
+ cmdgen.ObjectIdentity('IF-MIB', ''),
lookupValues=True
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-options.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-options.py
index 2e9c9f4..bdeda85 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-options.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-options.py
@@ -21,7 +21,7 @@ errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
authProtocol=cmdgen.usmHMACSHAAuthProtocol,
privProtocol=cmdgen.usmAesCfb128Protocol),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- cmdgen.MibVariable('IF-MIB', '').loadMibs(),
+ cmdgen.ObjectIdentity('IF-MIB', '').loadMibs(),
lexicographicMode=True, maxRows=100,
ignoreNonIncreasingOid=True
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/set-v2c-with-value-type-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/set-v2c-with-value-type-mib-lookup.py
index d58ad9c..6732ec2 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/set-v2c-with-value-type-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/set-v2c-with-value-type-mib-lookup.py
@@ -15,7 +15,10 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- (cmdgen.MibVariable('SNMPv2-MIB', 'sysORDescr', 1), 'new system name')
+ cmdgen.ObjectType(
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'
+ )
)
# Check for errors and print out results
diff --git a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid-and-contextname.py b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid-and-contextname.py
index e273bba..f28063b 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid-and-contextname.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid-and-contextname.py
@@ -19,7 +19,10 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
cmdgen.UsmUserData('usr-md5-none', 'authkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- (cmdgen.MibVariable('SNMPv2-MIB', 'sysORDescr', 1), 'new system name'),
+ cmdgen.ObjectType(
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'
+ ),
contextEngineId=rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'),
contextName='da761cfc8c94d3aceef4f60f049105ba'
)
diff --git a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid.py b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid.py
index 04ee0bf..124a26f 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-custom-contextengineid.py
@@ -23,7 +23,10 @@ errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
)
),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- (cmdgen.MibVariable('SNMPv2-MIB', 'sysORDescr', 1), 'new system name'),
+ cmdgen.ObjectType(
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'
+ )
)
# Check for errors and print out results
diff --git a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-value-type-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-value-type-mib-lookup.py
index 9734400..c5ce06d 100644
--- a/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-value-type-mib-lookup.py
+++ b/examples/v3arch/oneliner/manager/cmdgen/set-v3-with-value-type-mib-lookup.py
@@ -16,7 +16,10 @@ cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
cmdgen.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
- (cmdgen.MibVariable('SNMPv2-MIB', 'sysORDescr', 1), 'new system name'),
+ cmdgen.ObjectType(
+ cmdgen.ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'
+ ),
lookupNames=True, lookupValues=True
)