SNMP Trap Listener

Simple Network Management Protocol (SNMP) is an “Internet-standard protocol for managing devices on IP networks. Devices that typically support SNMP include routers, switches, Servers, workstations, printers, modem tracks etc. It is used mostly in network management systems to monitor network-attached devices for conditions that warrant administrative attention.

SNMP exposes management data in the form of variables on the managed systems, which describe the system configuration. These variables can then be queried (and sometimes set) by managing applications.

The code attached in this article is .net based windows service to trap SNMP messages (SNMP v2) and process them accordingly. The service is capable to handle thousands of messages per second by using .net threads. One thread listens for incoming messages and pump them in message queue while another thread will extract and process the messages from another end of the queue.

The SNMP service in this article depends on windows “SNMP Trap Service”.

The source code also includes project “(SNMPSendTrap)” to send test SNMP v2 traps. 

Download source code for SNMP Listener (Vs2010)

7 thoughts on “SNMP Trap Listener

  1. Hello, we have compiled your installer, we are runing Windows Server 2008 and we have SNMP Trap and SNMP Service services started. When we try to Start the SnmpLib.Client SNMP Alerts it returns error 1075: The dependency service does not exist or has been marked for deletion.
     
    Any ideas on that?
     
    Thanks

    Like

  2. I have tested this on windows server 2003 but never get chance to test on windows 2008.You may need to check the dependencies of this new service services.msc>select service “SnmpLib.Client SNMP Alerts”> properties>dependencies this service depends on another windows service “SNMP Trap Service”. check that service SNMP Trap Service exists in windows 2008 and is running.Inside project SnmpLib.Client.Alerts > ServiceInstaller.cs> designer> select SNMPServiceInstaller > goto properties tab>property ServicesDependedOn> SNMP Trap Service.If windows 2008 has different name then change this value of this property.

    May be this thread helps you to solve the issue ; http://social.technet.microsoft.com/Forums/en/winserverManagement/thread/a10ae19b-c4d7-4372-bda0-c771c6d4cca3
    article http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/Q_23817059.html suggests that  After installing SNMP as a feature, the Trap option will not show up until after you logoff and back on again.

    Regards
    Rajnish Noonia

    Like

  3. Hi, great work!
    I need to understand how to integrate it in my .NET application.
    I need to receive traps from SNMP using this code.
    Can you explain me how or give me few examples please?
    Thanks
     
    Vincenzo

    Like

  4. You have to use library SnmpLib.WinSnmp and code from project SnmpLib.Client.Alerts.csproj.Class Traps listens for SNMP alerts and consumer_OnAlert is called whenever message is Dequeued from queue where as on trapHandler_OnMessage is triggered when any SNMP message is received which in turn format and enqueue the message in MessageQueue. MessageQueue is used in the code as you may have very high frequency of recieved messages as compare to messages processed on other end of queue.Download the code from this article and go through it, let me know if you have any queries.
    Regards
    Rajneesh

    Like

  5. Hi
    I am using your installer in Windows7 (64 bit). I am receiving the trap but not the values. I am always receiving zero as the value. For example, if linkDown trap is raised, when i debugged the code i could see that the “variable binding list” is containing names of the parameters but their values are always zero. Could you please suggest a solution.

    Like

Leave a comment