Skip to content

Commit

Permalink
hook in the if-mib handler, add a bit of minimal processing code
Browse files Browse the repository at this point in the history
  • Loading branch information
jontow committed Oct 21, 2011
1 parent 86fb6b6 commit 4b0e58e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions handlers/snmp-trap-handler/if-mib-handler.rb
@@ -0,0 +1,19 @@
#
# 2011-10-21 -- jontow@zenbsd.net
#
# Parsing and handling for IF-MIB related SNMP traps
#

module IFMIB
def self.linkdown(evinfo)
if evinfo =~ /IF-MIB::ifName\.[0-9]+\ ::\ (.*)/
return "linkDown: #{$1}"
end
end

def self.linkup(evinfo)
if evinfo =~ /IF-MIB::ifName\.[0-9]+\ ::\ (.*)/
return "linkUp: #{$1}"
end
end
end
11 changes: 11 additions & 0 deletions handlers/snmp-trap-handler/snmp-trap-handler.rb
Expand Up @@ -12,5 +12,16 @@ class SNMPTrapHandler
def initialize(event)
puts "TRAP -- #{event['name']}:"
puts event['info']

case event['name']
when "IF-MIB::linkDown"
alarm = IFMIB.linkdown(event['info'])
p alarm
when "IF-MIB::linkUp"
alarm = IFMIB.linkup(event['info'])
p alarm
else
puts "Unhandled IF-MIB trap: #{event['name']}"
end
end
end

0 comments on commit 4b0e58e

Please sign in to comment.