简体   繁体   中英

Collecting SNMP traps with pySNMP

Which is the more resource-friendly way to collect SNMP traps from a Cisco router via python:

  1. I could use a manager on a PC running a server, where the Cisco SNMP traps are sent to in case one occurs
  2. I could use an agent to send a GET/GETBULK request every x timeframe to check if any new traps have occurred

I am looking for a way to run the script so that it uses the least resources as possible. Not many traps will occur so the communication will be low mostly, but as soon as one does occur, the PC should know immediately.

Approach 1 is better from most perspectives.

  • It uses a little memory on the PC due to running a trap collecting daemon, but the footprint should be reasonably small since it only needs to listen for traps and decode them, not do any complex task.
  • Existing tools to receive traps include the net-snmp suite which allows you to just configure the daemon (ie you don't have to do any programming if you want to save some time).

Approach 2 has a couple of problems:

  1. No matter what polling interval you choose, you run the risk of missing an alarm that was only active on the router for a short time.
  2. Consumes CPU and network resources even if no faults are occurring.
  3. Depending on the MIB of the router, some types of event may not be stored in any table for later retrieval. For Cisco, I would not expect this problem, but you do need to study the MIB and make sure of this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM