Send emails on receiving SNMP TrapsThis article explains how you can send an email when SNMP traps are received by Unbrowse SNMP. We use Unbrowse Scripting and the Ruby programming language for this purpose. Here's what we are going to do:
About the high performance trap server A common misconception about the Unbrowse Scripting interface is that it is slow. Lets clear that up. The trap receiver is a really fast C++ server capable of processing bursts of thousands of traps per second without dropping anything. The server keeps the traps and the script is only used to drain the server. This combination provides the optimum mix of performance and flexibility. For example : You can write a Ruby or VBScript program to do whatever custom housekeeping work you want without the fear of losing traps due to the script execution speed. If tasks like sending emails or inserting into a database were baked into the C++ server - it would be severely restrictive. Running the serverStep 1 : Download the latest version of Unbrowse SNMP and install itStep 2 : Get the script and save it in a directory of your choice
Step 3 : Download and install the Ruby one click installerGet it from http://rubyforge.org/projects/rubyinstaller/ (Get the latest version) Step 4 : After the ruby installer is done. Type the following commandgem install tmail This will install the TMail library which we use to send out SMTP emails. Step 5 : Edit the email settingsEnter your password details, to and from addresses, etc Open the script you downloaded in Step 2 and locate the following section # Change this to your environment # Add from,to,and cc # Max Mail frequency seconds All parameters are self explanatory. The mail_frequency_settings is the minimum amount of time between emails. The default is 30, which means the script will not send emails faster than this rate. If there are many SNMP Traps in this interval, the script will combine them into a single email.
Step 6 : Run the scriptOpen a command prompt and type the following ruby t2email.rb
Thats it ! Now you have a high performance SNMP server that sends emails. You can adapt the script to perform more involved work like translating the trap OIDs to SNMP OID Names using the scripting interface If you have any trouble getting this to work please post a message in our forum or send an email across to info at
|