Class: LogStash::Inputs::Snmptrap
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Snmptrap
- Defined in:
- lib/logstash/inputs/snmptrap.rb
Overview
Read snmp trap messages as events
Resulting ‘@message` looks like :
- source,ruby
-
#<SNMP::SNMPv1_Trap:0x6f1a7a4 @varbind_list=[#<SNMP::VarBind:0x2d7bcd8f @value=“teststring”, @name=>], @timestamp=#<SNMP::TimeTicks:0x1af47e9d @value=55>, @generic_trap=6, @enterprise=, @source_ip=“127.0.0.1”, @agent_addr=#<SNMP::IpAddress:0x29a4833e @value=“xC0xC1xC2xC3”>, @specific_trap=99>
Instance Method Summary collapse
-
#initialize(*args) ⇒ Snmptrap
constructor
A new instance of Snmptrap.
-
#register ⇒ Object
def initialize.
-
#run(output_queue) ⇒ Object
def register.
-
#stop ⇒ Object
def run.
Constructor Details
#initialize(*args) ⇒ Snmptrap
Returns a new instance of Snmptrap.
34 35 36 |
# File 'lib/logstash/inputs/snmptrap.rb', line 34 def initialize(*args) super(*args) end |
Instance Method Details
#register ⇒ Object
def initialize
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/logstash/inputs/snmptrap.rb', line 38 def register @snmptrap = nil if @yamlmibdir @logger.info("checking #{@yamlmibdir} for MIBs") Dir["#{@yamlmibdir}/*.yaml"].each do |yamlfile| mib_name = File.basename(yamlfile, ".*") @yaml_mibs ||= [] @yaml_mibs << mib_name end @logger.info("found MIBs: #{@yaml_mibs.join(',')}") if @yaml_mibs end end |
#run(output_queue) ⇒ Object
def register
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/logstash/inputs/snmptrap.rb', line 51 def run(output_queue) begin # snmp trap server snmptrap_listener(output_queue) rescue => e @logger.warn("SNMP Trap listener died", :exception => e, :backtrace => e.backtrace) Stud.stoppable_sleep(5) { stop? } retry if !stop? end # begin end |
#stop ⇒ Object
def run
62 63 64 65 |
# File 'lib/logstash/inputs/snmptrap.rb', line 62 def stop @snmptrap.exit unless @snmptrap.nil? @snmptrap = nil end |