etingof / snmpsim

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

Not dumping to .snmprec and not populating SQL table #162

Open thomasbromehead opened 3 years ago

thomasbromehead commented 3 years ago

Hi Ilya,

Been trying really hard to dump recordings using the sql and redis variation modules, to no avail. Strangely enough I see only ONE record being inserted in my Postgres DB, whether using --use-getbulk or not, even when adding --start-object and --stop-object flags or -getbulk-repetitions. It is not a DB connection problem as the printer table is created and with the right schema. A regular snmpsim-record-commands with no variation modules gives me a correctly populated .snmprec file. The logs say there are no errors however the walk is extremely quick and as you can see I have a nice 0 oids dumped. Here's the command I am using (recording against my local printer):

snmpsim-record-commands --agent-udpv4-endpoint=192.168.8.107 --start-object=1.3.6.1.2.1.1 --stop-object=1.3.6.1.2.1.9 --output-file=printer.snmprec --variation-module=sql --variation-module-options=dbtype:psycopg2,database:snmpsim,user:snmpsim,password:snmpsim,dbtable:printer --log-level=error --use-getbulk --getbulk-repetitions=30

Expected

Actual

Regards from France, thanks for the terrific work on this tool ;) :1st_place_medal:

Here's the output:

Scanning "/home/thomas/.snmpsim/variation" directory for variation modules... 
Directory "/home/thomas/.snmpsim/variation" does not exist 
Scanning "/home/thomas/snmp-project/venv/snmpsim/variation" directory for variation modules... 
Variation module "sql" loaded 
SNMP version 2c, Community name: public 
Querying UDP/IPv4 agent at 192.168.8.107:161 
Agent response timeout: 3 secs, retries: 3 
Initializing variation module... 
Variation module "sql" initialization OK 
Sending initial GETBULK request for 1.3.6.1.2.1.1 (stop at 1.3.6.1.2.1.9).... 
Shutting down variation module sql... 
Variation module sql shutdown OK 
OIDs dumped: 0, elapsed: 0.03 sec, rate: 0.00 OIDs/sec, errors: 0
triremerufus commented 3 years ago

FWIW, this appears to be a silent error in the variation/sql .record method - it's looking for a start oid entry in a dict, and the relevant entry appears to actually be called "args.start_object". Not yet clear whence the difference.

approx variation/sql.py:250