├── snmpsim ├── commands │ └── __init__.py ├── reporting │ ├── __init__.py │ ├── formats │ │ ├── __init__.py │ │ ├── null.py │ │ └── base.py │ └── manager.py ├── __init__.py ├── grammar │ ├── __init__.py │ ├── mvc.py │ ├── abstract.py │ ├── sap.py │ ├── dump.py │ ├── snmprec.py │ └── walk.py ├── record │ ├── __init__.py │ ├── search │ │ ├── __init__.py │ │ ├── file.py │ │ └── database.py │ ├── sap.py │ ├── walk.py │ ├── mvc.py │ ├── abstract.py │ ├── dump.py │ └── snmprec.py ├── error.py ├── utils.py ├── confdir.py ├── endpoints.py ├── controller.py └── daemon.py ├── requirements.txt ├── data ├── variation │ ├── sql.snmprec │ ├── multiplex.snmprec │ ├── README.txt │ ├── error.snmprec │ ├── multiplex │ │ ├── README.txt │ │ ├── 00000.snmprec │ │ ├── 00001.snmprec │ │ ├── 00002.snmprec │ │ ├── 00003.snmprec │ │ ├── 00004.snmprec │ │ ├── 00005.snmprec │ │ ├── 00006.snmprec │ │ ├── 00007.snmprec │ │ ├── 00008.snmprec │ │ ├── 00009.snmprec │ │ └── 00010.snmprec │ ├── writecache.snmprec │ ├── delay.snmprec │ ├── subprocess.snmprec │ ├── notification.snmprec │ └── virtualtable.snmprec ├── recorded │ ├── linksys-system.snmprec │ ├── solaris-system.snmprec │ ├── udp-endpoint-table-walk.snmprec │ └── eaton-9PX-partial-walk.snmprec ├── public │ ├── README-v3.txt │ ├── README-v2c.txt │ ├── 1.3.6.1.6.1.1.0 │ │ ├── README-v3.txt │ │ ├── README-v2c.txt │ │ └── 127.0.0.1.snmprec │ ├── 1.3.6.1.2.1.100.1.2.0 │ │ ├── README-v2c.txt │ │ ├── README-v3.txt │ │ └── __1.snmprec │ └── 1.3.6.1.2.1.100.1.13.0.snmprec ├── README.txt ├── 1.3.6.1.6.1.1.0 │ ├── README-v3.txt │ ├── README-v2c.txt │ └── 127.0.0.1.snmprec ├── mib2dev │ ├── udp-mib.snmprec │ ├── tcp-mib.snmprec │ └── host-resources-mib.snmprec └── foreignformats │ └── README.txt ├── .github └── FUNDING.yml ├── THANKS.txt ├── docs ├── source │ ├── changelog.rst │ ├── .static │ │ └── favicon.ico │ ├── license.rst │ ├── documentation │ │ ├── contents.rst │ │ ├── managing-simulation-data.rst │ │ ├── tips-and-tricks.rst │ │ └── addressing-agents.rst │ ├── development.rst │ ├── contents.rst │ ├── quickstart.rst │ └── conf.py └── Makefile ├── setup.cfg ├── devel-requirements.txt ├── MANIFEST.in ├── TODO.txt ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── variation ├── subprocess.py ├── error.py ├── writecache.py ├── delay.py └── sql.py ├── runtests.sh ├── setup.py └── README.md /snmpsim/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snmpsim/reporting/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snmpsim/reporting/formats/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pysnmp>=4.4.12,<5.0.0 2 | -------------------------------------------------------------------------------- /data/variation/sql.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1|:sql|snmprec 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: http://snmplabs.com/sponsorship.html 2 | -------------------------------------------------------------------------------- /THANKS.txt: -------------------------------------------------------------------------------- 1 | Simon Crook 2 | Yateen Bhagat 3 | Florent Brisson 4 | Rich Brown 5 | -------------------------------------------------------------------------------- /snmpsim/__init__.py: -------------------------------------------------------------------------------- 1 | # http://www.python.org/dev/peps/pep-0396/ 2 | __version__ = '1.0.0' 3 | -------------------------------------------------------------------------------- /snmpsim/grammar/__init__.py: -------------------------------------------------------------------------------- 1 | # This file is necessary to make this directory a package. 2 | -------------------------------------------------------------------------------- /snmpsim/record/__init__.py: -------------------------------------------------------------------------------- 1 | # This file is necessary to make this directory a package. 2 | -------------------------------------------------------------------------------- /data/variation/multiplex.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.2|:multiplex|dir=variation/multiplex,period=10.0 2 | -------------------------------------------------------------------------------- /docs/source/changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Changelog 3 | ========= 4 | 5 | .. include:: ../../CHANGES.txt 6 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | 4 | [metadata] 5 | license_file = LICENSE.txt 6 | -------------------------------------------------------------------------------- /snmpsim/record/search/__init__.py: -------------------------------------------------------------------------------- 1 | # This file is necessary to make this directory a package. 2 | -------------------------------------------------------------------------------- /devel-requirements.txt: -------------------------------------------------------------------------------- 1 | Sphinx <= 1.6; python_version < '2.7' 2 | Sphinx > 1.6; python_version >= '2.7' 3 | -------------------------------------------------------------------------------- /docs/source/.static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etingof/snmpsim/HEAD/docs/source/.static/favicon.ico -------------------------------------------------------------------------------- /docs/source/license.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _license: 3 | 4 | License 5 | ======= 6 | 7 | .. include:: ../../LICENSE.txt 8 | -------------------------------------------------------------------------------- /data/variation/README.txt: -------------------------------------------------------------------------------- 1 | This directory is an example repository of .snmprec files that use 2 | various value variation modules for the purpose of building SNMP 3 | responses. 4 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.txt *.md *.sh 2 | recursive-include data *.snmprec *.snmpwalk *.sapwalk *.txt 3 | recursive-include variation *.py 4 | recursive-include docs *.rst *.py *.svg 5 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | * Improve .snmprec comments handling in the `datafile.py` tool. Possibly 2 | allow dropping/rearranging comments and empty lines 3 | * Refactor the documentation into Sphinx form -------------------------------------------------------------------------------- /data/recorded/linksys-system.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.1.1.0|4|BEFSX41 2 | 1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.3955.1.1 3 | 1.3.6.1.2.1.1.3.0|67|638239 4 | 1.3.6.1.2.1.1.4.0|4|Linksys 5 | 1.3.6.1.2.1.1.5.0|4|isp-gw 6 | 1.3.6.1.2.1.1.6.0|4|4, Petersburger strasse, Berlin, Germany 7 | 1.3.6.1.2.1.1.8.0|67|4 8 | -------------------------------------------------------------------------------- /data/variation/error.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.2.2.1.1.1|2:error|op=get,status=authorizationError,value=1 2 | 1.3.6.1.2.1.2.2.1.2.1|4:error|op=set,status=commitfailed,hexvalue=00127962f940 3 | 1.3.6.1.2.1.2.2.1.3.1|2:error|vlist=gt:2:wrongvalue,value=1 4 | 1.3.6.1.2.1.2.2.1.6.1|4:error|status=noaccess 5 | -------------------------------------------------------------------------------- /snmpsim/grammar/mvc.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | from snmpsim.grammar import dump 8 | 9 | 10 | class MvcGrammar(dump.DumpGrammar): 11 | pass 12 | -------------------------------------------------------------------------------- /data/recorded/solaris-system.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.1.1.0|4|Sun SNMP Agent, Sun-Blade-100 2 | 1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.42.2.1.1 3 | 1.3.6.1.2.1.1.3.0|67|624162552 4 | 1.3.6.1.2.1.1.4.0|4|System administrator 5 | 1.3.6.1.2.1.1.5.0|4|oss 6 | 1.3.6.1.2.1.1.6.0|4|System administrators office 7 | 1.3.6.1.2.1.1.8.0|67|72 8 | -------------------------------------------------------------------------------- /data/variation/multiplex/README.txt: -------------------------------------------------------------------------------- 1 | This directory is an example repository of .snmprec files that can 2 | be used by the "multiplex" variation module for the purpose of building SNMP 3 | responses choosing one of these snmprec files in a time-dependent fashion. 4 | 5 | Such .snmprec files can be created automatically by the snmprec.py tool. 6 | -------------------------------------------------------------------------------- /data/public/README-v3.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is NOT running 2 | in --v2c-arch mode. 3 | 4 | This is a ContextName specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | ContextName in request AND Manager's source address matches the .snmprec 8 | filename. 9 | -------------------------------------------------------------------------------- /data/public/README-v2c.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is running 2 | in --v2c-arch mode. 3 | 4 | This is a community name specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | community name in request AND Manager's source address matches the .snmprec 8 | filename. 9 | -------------------------------------------------------------------------------- /data/README.txt: -------------------------------------------------------------------------------- 1 | This directory is a repository of .snmprec files -- those are picked by 2 | Simulator using community name (SNMPv1/v2c) or context name (SNMPv3) 3 | as a selector. The contents of .snmprec files is used by Simulator 4 | for building responses. 5 | 6 | Simulator will report .snmprec files it finds on startup along with 7 | community/context names to be used to address them. 8 | -------------------------------------------------------------------------------- /snmpsim/record/sap.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | from snmpsim.grammar import sap 8 | from snmpsim.record import dump 9 | 10 | 11 | class SapRecord(dump.DumpRecord): 12 | grammar = sap.SapGrammar() 13 | ext = 'sapwalk' 14 | -------------------------------------------------------------------------------- /snmpsim/record/walk.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | from snmpsim.grammar import walk 8 | from snmpsim.record import dump 9 | 10 | 11 | class WalkRecord(dump.DumpRecord): 12 | grammar = walk.WalkGrammar() 13 | ext = 'snmpwalk' 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Python stuff 2 | *.pyc 3 | __pycache__ 4 | 5 | # vim swapfiles 6 | *.sw? 7 | 8 | # python packaging 9 | MANIFEST 10 | dist/ 11 | build/ 12 | *.egg-info/ 13 | 14 | # PyCharm stuff 15 | .idea/ 16 | 17 | # Sphinx template 18 | docs/source/.templates/layout.html 19 | 20 | # Eclipse stuff 21 | .project 22 | .pydevproject 23 | 24 | # Virtual envs 25 | venv* 26 | *.komodoproject 27 | -------------------------------------------------------------------------------- /data/1.3.6.1.6.1.1.0/README-v3.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case when Simulator is NOT running 2 | in --v2c-arch mode. 3 | 4 | This is a ContextName AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | ContextName in request is empty AND transport domain AND source address 8 | being used matches the .snmprec filename. 9 | -------------------------------------------------------------------------------- /data/1.3.6.1.6.1.1.0/README-v2c.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case when Simulator is running 2 | in --v2c-arch mode. 3 | 4 | This is a community name AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | community name in request is empty AND transport domain AND source address 8 | being used matches the .snmprec filename. 9 | -------------------------------------------------------------------------------- /data/public/1.3.6.1.6.1.1.0/README-v3.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is NOT running 2 | in --v2c-arch mode. 3 | 4 | This is a ContextName AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | ContextName in request AND transport domain AND source address being 8 | used matches the .snmprec filename. 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | cache: pip 3 | matrix: 4 | include: 5 | - python: '2.7' 6 | - python: '3.5' 7 | - python: '3.6' 8 | - python: '3.7' 9 | - python: '3.8' 10 | - python: 'nightly' 11 | - python: 'pypy' 12 | - python: 'pypy3' 13 | install: 14 | - pip install -r requirements.txt -r devel-requirements.txt 15 | - pip install -e . 16 | script: 17 | - bash runtests.sh 18 | -------------------------------------------------------------------------------- /data/public/1.3.6.1.6.1.1.0/README-v2c.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is running 2 | in --v2c-arch mode. 3 | 4 | This is a community name AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | community name in request AND transport domain AND source address being 8 | used matches the .snmprec filename. 9 | -------------------------------------------------------------------------------- /snmpsim/record/mvc.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | from snmpsim.grammar import mvc 8 | from snmpsim.record import dump 9 | 10 | 11 | class MvcRecord(dump.DumpRecord): 12 | grammar = mvc.MvcGrammar() 13 | ext = 'MVC' # an alias to .dump 14 | -------------------------------------------------------------------------------- /snmpsim/reporting/formats/null.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | # SNMP Agent Simulator 8 | # 9 | from snmpsim.reporting.formats import base 10 | 11 | 12 | class NullReporter(base.BaseReporter): 13 | """Maintain activity metrics. 14 | """ 15 | -------------------------------------------------------------------------------- /data/variation/writecache.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.1.1.0|4:writecache|hexvalue=49276d206120737472696e672c20706c65617365206d6f64696679206d6520616e64204927642072656d656d626572207468617421 2 | 1.3.6.1.2.1.1.3.0|2:writecache|value=42,vlist=lt:40:wrongvalue:gt:50:noaccess 3 | # write-only OID, can be configured readable via other .snmprec 4 | 1.3.6.1.2.1.2.2.1.5.1|66:writecache|value=100000000,op=get,status=noaccess 5 | # read-only OID, can be configured writable via other .snmprec 6 | 1.3.6.1.2.1.2.2.1.5.2|66:writecache|value=100000000,op=set,status=noaccess 7 | -------------------------------------------------------------------------------- /data/variation/delay.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.2.2.1.1.1|2:delay|value=1 2 | 1.3.6.1.2.1.2.2.1.2.1|4:delay|value=eth0 3 | 1.3.6.1.2.1.2.2.1.3.1|2:delay|value=6,wait=100,deviation=200 4 | 1.3.6.1.2.1.2.2.1.5.1|66:delay|value=100000000 5 | 1.3.6.1.2.1.2.2.1.6.1|4:delay|hexvalue=00127962f940,wait=800 6 | 1.3.6.1.2.1.2.2.1.7.1|2:delay|wait=1,value=0 7 | 1.3.6.1.2.1.2.2.1.8.1|2:delay|vlist=eq:0:100:eq:1:1000,value=1 8 | 1.3.6.1.2.1.2.2.1.9.1|67:delay|vlist=lt:100:1:gt:300:1000000,value=150 9 | 1.3.6.1.2.1.2.2.1.10.1|65:delay|tlist=gt:1364860800:1000000,value=12345 10 | -------------------------------------------------------------------------------- /data/public/1.3.6.1.2.1.100.1.2.0/README-v2c.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is running 2 | in --v2c-arch mode. 3 | 4 | This is a community name AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | community name in request AND transport domain AND source address being 8 | used matches the .snmprec filename. 9 | 10 | Since this is a IPv6 transport domain, .snmprec files take shape of 11 | an IPv6 IP address with semicolons (:) replaces with underscores (_). 12 | -------------------------------------------------------------------------------- /data/public/1.3.6.1.2.1.100.1.2.0/README-v3.txt: -------------------------------------------------------------------------------- 1 | This directory serves as a special case only when Simulator is NOT running 2 | in --v2c-arch mode. 3 | 4 | This is a ContextName AND transport domain specific directory. 5 | 6 | The .snmprec files in this directory would be used by Simulator whenever 7 | ContextName in request AND transport domain AND source address being 8 | used matches the .snmprec filename. 9 | 10 | Since this is a IPv6 transport domain, .snmprec files take shape of 11 | an IPv6 IP address with semicolons (:) replaces with underscores (_). 12 | -------------------------------------------------------------------------------- /data/variation/subprocess.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.1.1.0|4:subprocess|echo SNMP info: transportDomain @TRANSPORTDOMAIN@, transportAddress @TRANSPORTADDRESS@, securityModel @SECURITYMODEL@, securityName @SECURITYNAME@, securityLevel @SECURITYLEVEL@, contextName @CONTEXTNAME@\r\nUsing data file @DATAFILE@\r\nReceived request for @ORIGOID@, matched @OID@, received tag/value "@ORIGTAG@"/"@ORIGVALUE@", would return value tagged @TAG@, request write mode flag is @SETFLAG@, next flag is @NEXTFLAG@, subtree flag is @SUBTREEFLAG@ 2 | 1.3.6.1.2.1.1.3.0|2:subprocess|echo 123455 3 | 1.3.6.1.2.1.1.5.0|4|new system name 4 | 1.3.6.1.2.1.25.1.2.1|4x:subprocess|echo -n 07e30307001b01152b0000 5 | -------------------------------------------------------------------------------- /snmpsim/reporting/formats/base.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | # SNMP Agent Simulator 8 | # 9 | 10 | 11 | class BaseReporter(object): 12 | """Maintain activity metrics. 13 | """ 14 | def update_metrics(self, **kwargs): 15 | """Process activity update. 16 | """ 17 | 18 | def flush(self): 19 | """Dump accumulated metrics into a JSON file. 20 | 21 | Reset all counters upon success. 22 | """ 23 | 24 | def __str__(self): 25 | return self.__class__.__name__ -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = SNMPSimulator 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /snmpsim/grammar/abstract.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | from snmpsim import error 8 | 9 | 10 | class AbstractGrammar(object): 11 | def parse(self, line): 12 | raise error.SnmpsimError( 13 | 'Method not implemented at %s' % self.__class__.__name__) 14 | 15 | def build(self, oid, tag, val): 16 | raise error.SnmpsimError( 17 | 'Method not implemented at %s' % self.__class__.__name__) 18 | 19 | def get_tag_by_type(self, val): 20 | raise error.SnmpsimError( 21 | 'Method not implemented at %s' % self.__class__.__name__) 22 | -------------------------------------------------------------------------------- /data/variation/notification.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.1.1.0|4:notification|op=get,version=1,community=public,proto=udp,host=127.0.0.1,port=162,ntftype=trap,trapoid=1.3.6.1.4.1.20408.4.1.1.2.0.432,uptime=12345,agentaddress=127.0.0.1,enterprise=1.3.6.1.4.1.20408.4.1.1.2,varbinds=1.3.6.1.2.1.1.1.0:s:snmpsim agent:1.3.6.1.2.1.1.3.0:i:42,value=SNMPv1 trap sender 2 | 1.3.6.1.2.1.1.2.0|6:notification|op=set,vlist=eq:1.3.6.1.1.2,version=2c,community=public,bindaddr=127.0.0.1,host=127.0.0.1,ntftype=trap,trapoid=1.3.6.1.6.3.1.1.5.1,varbinds=1.3.6.1.2.1.1.1.0:s:snmpsim agent:1.3.6.1.2.1.1.3.0:i:42,value=1.3.6.1.1.1 3 | 1.3.6.1.2.1.1.3.0|67:notification|version=3,user=usr-md5-des,authkey=authkey1,privkey=privkey1,host=127.0.0.1,ntftype=inform,trapoid=1.3.6.1.6.3.1.1.5.2,value=123456 4 | -------------------------------------------------------------------------------- /snmpsim/error.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | 8 | 9 | class SnmpsimError(Exception): 10 | pass 11 | 12 | 13 | class NoDataNotification(SnmpsimError): 14 | pass 15 | 16 | 17 | class MoreDataNotification(SnmpsimError): 18 | def __init__(self, **kwargs): 19 | self.__kwargs = kwargs 20 | 21 | def __contains__(self, key): 22 | return key in self.__kwargs 23 | 24 | def __getitem__(self, key): 25 | return self.__kwargs[key] 26 | 27 | def get(self, key): 28 | return self.__kwargs.get(key) 29 | 30 | def keys(self): 31 | return self.__kwargs.keys() 32 | -------------------------------------------------------------------------------- /docs/source/documentation/contents.rst: -------------------------------------------------------------------------------- 1 | 2 | Documentation 3 | ------------- 4 | 5 | SNMP Simulator suite contains a handful of command-line tools implementing 6 | different stages of simulation work flow. 7 | 8 | In general, SNMP simulator user might want to prepare some SNMP simulation 9 | data in one way or the other, then run SNMP agent simulator tool over 10 | simulation data to represent SNMP agents on the network. Then user software 11 | might query those simulated agents to test its own behavior. 12 | 13 | .. toctree:: 14 | :maxdepth: 2 15 | 16 | command-line-options 17 | simulating-agents 18 | managing-simulation-data 19 | addressing-agents 20 | simulation-with-variation-modules 21 | building-simulation-data 22 | recording-with-variation-modules 23 | tips-and-tricks 24 | 25 | -------------------------------------------------------------------------------- /data/mib2dev/udp-mib.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.7.1.0|65|2227133058 2 | 1.3.6.1.2.1.7.2.0|65|2937178585 3 | 1.3.6.1.2.1.7.3.0|65|1729892225 4 | 1.3.6.1.2.1.7.4.0|65|3771766783 5 | 1.3.6.1.2.1.7.5.1.1.8.185.250.193.1|64x|9cd2059e 6 | 1.3.6.1.2.1.7.5.1.2.8.185.250.193.1|2|4 7 | 1.3.6.1.2.1.7.7.1.1.2.0.100.3.0.123.990022909|2|3 8 | 1.3.6.1.2.1.7.7.1.2.2.0.100.3.0.123.990022909|4|whisky au juge blond qui 9 | 1.3.6.1.2.1.7.7.1.3.2.0.100.3.0.123.990022909|66|422 10 | 1.3.6.1.2.1.7.7.1.4.2.0.100.3.0.123.990022909|2|1 11 | 1.3.6.1.2.1.7.7.1.5.2.0.100.3.0.123.990022909|4| 12 | 1.3.6.1.2.1.7.7.1.6.2.0.100.3.0.123.990022909|66|322 13 | 1.3.6.1.2.1.7.7.1.7.2.0.100.3.0.123.990022909|66|942640476 14 | 1.3.6.1.2.1.7.7.1.8.2.0.100.3.0.123.990022909|66|543812974 15 | 1.3.6.1.2.1.7.8.0|70|3896031866066683889 16 | 1.3.6.1.2.1.7.9.0|70|3518073560493506800 17 | -------------------------------------------------------------------------------- /data/foreignformats/README.txt: -------------------------------------------------------------------------------- 1 | This directory holds examples of Managed Objects snapshots recorded by 2 | other popular SNMP tools and stored in their own proprietary formats. 3 | 4 | Snmpsim currently supports the following foreign data file formats: 5 | 6 | * Net-SNMP's snmpwalk output (with -ObentU options) 7 | * SimpleAgentPro sapwalk/sapwalk2 8 | 9 | Please note that foreign formats do not allow for snmpsim's advanced features 10 | such as dynamic value variation or triggering events to external systems. 11 | If you possess a snapshot in a foreign format and wish to use advanced 12 | snmpsim's features, do "snmprec" against "snmpsim" serving foreign data file 13 | to aqcuire a snapshot in snmpsim's native .snmprec form. 14 | 15 | Since snmpsim does not tolerate comments in data files, make sure to remove 16 | ones from .sapwalk prior to feeding them to snmpsim. 17 | -------------------------------------------------------------------------------- /data/public/1.3.6.1.2.1.100.1.2.0/__1.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.6.16.1.1.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|4|7327244883929832 2 | 1.3.6.1.2.1.6.16.1.2.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|2|89 3 | 1.3.6.1.2.1.6.16.1.3.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|4|7327244883924545 4 | 1.3.6.1.2.1.6.16.1.4.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|2|87 5 | 1.3.6.1.2.1.6.16.1.5.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|2|402562730 6 | 1.3.6.1.2.1.6.16.1.6.55.51.50.55.50.52.52.56.56.51.57.50.52.55.51.50.434.55.51.50.55.50.52.52.56.56.51.57.50.52.55.52.51.64.1853700339|2|10 7 | -------------------------------------------------------------------------------- /snmpsim/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of snmpsim software. 3 | # 4 | # Copyright (c) 2010-2019, Ilya Etingof 5 | # License: http://snmplabs.com/snmpsim/license.html 6 | # 7 | import importlib 8 | import sys 9 | 10 | import pysnmp 11 | import pysmi 12 | import pyasn1 13 | import snmpsim 14 | 15 | TITLE = """\ 16 | SNMP Simulator version %s, written by Ilya Etingof 17 | Using foundation libraries: pysmi %s, pysnmp %s, pyasn1 %s. 18 | Python interpreter: %s 19 | Documentation and support at http://snmplabs.com/snmpsim 20 | """ % (snmpsim.__version__, pysmi.__version__, pysnmp.__version__, 21 | pyasn1.__version__, sys.version) 22 | 23 | 24 | def try_load(module, package=None): 25 | """Try to load given module, return `None` on failure""" 26 | try: 27 | return importlib.import_module(module, package) 28 | 29 | except ImportError: 30 | return 31 | 32 | 33 | def split(val, sep): 34 | for x in (3, 2, 1): 35 | if val.find(sep * x) != -1: 36 | return val.split(sep * x) 37 | 38 | return [val] 39 | -------------------------------------------------------------------------------- /data/variation/virtualtable.snmprec: -------------------------------------------------------------------------------- 1 | 1.3.6.1.2.1.2.2.1.1.1|2|1 2 | 1.3.6.1.2.1.2.2.1.2.1|4|eth0 3 | 1.3.6.1.2.1.2.2.1.3.1|2|6 4 | 1.3.6.1.2.1.2.2.1.4.1|2|1500 5 | 1.3.6.1.2.1.2.2.1.5.1|66|100000000 6 | 1.3.6.1.2.1.2.2.1.6.1|4x|00127962f940 7 | 1.3.6.1.2.1.2.2.1.7.1|2|1 8 | 1.3.6.1.2.1.2.2.1.8.1|2|1 9 | 1.3.6.1.2.1.2.2.1.9.1|67:numeric|rate=100,initial=100000000 10 | 1.3.6.1.2.1.2.2.1.10.1|65:numeric|rate=200,deviation=10,cumulative=1 11 | 1.3.6.1.2.1.2.2.1.11.1|65:numeric|rate=18,initial=1,cumulative=1 12 | 1.3.6.1.2.1.2.2.1.12.1|65:numeric|rate=2,cumulative=1 13 | 1.3.6.1.2.1.2.2.1.13.1|65:numeric|scale=0.6,offset=1,deviation=1,function=cos,cumulative=1 14 | 1.3.6.1.2.1.2.2.1.14.1|65:numeric|scale=0.4,offset=1,deviation=1,function=sin,cumulative=1 15 | 1.3.6.1.2.1.2.2.1.15.1|65:numeric|rate=0.1,deviation=2,cumulative=1 16 | 1.3.6.1.2.1.2.2.1.16.1|65:numeric|rate=100,deviation=5,cumulative=1 17 | 1.3.6.1.2.1.2.2.1.17.1|65:numeric|rate=9,initial=1,cumulative=1 18 | 1.3.6.1.2.1.2.2.1.18.1|65:numeric|rate=1,cumulative=1 19 | 1.3.6.1.2.1.2.2.1.19.1|65:numeric|scale=0.6,offset=1,deviation=1,function=sin,cumulative=1 20 | 1.3.6.1.2.1.2.2.1.20.1|65:numeric|scale=0.4,offset=1,deviation=1,function=cos,cumulative=1 21 | 1.3.6.1.2.1.2.2.1.21.1|66:numeric|function=pow%