Class: LogStash::Inputs::Perfmon

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

Overview

filter

    grok {
      match => {
        "message" => "%{DATESTAMP:Occurred,%NUMBER:PrivilegedTime:float,%NUMBER:ProcessorTime:float,%NUMBER:UserTime:float"
    }
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countersObject (readonly)

Returns the value of attribute counters.



30
31
32
# File 'lib/logstash/inputs/perfmon.rb', line 30

def counters
  @counters
end

#hostObject (readonly)

Returns the value of attribute host.



30
31
32
# File 'lib/logstash/inputs/perfmon.rb', line 30

def host
  @host
end

#intervalObject (readonly)

Returns the value of attribute interval.



30
31
32
# File 'lib/logstash/inputs/perfmon.rb', line 30

def interval
  @interval
end

Instance Method Details

#registerObject

Registers the plugin with logstash



61
62
63
64
# File 'lib/logstash/inputs/perfmon.rb', line 61

def register
  @typeperf = TypeperfWrapper.new(PerfmonProcGetter.new, @interval)
  @counters.each { |counter| @typeperf.add_counter(counter) }
end

#run(queue) ⇒ Object

Runs the perf monitor and monitors its output

queue

The queue to add new events to



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/logstash/inputs/perfmon.rb', line 68

def run(queue)
  @typeperf.start_monitor
	
  @logger.debug("Started perfmon monitor")

  while @typeperf.alive?
    data = @typeperf.get_next

    @codec.decode(data) do |event|
      decorate(event)

      event['host'] = @host

      queue << event
      @logger.debug("Added event to queue: #{event}")
    end
  end
end

#stopObject

Manual way to stop the plugin



96
97
98
99
100
# File 'lib/logstash/inputs/perfmon.rb', line 96

def stop
  @logger.debug("Calling stop on logstash-input-perfmon")
  @typeperf.stop_monitor
  @logger.debug("Stopped the perfmon monitor")
end

#teardownObject

Cleans up any resources, called when Ctrl+C used



88
89
90
91
92
93
# File 'lib/logstash/inputs/perfmon.rb', line 88

def teardown
  @logger.debug("Calling teardown on logstash-input-perfmon")
  @typeperf.stop_monitor
  @logger.debug("Stopped the perfmon monitor")
  finished
end