2

I need to ask 4000 hosts with simple snmpget query. I used netsnmp with threads and pynetsnmp with twisted and it works pretty fast (less 1 minute). I tried to use pysnmp with AsyncCommandGenerator and pysnmp with twisted (i've fixed that example with one instance of SnmpEngine)

and it took more than 10 minutes. Am i doing something wrong? Should the pysnmp be so slow?

Community
  • 1
  • 1
kalombo
  • 861
  • 1
  • 9
  • 31

1 Answers1

3

EDIT: pastebin example added

Please post your current version of the script.

In the code you refer to you may try to optimize out some of:

addV1System()
addTargetParams()
addSocketTransport()

calls whenever you call them more then once with the same arguments.

In other words, if among the 4000 hosts you query the only difference is host's address, then the only call you need to repeat is addTargetAddr(). Otherwise you re-configure SNMP engine on every request.

To better estimate pysnmp performance you consider running the following example configured with the 4000 hosts you with to query.

If you would never need SNMPv3 and performance is your priority, you may wish to employ pysnmp's low-level API.

But in any case you would never come close to C implementation in terms of performance. ;-)

Pooh
  • 276
  • 1
  • 3
  • Could you post simple code here? It should be async (twisted would be better) and ask 4000 hosts with get query. You can use any oid that you like. The version is v2c. I'll try it and notice results. – kalombo Oct 22 '13 at 11:15
  • 1
    See http://pastebin.com/wMjvmxLV . On my system it completes 1000 queries in 5 seconds. My local agent does not accept more queries so I can't try 4000 hosts. So configure your 4000 hosts into the script above and give it a try. – Pooh Oct 23 '13 at 07:15
  • It completed 4000 queries in 30 seconds. Also i've tried pysnmp with twisted. It took 55 seconds. There is a [code](http://pastebin.com/YaD8dZLm). Why twisted time is more than AsynCommandGenerator time? Is it right code? – kalombo Oct 23 '13 at 10:24
  • 1
    Your code looks good. I suppose Twisted is itself is a bit "heavier" than asyncore. At least the performance difference pysnmp vs net-snmp is not that huge now, right? – Pooh Oct 24 '13 at 21:25
  • Yes, it looks it is. Actually, i need to get a table for 6 oids like [here](https://github.com/zenoss/pynetsnmp/blob/master/test/tableget.py) I'll try to do it later. Thx for help. Btw, it takes 23 seconds with pynetsnmp and twisted for 4.5k hosts. – kalombo Oct 25 '13 at 05:51
  • So [here](http://pastebin.com/Ug7bPgB8) is the code. It works about 10 minutes against 40 seconds of pynetsnmp with twisted or 80 seconds of netsnmp with threads. – kalombo Oct 25 '13 at 09:03