summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2014-12-15 22:58:08 +0000
committerelie <elie>2014-12-15 22:58:08 +0000
commit46b1e24d88a3441c21345d3b757eb61c4b226959 (patch)
treefc24f52aa94663b2818e165e1fc8035069798f8a
parent8a1d2aa33215905b7dd1c99a33ff31330b957dc4 (diff)
downloadpysnmp-46b1e24d88a3441c21345d3b757eb61c4b226959.tar.gz
trollius examples added
-rw-r--r--examples/v3arch/trollius/agent/ntforg/inform-v3.py120
-rw-r--r--examples/v3arch/trollius/agent/ntforg/trap-v1.py144
-rw-r--r--examples/v3arch/trollius/manager/cmdgen/get-v1.py99
-rw-r--r--examples/v3arch/trollius/manager/cmdgen/get-v2c-custom-timeout.py101
-rw-r--r--examples/v3arch/trollius/manager/cmdgen/getbulk-v3.py118
-rw-r--r--examples/v3arch/trollius/manager/cmdgen/getnext-v3.py111
-rw-r--r--examples/v3arch/trollius/manager/cmdgen/set-v2c.py101
7 files changed, 794 insertions, 0 deletions
diff --git a/examples/v3arch/trollius/agent/ntforg/inform-v3.py b/examples/v3arch/trollius/agent/ntforg/inform-v3.py
new file mode 100644
index 0000000..595bde5
--- /dev/null
+++ b/examples/v3arch/trollius/agent/ntforg/inform-v3.py
@@ -0,0 +1,120 @@
+#
+# Notification Originator
+#
+# Send SNMP INFORM notification using the following options:
+#
+# * SNMPv3
+# * with user 'usr-md5-none', auth: MD5, priv NONE
+# * over IPv4/UDP
+# * using Trollius framework for network transport
+# * to a Manager at 127.0.0.1:162
+# * send INFORM notification
+# * with TRAP ID 'warmStart' specified as an OID
+# * include managed object information 1.3.6.1.2.1.1.5.0 = 'system name'
+#
+# Requires Trollius framework!
+#
+from pysnmp.entity import engine, config
+from pysnmp.entity.rfc3413 import context
+from pysnmp.entity.rfc3413.asyncio import ntforg
+from pysnmp.carrier.asyncio.dgram import udp
+from pysnmp.proto import rfc1902
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+# SNMPv3/USM setup
+
+# Add USM user
+config.addV3User(
+ snmpEngine, 'usr-md5-none',
+ config.usmHMACMD5AuthProtocol, 'authkey1'
+)
+config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-none', 'authNoPriv')
+
+# Transport setup
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name. Since Notifications could be sent to multiple Managers
+# at once, more than one target entry may be configured (and tagged).
+#
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-nms',
+ udp.domainName, ('127.0.0.1', 162),
+ 'my-creds',
+ tagList='all-my-managers'
+)
+
+# Specify what kind of notification should be sent (TRAP or INFORM),
+# to what targets (chosen by tag) and what filter should apply to
+# the set of targets (selected by tag)
+config.addNotificationTarget(
+ snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'inform'
+)
+
+# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel
+# and SecurityName
+config.addContext(snmpEngine, '')
+config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6))
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, snmpContext, contextName,
+ notificationName, instanceIndex, additionalVarBinds):
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds ) = yield trollius.From(
+ ntforg.NotificationOriginator().sendVarBinds(
+ snmpEngine,
+ target,
+ snmpContext,
+ contextName,
+ notificationName,
+ instanceIndex,
+ additionalVarBinds
+ )
+ )
+
+ print('Notification status - %s' % (
+ errorIndication and errorIndication or 'delivered'
+ )
+ )
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+# Initiate sending SNMP message
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ # Notification targets
+ 'my-notification',
+ # Default SNMP context where contextEngineId == SnmpEngineId
+ context.SnmpContext(snmpEngine),
+ # contextName
+ '',
+ # notification name (SNMPv2-MIB::coldStart)
+ (1,3,6,1,6,3,1,1,5,1),
+ # notification objects instance index
+ None,
+ # additional var-binds: ( (oid, value), ... )
+ [ ((1,3,6,1,2,1,1,5,0), rfc1902.OctetString('system name')) ]
+ )
+)
+
+# Clear the event loop
+loop.close()
diff --git a/examples/v3arch/trollius/agent/ntforg/trap-v1.py b/examples/v3arch/trollius/agent/ntforg/trap-v1.py
new file mode 100644
index 0000000..2ec3dda
--- /dev/null
+++ b/examples/v3arch/trollius/agent/ntforg/trap-v1.py
@@ -0,0 +1,144 @@
+#
+# Notification Originator
+#
+# Send SNMP notification using the following options:
+#
+# * SNMPv1
+# * with community name 'public'
+# * over IPv4/UDP
+# * using Trollius framework for network transport
+# * to a Manager at 127.0.0.1:162
+# * send TRAP notification
+# * with TRAP ID 'coldStart' specified as an OID
+# * include managed objects information:
+# * overriding Uptime value with 12345
+# * overriding Agent Address with '127.0.0.1'
+# * overriding Enterprise OID with 1.3.6.1.4.1.20408.4.1.1.2
+# * include managed object information '1.3.6.1.2.1.1.1.0' = 'my system'
+#
+# Requires Trollius framework!
+#
+from pysnmp.entity import engine, config
+from pysnmp.entity.rfc3413 import context
+from pysnmp.entity.rfc3413.asyncio import ntforg
+from pysnmp.carrier.asyncio.dgram import udp
+from pysnmp.proto import rfc1902
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+# SNMPv1 setup
+
+# SecurityName <-> CommunityName mapping
+config.addV1System(snmpEngine, 'my-area', 'public')
+
+# Specify security settings per SecurityName (SNMPv1 -> 0)
+config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 0)
+
+# Transport setup
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name. Since Notifications could be sent to multiple Managers
+# at once, more than one target entry may be configured (and tagged).
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-nms-1',
+ udp.domainName, ('127.0.0.1', 162),
+ 'my-creds',
+ tagList='all-my-managers'
+)
+
+# Specify what kind of notification should be sent (TRAP or INFORM),
+# to what targets (chosen by tag) and what filter should apply to
+# the set of targets (selected by tag)
+config.addNotificationTarget(
+ snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap'
+)
+
+# Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel
+# and SecurityName
+config.addContext(snmpEngine, '')
+config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, snmpContext, contextName,
+ notificationName, instanceIndex, additionalVarBinds):
+ future = ntforg.NotificationOriginator().sendVarBinds(
+ snmpEngine,
+ target,
+ snmpContext,
+ contextName,
+ notificationName,
+ instanceIndex,
+ additionalVarBinds
+ )
+
+ # We know we are sending TRAP which will never produce any response.
+ # Therefore we simulate successful response here.
+ future.set_result((snmpEngine, None, 0, 0, ()))
+
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds ) = yield trollius.From(future)
+
+ if errorIndication:
+ print(errorIndication)
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+# Initiate sending SNMP message
+trollius.async(
+ snmpOperation(
+ snmpEngine,
+ # Notification targets
+ 'my-notification',
+ # Default SNMP context where contextEngineId == SnmpEngineId
+ context.SnmpContext(snmpEngine),
+ # contextName
+ '',
+ # notification name: Generic Trap #6 (enterpriseSpecific)
+ # and Specific Trap 432
+ '1.3.6.1.4.1.20408.4.1.1.2.0.432',
+ # notification objects instance index
+ None,
+ # additional var-binds holding SNMPv1 TRAP details
+ [
+ # Uptime value with 12345
+ (rfc1902.ObjectName('1.3.6.1.2.1.1.3.0'),
+ rfc1902.TimeTicks(12345)),
+ # Agent Address with '127.0.0.1'
+ (rfc1902.ObjectName('1.3.6.1.6.3.18.1.3.0'),
+ rfc1902.IpAddress('127.0.0.1')),
+ # Enterprise OID with 1.3.6.1.4.1.20408.4.1.1.2
+ (rfc1902.ObjectName('1.3.6.1.6.3.1.1.4.3.0'),
+ rfc1902.ObjectName('1.3.6.1.4.1.20408.4.1.1.2')),
+ # managed object '1.3.6.1.2.1.1.1.0' = 'my system'
+ (rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
+ rfc1902.OctetString('my system'))
+ ]
+ )
+)
+
+# Since SNMP TRAP's are unacknowledged, there's nothing to wait for. So we
+# simulate other loop activities by sleep()'ing.
+loop.run_until_complete(trollius.sleep(1))
+
+# Clear the event loop
+loop.close()
diff --git a/examples/v3arch/trollius/manager/cmdgen/get-v1.py b/examples/v3arch/trollius/manager/cmdgen/get-v1.py
new file mode 100644
index 0000000..523bee0
--- /dev/null
+++ b/examples/v3arch/trollius/manager/cmdgen/get-v1.py
@@ -0,0 +1,99 @@
+#
+# Command Generator
+#
+# Send SNMP GET request using the following options:
+#
+# * with SNMPv1, community 'public'
+# * using Trollius framework for network transport
+# * over IPv4/UDP
+# * to an Agent at 195.218.195.228:161
+# * for an OID in string form
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpset -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0
+#
+# Requires Trollius framework!
+#
+from pysnmp.carrier.asyncio.dgram import udp
+from pysnmp.entity.rfc3413.asyncio import cmdgen
+from pysnmp.entity import engine, config
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+#
+# SNMPv2c 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', 0)
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds'
+)
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, contextEngineId, contextName, varBinds):
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds ) = yield trollius.From(
+ cmdgen.GetCommandGenerator().sendVarBinds(
+ snmpEngine,
+ target,
+ contextEngineId,
+ contextName,
+ varBinds
+ )
+ )
+
+ if errorIndication:
+ print(errorIndication)
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ else:
+ for oid, val in varBinds:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ ( ('1.3.6.1.2.1.1.1.0', None), )
+ )
+)
+
+loop.close()
diff --git a/examples/v3arch/trollius/manager/cmdgen/get-v2c-custom-timeout.py b/examples/v3arch/trollius/manager/cmdgen/get-v2c-custom-timeout.py
new file mode 100644
index 0000000..fa7d8d3
--- /dev/null
+++ b/examples/v3arch/trollius/manager/cmdgen/get-v2c-custom-timeout.py
@@ -0,0 +1,101 @@
+#
+# GET Command Generator
+#
+# Send a SNMP GET request
+# with SNMPv2c, community 'public'
+# using Trollius framework for network transport
+# over IPv4/UDP
+# to an Agent at 195.218.195.228:161
+# wait 3 seconds for response, retry 5 times (plus one initial attempt)
+# for an OID in string form
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpget -v2c -c public -ObentU -r 5 -t 1 195.218.195.228 1.3.6.1.2.1.1.1.0
+#
+# Requires Trollius framework!
+#
+from pysnmp.carrier.asyncio.dgram import udp
+from pysnmp.entity.rfc3413.asyncio import cmdgen
+from pysnmp.entity import engine, config
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+#
+# SNMPv2c 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.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds',
+ timeout=300, # in 1/100 sec
+ retryCount=5
+)
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, contextEngineId, contextName, varBinds):
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds ) = yield trollius.From(
+ cmdgen.GetCommandGenerator().sendVarBinds(
+ snmpEngine,
+ target,
+ contextEngineId,
+ contextName,
+ varBinds
+ )
+ )
+
+ if errorIndication:
+ print(errorIndication)
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ else:
+ for oid, val in varBinds:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ ( ('1.3.6.1.2.1.1.1.0', None), )
+ )
+)
+
+loop.close()
diff --git a/examples/v3arch/trollius/manager/cmdgen/getbulk-v3.py b/examples/v3arch/trollius/manager/cmdgen/getbulk-v3.py
new file mode 100644
index 0000000..6847b42
--- /dev/null
+++ b/examples/v3arch/trollius/manager/cmdgen/getbulk-v3.py
@@ -0,0 +1,118 @@
+#
+# GETBULK Command Generator
+#
+# Send a series of SNMP GETBULK requests
+# with SNMPv3 with user 'usr-md5-des', M%d auth and DES privacy protocols
+# using Trollius framework for network transport
+# over IPv4/UDP
+# to an Agent at 195.218.195.228:161
+# with values non-repeaters = 0, max-repetitions = 25
+# for two OIDs in string form
+# stop on end-of-mib condition for both OIDs
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpbulkwalk -v2c -c public -C n0 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1
+#
+# Requires Trollius framework!
+#
+from pysnmp.entity import engine, config
+from pysnmp.proto import rfc1905
+from pysnmp.entity.rfc3413.asyncio import cmdgen
+from pysnmp.carrier.asyncio.dgram import udp
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+#
+# SNMPv3/USM setup
+#
+
+# user: usr-md5-des, auth: MD5, priv DES
+config.addV3User(
+ snmpEngine, 'usr-md5-des',
+ config.usmHMACMD5AuthProtocol, 'authkey1',
+ config.usmDESPrivProtocol, 'privkey1'
+)
+config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-des', 'authPriv')
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds'
+)
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, contextEngineId, contextName,
+ nonRepeaters, maxRepetitions, varBinds):
+ initialVarBinds = varBinds
+ while varBinds:
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBindTable ) = yield trollius.From(
+ cmdgen.BulkCommandGenerator().sendVarBinds(
+ snmpEngine,
+ target,
+ contextEngineId,
+ contextName,
+ nonRepeaters,
+ maxRepetitions,
+ varBinds
+ )
+ )
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBindRow in varBindTable:
+ for oid, val in varBindRow:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
+ errorIndication, varBinds = cmdgen.getNextVarBinds(
+ initialVarBinds, varBindRow
+ )
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+ loop.stop()
+
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ 0, 25, # nonRepeaters, maxRepetitions
+ ( ('1.3.6.1.2.1.1', None), ('1.3.6.1.2.1.11', None) )
+ )
+)
+
+loop.close()
diff --git a/examples/v3arch/trollius/manager/cmdgen/getnext-v3.py b/examples/v3arch/trollius/manager/cmdgen/getnext-v3.py
new file mode 100644
index 0000000..76784e3
--- /dev/null
+++ b/examples/v3arch/trollius/manager/cmdgen/getnext-v3.py
@@ -0,0 +1,111 @@
+#
+# GETNEXT Command Generator
+#
+# Send a series of SNMP GETNEXT requests
+# with SNMPv3 with user 'usr-none-none', no auth and no privacy protocols
+# using Asyncio framework for network transport
+# over IPv4/UDP
+# to an Agent at 195.218.195.228:161
+# for an OID in string form
+# stop on end-of-mib condition for both OIDs
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpwalk -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1
+#
+# Requires Trollius framework!
+#
+from pysnmp.entity import engine, config
+from pysnmp.proto import rfc1905
+from pysnmp.entity.rfc3413.asyncio import cmdgen
+from pysnmp.carrier.asyncio.dgram import udp
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+#
+# SNMPv3/USM setup
+#
+
+# user: usr-none-none, auth: none, priv: none
+config.addV3User(
+ snmpEngine, 'usr-none-none',
+)
+config.addTargetParams(snmpEngine, 'my-creds', 'usr-none-none', 'noAuthNoPriv')
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds'
+)
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, contextEngineId, contextName, varBinds):
+ initialVarBinds = varBinds
+ while varBinds:
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBindTable ) = yield trollius.From(
+ cmdgen.NextCommandGenerator().sendVarBinds(
+ snmpEngine,
+ target,
+ contextEngineId,
+ contextName,
+ varBinds
+ )
+ )
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBindRow in varBindTable:
+ for oid, val in varBindRow:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
+ errorIndication, varBinds = cmdgen.getNextVarBinds(
+ initialVarBinds, varBindRow
+ )
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+ loop.stop()
+
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ ( ('1.3.6.1.2.1.1', None), ('1.3.6.1.2.1.11', None) )
+ )
+)
+
+loop.close()
diff --git a/examples/v3arch/trollius/manager/cmdgen/set-v2c.py b/examples/v3arch/trollius/manager/cmdgen/set-v2c.py
new file mode 100644
index 0000000..9a2366e
--- /dev/null
+++ b/examples/v3arch/trollius/manager/cmdgen/set-v2c.py
@@ -0,0 +1,101 @@
+#
+# Command Generator
+#
+# Send SNMP SET request using the following options:
+#
+# * with SNMPv1, community 'public'
+# * using Trollius framework for network transport
+# * over IPv4/UDP
+# * to an Agent at 195.218.195.228:161
+# * for OIDs in tuple form and an integer and string-typed values
+#
+# This script performs similar to the following Net-SNMP command:
+#
+# $ snmpset -v1 -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my value' 1.3.6.1.2.1.1.9.1.4.1 t 123
+#
+# Requires Trollius framework!
+#
+from pysnmp.carrier.asyncio.dgram import udp
+from pysnmp.entity.rfc3413.asyncio import cmdgen
+from pysnmp.entity import engine, config
+from pysnmp.proto import rfc1902
+import trollius
+
+# Get the event loop for this thread
+loop = trollius.get_event_loop()
+
+# Create SNMP engine instance
+snmpEngine = engine.SnmpEngine()
+
+#
+# SNMPv2c 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', 0)
+
+#
+# Setup transport endpoint and bind it with security settings yielding
+# a target name
+#
+
+# UDP/IPv4
+config.addTransport(
+ snmpEngine,
+ udp.domainName,
+ udp.UdpTransport().openClientMode()
+)
+config.addTargetAddr(
+ snmpEngine, 'my-router',
+ udp.domainName, ('195.218.195.228', 161),
+ 'my-creds'
+)
+
+@trollius.coroutine
+def snmpOperation(snmpEngine, target, contextEngineId, contextName, varBinds):
+ ( snmpEngine,
+ errorIndication,
+ errorStatus,
+ errorIndex,
+ varBinds ) = yield trollius.From(
+ cmdgen.SetCommandGenerator().sendVarBinds(
+ snmpEngine,
+ target,
+ contextEngineId,
+ contextName,
+ varBinds
+ )
+ )
+
+ if errorIndication:
+ print(errorIndication)
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ else:
+ for oid, val in varBinds:
+ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
+ # This also terminates internal timer
+ config.delTransport(
+ snmpEngine,
+ udp.domainName
+ )
+
+loop.run_until_complete(
+ snmpOperation(
+ snmpEngine,
+ 'my-router',
+ None, '', # contextEngineId, contextName
+ [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')),
+ ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ]
+ )
+)
+
+loop.close()