etingof / snmpsim

SNMP Simulator
http://snmplabs.com/snmpsim/
BSD 2-Clause "Simplified" License
391 stars 120 forks source link

Unable to record from MIB #163

Open thomasbromehead opened 3 years ago

thomasbromehead commented 3 years ago

Hi Ilya, Thomas again... lol Been trying to create .snmprec files from MIB files using snmpsim-record-mibs but I'm getting the following error:

len(args.string_pool)
*** TypeError: object of type 'NoneType' has no len()

Tried with several MIBs including SNMPv2-MIB which is provided by default in /site-packages/snmpsim etc as well as a correctly formatted one from a DAHUA camera. Set a breakpoint with PDB and couldn't fathom why args.string_pool was NoneType, this is what I get when I call args.string_pool:

`(Pdb) args.string_pool
syntax = <DisplayString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 0, 255>, <ValueSizeConstraint object, consts 0, 255>>, encoding iso-8859-1>
hint = '# Scalar SNMPv2-MIB::sysDescr (type DisplayString)\r\n'
automatic_values = 5000

argsseems like a very weird object, I can call non-existing methods on it, even on args.string_pool: args.string_pool.asdadasda yields the same result as above...

This is the stacktrace: Traceback (most recent call last): File "/home/thomas/snmp-project/venv/bin/snmpsim-record-mibs", line 8, in <module> sys.exit(main()) File "/home/thomas/snmp-project/venv/lib/python3.8/site-packages/snmpsim/commands/mib2rec.py", line 472, in main val = get_value(node.syntax, hint) File "/home/thomas/snmp-project/venv/lib/python3.8/site-packages/snmpsim/commands/mib2rec.py", line 240, in get_value val = ' '.join([args.string_pool[random.randrange(0, len(args.string_pool))] File "/home/thomas/snmp-project/venv/lib/python3.8/site-packages/snmpsim/commands/mib2rec.py", line 240, in <listcomp> val = ' '.join([args.string_pool[random.randrange(0, len(args.string_pool))] TypeError: object of type 'NoneType' has no len()

wanglong001 commented 2 years ago

+1

image
BURNI80 commented 1 year ago

I have this error pls help image

lextm commented 1 year ago

snmpsim-lextudio version 1.0.3 contains the fix.

@BURNI80 You didn't compile AGENTX-MIB properly and mibdump --destination-directory=pysnmp_mibs ./AGENTX-MIB.txt is necessary to ensure you use the proper MIB document and compile it to .py. Then your snmpsim-record-mibs command might start to work.

You are welcome to read etingof/pysnmp/issues/429 to learn more.

BURNI80 commented 1 year ago

Thank you!

Why when I execute: snmpsim-record-mibs --mib-module=BRIDGE-MIB it ask me for values?

image

What do I have to write?

lextm commented 1 year ago

@BURNI80 if you read the actual MIB documents, you will see that dot1dBaseBridgeAddress is of the type MacAddress, which in turn is OCTET STRING (SIZE (6))

https://github.com/lextudio/sharpsnmppro-mib/blob/master/SNMPv2-TC.txt#L92

So when prompted to input value, you might use something like AAAAAA to meet the constraint.

Similarly you need the following (and more),

BURNI80 commented 1 year ago

@lextm

Thanks!!! Anyway to do it full automatic?

What command I need to compile AGENTX-MIB.py to a .snmprec file?

Any idea of why some mibs return 0 OIDs? image

And why is generated like this? I mean, with taht strange OIDs image image