Class: LogStash::Inputs::Ganglia
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Ganglia
- Defined in:
- lib/logstash/inputs/ganglia.rb
Overview
Read ganglia packets from the network via udp
Instance Method Summary collapse
-
#initialize(params) ⇒ Ganglia
constructor
A new instance of Ganglia.
- #parse_packet(packet) ⇒ Object
- #register ⇒ Object
- #run(output_queue) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(params) ⇒ Ganglia
Returns a new instance of Ganglia.
24 25 26 27 |
# File 'lib/logstash/inputs/ganglia.rb', line 24 def initialize(params) super BasicSocket.do_not_reverse_lookup = true end |
Instance Method Details
#parse_packet(packet) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/logstash/inputs/ganglia.rb', line 98 def parse_packet(packet) gmonpacket=GmonPacket.new(packet) if gmonpacket. # Extract the metadata from the packet =gmonpacket. # Add it to the global metadata of this connection [['name']]= # We are ignoring meta events for putting things on the queue @logger.debug("received a meta packet", ) return nil elsif gmonpacket.data? data=gmonpacket.parse_data() # Check if it was a valid data request return nil unless data props={ "program" => "ganglia", "log_host" => data["hostname"], "val" => data["val"] } %w{dmax tmax slope type units name}.each do |info| props[info] = [data["name"]][info] end return LogStash::Event.new(props) else # Skipping unknown packet types return nil end end |
#register ⇒ Object
30 31 |
# File 'lib/logstash/inputs/ganglia.rb', line 30 def register end |
#run(output_queue) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/logstash/inputs/ganglia.rb', line 34 def run(output_queue) begin udp_listener(output_queue) rescue => e if !stop? @logger.warn("ganglia udp listener died", :address => "#{@host}:#{@port}", :exception => e, :backtrace => e.backtrace) Stud.stoppable_sleep(5) { stop? } retry end end # begin end |
#stop ⇒ Object
85 86 87 |
# File 'lib/logstash/inputs/ganglia.rb', line 85 def stop close_udp end |