SNMP::Trapinfo

Read and process an SNMP trap from Net-SNMP's snmptrapd
Download

SNMP::Trapinfo Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ton Voon
  • Publisher web site:
  • http://search.cpan.org/~tonvoon/

SNMP::Trapinfo Tags


SNMP::Trapinfo Description

Read and process an SNMP trap from Net-SNMP's snmptrapd SNMP::Trapinfo is a Perl module to read and process an SNMP trap from Net-SNMP's snmptrapd.SYNOPSIS use SNMP::Trapinfo; $trap = SNMP::Trapinfo->new(*STDIN); open F, ">> /tmp/trap.log"; print F $trap->packet; close F; if (! defined $trap->trapname) { die "No trapname in packet"; } elsif ($trap->trapname eq "IF-MIB::linkUp" or $trap->trapname eq "IF-MIB::linkDown") { # $mailer is a Mail::Mailer object, for example print $mailer "Received trap :", $trap->trapname, $/, "From host: ", $trap->hostname, $/, "Message: ", $trap->expand('Interface ${V5} received ${TRAPNAME}'), $/; } else { # not expected trap } # Do some complex evaluation of the packet my $result = $trap->eval('"${IF-MIB::ifType}" eq "ppp" && ${IF-MIB::ifIndex} < 5'); if ($result) { print "Got a trap for ppp where index is less than 5", $/; } elsif ($result == 0) { print "Packet not desired", $/; } else { print "Error evaluating: " . $trap->last_eval_string . "; result: $@", $/; }This module allows the user to get to the useful parts of an snmptrapd packet, as provided by the Net-SNMP software (http://www.net-snmp.org). You can evaluate the packet to match whatever rules you define and then take whatever action with the packet, such as sending an email, post an IM or submit it as a passive check to Nagios (http://www.nagios.org).Rules are defined as little perl snippets of code - run using the eval method. You use macros to pull out specific bits of the trap to then evaluate against. See the expand method for the macro definitions. Requirements: · Perl


SNMP::Trapinfo Related Software