logstash-input-perfmon 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/README.md +76 -0
- data/Rakefile +1 -0
- data/lib/logstash/inputs/perfmon.rb +80 -0
- data/lib/logstash/inputs/perfmon_proc_getter.rb +72 -0
- data/lib/logstash/inputs/typeperf_wrapper.rb +62 -0
- data/logstash-input-perfmon.gemspec +27 -0
- data/spec/inputs/perfmon_proc_getter_spec.rb +25 -0
- data/spec/inputs/perfmon_spec.rb +45 -0
- data/spec/inputs/typeperf_wrapper_spec.rb +128 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 912cecdb5d9d7caa1b6010d2c5d544bbb258ca52
|
4
|
+
data.tar.gz: 180877863382a2cc1f719e08f53ef5b6e9b8d67e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a38105130ea4f3e34ef586b88274febc153e95590996d0c096ea35bc25888e84d638c3428c611934acea4e0ae7673c6df9012b29311b950a57cf57c4f6963d80
|
7
|
+
data.tar.gz: 8dc370b3de33743434a8c80d9f01ac9913b61b2b007e83a7f06bf7e3bd21d2c432e6f6d46fb319c371822ab588dd7fff2b673a748a357aca742c0f2c11a29083
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Perfmon Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
5
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
On Windows, performance metrics can be collected using [Windows Performance Monitor](https://technet.microsoft.com/en-us/library/cc749249.aspx).
|
10
|
+
This plugin collects the same sort of counters by using the command-line tool [Typeperf](https://technet.microsoft.com/en-us/library/bb490960.aspx).
|
11
|
+
|
12
|
+
To run the tests (be sure that JRuby is installed prior):
|
13
|
+
```
|
14
|
+
git clone https://github.com/NickMRamirez/logstash-input-perfmon.git
|
15
|
+
cd logstash-input-perfmon
|
16
|
+
jruby -S bundle install
|
17
|
+
jruby -S bundle exec rspec spec
|
18
|
+
```
|
19
|
+
|
20
|
+
To build the gem:
|
21
|
+
```
|
22
|
+
git clone https://github.com/NickMRamirez/logstash-input-perfmon.git
|
23
|
+
cd logstash-input-perfmon
|
24
|
+
gem build logstash-input-perfmon.gemspec
|
25
|
+
```
|
26
|
+
|
27
|
+
To install the gem to logstash:
|
28
|
+
```
|
29
|
+
cd path\to\logstash\bin
|
30
|
+
plugin install path\to\gem
|
31
|
+
```
|
32
|
+
|
33
|
+
Create a configuration file. The following collects three metrics every ten seconds:
|
34
|
+
```ruby
|
35
|
+
input {
|
36
|
+
perfmon {
|
37
|
+
interval => 10
|
38
|
+
counters => [
|
39
|
+
"\Processor(_Total)\% Privileged Time",
|
40
|
+
"\Processor(_Total)\% Processor Time",
|
41
|
+
"\Processor(_Total)\% User Time"]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
filter {
|
46
|
+
grok {
|
47
|
+
match => {
|
48
|
+
"message" => "%{DATESTAMP:Occurred},%{NUMBER:PrivilegedTime:float},%{NUMBER:ProcessorTime:float},%{NUMBER:UserTime:float}"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
output {
|
54
|
+
file {
|
55
|
+
path => "C:\perfmon_output.txt"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
This configuration will produce output like:
|
61
|
+
```json
|
62
|
+
{
|
63
|
+
"message":"06/05/2015 15:40:46.999,0.781236,7.032877,6.249891",
|
64
|
+
"@version":"1",
|
65
|
+
"@timestamp":"2015-06-05T19:40:48.468Z",
|
66
|
+
"Occurred":"06/05/2015 15:40:46.999",
|
67
|
+
"PrivilegedTime":0.781236,
|
68
|
+
"ProcessorTime":7.032877,
|
69
|
+
"UserTime":6.249891
|
70
|
+
}
|
71
|
+
```
|
72
|
+
|
73
|
+
Run logstash:
|
74
|
+
```
|
75
|
+
logstash -f C:\path\to\conf
|
76
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rake"
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "socket" # for Socket.gethostname
|
5
|
+
require_relative "typeperf_wrapper"
|
6
|
+
|
7
|
+
# This input will pull metrics from https://technet.microsoft.com/en-us/library/cc749249.aspx[Windows Performance Monitor].
|
8
|
+
# Under the covers, it uses https://technet.microsoft.com/en-us/library/bb490960.aspx[Typeperf].
|
9
|
+
#
|
10
|
+
# To collect performance measurements, use a config like:
|
11
|
+
# [source,ruby]
|
12
|
+
# input {
|
13
|
+
# perfmon {
|
14
|
+
# interval => 10
|
15
|
+
# counters => [
|
16
|
+
# "\Processor(_Total)\% Privileged Time",
|
17
|
+
# "\Processor(_Total)\% Processor Time",
|
18
|
+
# "\Processor(_Total)\% User Time"]
|
19
|
+
# }
|
20
|
+
# }
|
21
|
+
|
22
|
+
# filter {
|
23
|
+
# grok {
|
24
|
+
# match => {
|
25
|
+
# "message" => "%{DATESTAMP:Occurred},%{NUMBER:PrivilegedTime:float},%{NUMBER:ProcessorTime:float},%{NUMBER:UserTime:float}"
|
26
|
+
# }
|
27
|
+
# }
|
28
|
+
# }
|
29
|
+
class LogStash::Inputs::Perfmon < LogStash::Inputs::Base
|
30
|
+
attr_reader :counters, :interval
|
31
|
+
|
32
|
+
config_name "perfmon"
|
33
|
+
|
34
|
+
# If undefined, Logstash will complain, even if codec is unused.
|
35
|
+
default :codec, "plain"
|
36
|
+
|
37
|
+
# Sets which perfmon counters to collect
|
38
|
+
config :counters, :validate => :array, :required => false, :default => [
|
39
|
+
"\\Processor(_Total)\\% Processor Time",
|
40
|
+
"\\Processor Information(_Total)\\% User Time",
|
41
|
+
"\\Process(_Total)\\% Privileged Time"]
|
42
|
+
|
43
|
+
# Sets the frequency, in seconds, at which to collect perfmon metrics
|
44
|
+
config :interval, :validate => :number, :required => false, :default => 10
|
45
|
+
|
46
|
+
#------------Public Methods--------------------
|
47
|
+
public
|
48
|
+
|
49
|
+
# Registers the plugin with logstash
|
50
|
+
def register
|
51
|
+
@host = Socket.gethostname
|
52
|
+
@typeperf = TypeperfWrapper.new(PerfmonProcGetter.new, @interval)
|
53
|
+
@counters.each { |counter| @typeperf.add_counter(counter) }
|
54
|
+
end
|
55
|
+
|
56
|
+
# Runs the perf monitor and monitors its output
|
57
|
+
def run(queue)
|
58
|
+
@typeperf.start_monitor
|
59
|
+
|
60
|
+
@logger.debug("Started perfmon monitor")
|
61
|
+
|
62
|
+
while @typeperf.alive?
|
63
|
+
data = @typeperf.get_next
|
64
|
+
|
65
|
+
@codec.decode(data) do |event|
|
66
|
+
decorate(event)
|
67
|
+
queue << event
|
68
|
+
@logger.debug("Added event to queue: #{event}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Cleans up any resources
|
74
|
+
def teardown
|
75
|
+
@typeperf.stop_monitor
|
76
|
+
@logger.debug("Stopped the perfmon monitor")
|
77
|
+
finished
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class PerfmonProcGetter
|
2
|
+
attr_reader :pid
|
3
|
+
|
4
|
+
# Initializes the PerfmonProcGetter class
|
5
|
+
def initialize
|
6
|
+
@all_counters = `#{get_all_counters_command}`
|
7
|
+
end
|
8
|
+
|
9
|
+
# Creates a new process that runs typeperf to collect perfmon metrics
|
10
|
+
# [counters] Array of counter names, such as ["\\Processor(_Total)\\% Processor Time"]
|
11
|
+
# [interval] The number, in seconds, to wait between each round of collecting metrics
|
12
|
+
# [output_queue] The queue to add each new message to
|
13
|
+
def start_process(counters, interval, output_queue)
|
14
|
+
cmd = get_typeperf_command(counters, interval)
|
15
|
+
|
16
|
+
IO.popen(cmd) do |f|
|
17
|
+
@pid = f.pid
|
18
|
+
|
19
|
+
f.each do |line|
|
20
|
+
next if counters.any? { |counter| line.include? counter } # don't show lines that contain headers
|
21
|
+
line.gsub!('"', '') # remove quotes
|
22
|
+
line.strip!
|
23
|
+
output_queue << line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Kills the typeperf process
|
29
|
+
def stop_process
|
30
|
+
Process.kill(9, @pid)
|
31
|
+
@pid = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gets a value indicating whether the typeperf
|
35
|
+
# process is currently running
|
36
|
+
def proc_is_running?
|
37
|
+
if @pid.nil?
|
38
|
+
return false
|
39
|
+
else
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Gets a value indicating whether the given counter
|
45
|
+
# exists on the system
|
46
|
+
# [counter_name] The name of the counter, such as "\\Processor(_Total)\\% Processor Time"
|
47
|
+
def counter_exists?(counter_name)
|
48
|
+
counter_name = counter_name.gsub(/\(.+\)/, '(*)')
|
49
|
+
return @all_counters.downcase.include?(counter_name.downcase)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Gets the typeperf command line
|
53
|
+
# [counters] Array of counter names, such as ["\\Processor(_Total)\\% Processor Time"]
|
54
|
+
# [interval] The number, in seconds, to wait between each round of collecting metrics
|
55
|
+
def get_typeperf_command(counters, interval)
|
56
|
+
cmd = "typeperf "
|
57
|
+
counters.each { |counter| cmd << "\"#{counter}\" " }
|
58
|
+
cmd << "-si #{interval.to_s} "
|
59
|
+
return cmd.strip!
|
60
|
+
end
|
61
|
+
|
62
|
+
# Gets the command line that lists all available
|
63
|
+
# perf counters on the system
|
64
|
+
def get_all_counters_command
|
65
|
+
"typeperf -q"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Waits until the typeperf process is running
|
69
|
+
def wait_for_process_to_start
|
70
|
+
sleep 0.5 until proc_is_running?
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'win32/process'
|
2
|
+
require_relative 'perfmon_proc_getter'
|
3
|
+
|
4
|
+
# Wraps the typeperf command-line tool, used to get
|
5
|
+
# Windows performance metrics
|
6
|
+
class TypeperfWrapper
|
7
|
+
attr_reader :counters
|
8
|
+
|
9
|
+
# Initializes the TypeperfWrapper class
|
10
|
+
# [perfmon_proc_getter] Gets the proc for opening the perfmon process and getting messages
|
11
|
+
# [interval] The time between samples, defaults to ten seconds
|
12
|
+
def initialize(perfmon_proc_getter, interval = 10)
|
13
|
+
@interval = interval
|
14
|
+
@perfmon_proc_getter = perfmon_proc_getter
|
15
|
+
@counters = []
|
16
|
+
@msg_queue = Queue.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# Adds a counter to the list of counters watched
|
20
|
+
# [counter_name] The path to the counter, such as "\\processor(_total)\\% processor time"
|
21
|
+
def add_counter(counter_name)
|
22
|
+
raise 'Perfmon counter could not be found.' unless @perfmon_proc_getter.counter_exists?(counter_name)
|
23
|
+
@counters << counter_name.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
# Begins monitoring, using the counters in the @counters array
|
27
|
+
# [interval] The time between samples, defaults to ten seconds
|
28
|
+
def start_monitor
|
29
|
+
raise "No perfmon counters defined" if @counters.compact.empty?
|
30
|
+
open_thread_and_do_work()
|
31
|
+
end
|
32
|
+
|
33
|
+
# Stops monitoring
|
34
|
+
def stop_monitor
|
35
|
+
@perfmon_proc_getter.stop_process
|
36
|
+
end
|
37
|
+
|
38
|
+
# Gets a value indicating whether the typeperf process is running
|
39
|
+
def alive?
|
40
|
+
@perfmon_proc_getter.proc_is_running?
|
41
|
+
end
|
42
|
+
|
43
|
+
# Waits until a new message is put onto the queue, then returns it
|
44
|
+
def get_next
|
45
|
+
while @msg_queue.empty?
|
46
|
+
sleep 0.5
|
47
|
+
end
|
48
|
+
|
49
|
+
@msg_queue.pop
|
50
|
+
end
|
51
|
+
|
52
|
+
#-------------Private methods----------------
|
53
|
+
private
|
54
|
+
|
55
|
+
def open_thread_and_do_work
|
56
|
+
@t1 = Thread.new do
|
57
|
+
@perfmon_proc_getter.start_process(@counters, @interval, @msg_queue)
|
58
|
+
end
|
59
|
+
|
60
|
+
@perfmon_proc_getter.wait_for_process_to_start
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-perfmon'
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = "Logstash input for Windows Performance Monitor"
|
6
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program. Logstash input for Windows Performance Monitor metrics."
|
7
|
+
s.authors = ["Nick Ramirez"]
|
8
|
+
s.email = 'nickram44@hotmail.com'
|
9
|
+
s.homepage = "https://github.com/NickMRamirez/logstash-input-perfmon"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = `git ls-files`.split($\)
|
14
|
+
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
23
|
+
s.add_runtime_dependency 'logstash-codec-plain'
|
24
|
+
s.add_runtime_dependency 'win32-process'
|
25
|
+
|
26
|
+
s.add_development_dependency 'logstash-devutils'
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# To run: jruby -S bundle exec rspec -fd spec
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require_relative '../../lib/logstash/inputs/perfmon_proc_getter.rb'
|
4
|
+
|
5
|
+
describe 'UnitTests' do
|
6
|
+
describe 'PerfmonProcGetter' do
|
7
|
+
|
8
|
+
subject(:getter) { PerfmonProcGetter.new }
|
9
|
+
|
10
|
+
describe 'get_typeperf_command' do
|
11
|
+
it 'should be expected command' do
|
12
|
+
result = getter.get_typeperf_command(["test_counter", "test_counter_2"], 1)
|
13
|
+
expect(result).to eq 'typeperf "test_counter" "test_counter_2" -si 1'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'get_all_counters_command' do
|
18
|
+
it 'should be expected command' do
|
19
|
+
result = getter.get_all_counters_command
|
20
|
+
expect(result).to eq 'typeperf -q'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require_relative '../../lib/logstash/inputs/perfmon'
|
3
|
+
|
4
|
+
describe 'IntegrationTests' do
|
5
|
+
describe 'Perfmon' do
|
6
|
+
|
7
|
+
subject(:plugin) do
|
8
|
+
LogStash::Inputs::Perfmon.new(
|
9
|
+
"interval" => 1,
|
10
|
+
"counters" => ["\\processor(_total)\\% processor time"]
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'initialize' do
|
15
|
+
it 'assigns counters and interval' do
|
16
|
+
expect(plugin.counters).to eq ["\\processor(_total)\\% processor time"]
|
17
|
+
expect(plugin.interval).to eq 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'run' do
|
22
|
+
it 'starts listening for perf metrics' do
|
23
|
+
my_queue = Queue.new
|
24
|
+
|
25
|
+
plugin.register
|
26
|
+
|
27
|
+
Thread.new do
|
28
|
+
plugin.run(my_queue)
|
29
|
+
end
|
30
|
+
|
31
|
+
# It can take a few seconds for it to start collecting metrics
|
32
|
+
# Wait up to 60 seconds
|
33
|
+
60.times do
|
34
|
+
break unless my_queue.empty?
|
35
|
+
sleep 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(my_queue).not_to be_empty
|
39
|
+
|
40
|
+
plugin.teardown
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# To run: jruby -S bundle exec rspec -fd spec
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require_relative '../../lib/logstash/inputs/typeperf_wrapper.rb'
|
4
|
+
|
5
|
+
class MockPerfmonProcGetter
|
6
|
+
def start_process(counters, interval, output_queue)
|
7
|
+
output_queue << "Test msg 1"
|
8
|
+
output_queue << "Test msg 2"
|
9
|
+
output_queue << "Test msg 3"
|
10
|
+
end
|
11
|
+
|
12
|
+
def wait_for_process_to_start
|
13
|
+
sleep 1
|
14
|
+
end
|
15
|
+
|
16
|
+
def counter_exists?(counter_name)
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'UnitTests' do
|
22
|
+
describe 'TypeperfWrapper' do
|
23
|
+
subject(:perfmon_proc_getter) do
|
24
|
+
MockPerfmonProcGetter.new
|
25
|
+
end
|
26
|
+
|
27
|
+
subject(:wrapper) { TypeperfWrapper.new(perfmon_proc_getter) }
|
28
|
+
|
29
|
+
describe 'initialize' do
|
30
|
+
it 'should initialize the counters array to empty' do
|
31
|
+
expect(wrapper.counters).to be_empty
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'add_counter' do
|
36
|
+
it 'should add a counter to the array' do
|
37
|
+
wrapper.add_counter '\\processor(_total)\\% processor time'
|
38
|
+
expect(wrapper.counters.count).to eq 1
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should convert the counter name to lowercase' do
|
42
|
+
wrapper.add_counter '\\Processor(_total)\\% Processor Time'
|
43
|
+
expect(wrapper.counters[0]).to eq '\\processor(_total)\\% processor time'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'start_monitor' do
|
48
|
+
it 'should add messages to the message queue' do
|
49
|
+
wrapper.add_counter '\\Processor(_total)\\% Processor Time'
|
50
|
+
wrapper.start_monitor
|
51
|
+
msg1 = wrapper.get_next
|
52
|
+
msg2 = wrapper.get_next
|
53
|
+
msg3 = wrapper.get_next
|
54
|
+
|
55
|
+
expect(msg1).to eq "Test msg 1"
|
56
|
+
expect(msg2).to eq "Test msg 2"
|
57
|
+
expect(msg3).to eq "Test msg 3"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'get_next' do
|
62
|
+
it 'waits for message and then returns it' do
|
63
|
+
# Start waiting for messages now, before any are available
|
64
|
+
msg = nil
|
65
|
+
Thread.new do
|
66
|
+
msg = wrapper.get_next
|
67
|
+
end
|
68
|
+
|
69
|
+
# Now add a message
|
70
|
+
wrapper.add_counter '\\Processor(_total)\\% Processor Time'
|
71
|
+
wrapper.start_monitor
|
72
|
+
|
73
|
+
# Should be seen by get_next
|
74
|
+
sleep 2
|
75
|
+
expect(msg).to eq "Test msg 1"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
describe 'IntegrationTests' do
|
87
|
+
describe 'TypeperfWrapper' do
|
88
|
+
subject(:perfmon_proc_getter) do
|
89
|
+
PerfmonProcGetter.new
|
90
|
+
end
|
91
|
+
|
92
|
+
subject(:wrapper) { TypeperfWrapper.new(perfmon_proc_getter) }
|
93
|
+
|
94
|
+
describe 'start_monitor' do
|
95
|
+
it 'should raise error if no counters are defined' do
|
96
|
+
expect { wrapper.start_monitor }.to raise_error('No perfmon counters defined')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should start the process running' do
|
100
|
+
wrapper.add_counter '\\Processor(_total)\\% Processor Time'
|
101
|
+
wrapper.start_monitor
|
102
|
+
expect(wrapper.alive?).to eq true
|
103
|
+
wrapper.stop_monitor
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'stop_monitor' do
|
108
|
+
it 'should stop the monitor thread' do
|
109
|
+
wrapper.add_counter '\\Processor(_total)\\% Processor Time'
|
110
|
+
wrapper.start_monitor
|
111
|
+
wrapper.stop_monitor
|
112
|
+
expect(wrapper.alive?).to eq false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'alive?' do
|
117
|
+
it 'is false when monitor has not been started' do
|
118
|
+
expect(wrapper.alive?).to eq false
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'add_counter' do
|
123
|
+
it 'raises error when counter is not found' do
|
124
|
+
expect { wrapper.add_counter('\\Nada(_total)\\% DoesntExist') }.to raise_error 'Perfmon counter could not be found.'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-perfmon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Ramirez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-codec-plain
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: win32-process
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: logstash-devutils
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: This gem is a logstash plugin required to be installed on top of the
|
76
|
+
Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
|
77
|
+
a stand-alone program. Logstash input for Windows Performance Monitor metrics.
|
78
|
+
email: nickram44@hotmail.com
|
79
|
+
executables: []
|
80
|
+
extensions: []
|
81
|
+
extra_rdoc_files: []
|
82
|
+
files:
|
83
|
+
- ".gitignore"
|
84
|
+
- Gemfile
|
85
|
+
- LICENSE
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- lib/logstash/inputs/perfmon.rb
|
89
|
+
- lib/logstash/inputs/perfmon_proc_getter.rb
|
90
|
+
- lib/logstash/inputs/typeperf_wrapper.rb
|
91
|
+
- logstash-input-perfmon.gemspec
|
92
|
+
- spec/inputs/perfmon_proc_getter_spec.rb
|
93
|
+
- spec/inputs/perfmon_spec.rb
|
94
|
+
- spec/inputs/typeperf_wrapper_spec.rb
|
95
|
+
homepage: https://github.com/NickMRamirez/logstash-input-perfmon
|
96
|
+
licenses:
|
97
|
+
- Apache License (2.0)
|
98
|
+
metadata:
|
99
|
+
logstash_plugin: 'true'
|
100
|
+
logstash_group: input
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.2.3
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Logstash input for Windows Performance Monitor
|
121
|
+
test_files:
|
122
|
+
- spec/inputs/perfmon_proc_getter_spec.rb
|
123
|
+
- spec/inputs/perfmon_spec.rb
|
124
|
+
- spec/inputs/typeperf_wrapper_spec.rb
|