Permalink
Browse files

hook in the if-mib handler, add a bit of minimal processing code

  • Loading branch information...
1 parent 86fb6b6 commit 4b0e58eea2b3d843a5d6f0ec62d4e71910d6bf29 @jontow committed Oct 21, 2011
Showing with 30 additions and 0 deletions.
  1. +19 −0 handlers/snmp-trap-handler/if-mib-handler.rb
  2. +11 −0 handlers/snmp-trap-handler/snmp-trap-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
@@ -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.