Class: LogStash::Inputs::HPArcSightAppliancePoll

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/hpaapoll.rb

Overview

Read events over HTTP requests.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ HPArcSightAppliancePoll

Returns a new instance of HPArcSightAppliancePoll.



24
25
26
# File 'lib/logstash/inputs/hpaapoll.rb', line 24

def initialize(*args)
  super(*args)
end

Instance Method Details

#registerObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/logstash/inputs/hpaapoll.rb', line 29

def register
  require 'snmp'
  require 'json'

  @@oid = '1.3.6.1.4.1.11937.3.1'
  @manager = SNMP::Manager.new(:host => @host, :port => @port, :community => @community, :mib_dir => @mibdir)
  @logger.info("Manager", :manager => @manager)
  @names = [ nil, nil, 'name', 'location', 'type', 'value', 'status']

end

#run(queue) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/logstash/inputs/hpaapoll.rb', line 41

def run(queue)
  while true
    begin
      sensors = Hash.new()

      @manager.walk(@@oid) { |vb| 
        @logger.info(:VarBind => vb)
        if vb.name[-2] == 1
          sensors[vb.name[-1]] = { 'index' => vb.value }
        else
          sensors[vb.name[-1]][@names[vb.name[-2]]] = vb.value
        end
      }

      sensors.each do |index, sensor|
        event = LogStash::Event.new()
        decorate(event)
        event['host'] = @host
        sensor['host'] = @host
        sensor['community'] = @community
        sensor['port'] = @port
        event['sensor'] = sensor
        event['message'] = sensor.to_s
        queue << event
      end
    rescue SocketError => e
      event = LogStash::Event.new()
      decorate(event)
      event['host'] = @host
      event[@tag_on_exception] = e unless @tag_on_exception.empty?
      queue << event
    end
    sleep(@interval)
  end # while true
end