Class: LogStash::Inputs::WMI
- Defined in:
- lib/logstash/inputs/wmi.rb
Overview
Collect data from WMI query
This is useful for collecting performance metrics and other data which is accessible via WMI on a Windows host
Example:
input {
wmi {
query => "select * from Win32_Process"
interval => 10
}
wmi {
query => "select PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor where name = '_Total'"
}
}
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/logstash/inputs/wmi.rb', line 33 def register @host = Socket.gethostname @logger.info("Registering wmi input", :query => @query) if RUBY_PLATFORM == "java" # make use of the same fix used for the eventlog input require "logstash/inputs/eventlog/racob_fix" require "jruby-win32ole" else require "win32ole" end end |
#run(queue) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/logstash/inputs/wmi.rb', line 48 def run(queue) @wmi = WIN32OLE.connect("winmgmts://") begin @logger.debug("Executing WMI query '#{@query}'") loop do @wmi.ExecQuery(@query).each do |wmiobj| # create a single event for all properties in the collection event = LogStash::Event.new event["host"] = @host decorate(event) wmiobj.Properties_.each do |prop| event[prop.name] = prop.value end queue << event end sleep @interval end # loop rescue Exception => ex @logger.error("WMI query error: #{ex}\n#{ex.backtrace}") sleep @interval retry end # begin/rescue end |