logstash-input-perfmon 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -5
- data/lib/logstash/inputs/perfmon.rb +16 -2
- data/lib/logstash/inputs/perfmon_proc_getter.rb +2 -2
- data/lib/logstash/inputs/typeperf_wrapper.rb +2 -2
- data/logstash-input-perfmon.gemspec +1 -1
- data/spec/inputs/perfmon_spec.rb +30 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a02d8e9c2007451db119daba0b7cc49edd7d4d1b
|
4
|
+
data.tar.gz: 3f883c2fc4e5a85fa1c777f96bb4329aa108d42c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e30516a092a4e498b3e90289dfe69cea0343f966bed7d1a9eb0e6447f46e00a20e421a0859553a74a4f4cbe85527ebab4adb2d806725d1ea9e9eb6b0c51d26e8
|
7
|
+
data.tar.gz: f642dc8d47e9573d32e59003aeb6c71e24745a533a1abe30c9888e3a4f5d733047acd37566f45e28022587d875e82253d54fa95b2b4b54556f0db149c09960a9
|
data/README.md
CHANGED
@@ -13,14 +13,13 @@ To run the tests (be sure that JRuby is installed prior):
|
|
13
13
|
```
|
14
14
|
git clone https://github.com/NickMRamirez/logstash-input-perfmon.git
|
15
15
|
cd logstash-input-perfmon
|
16
|
+
jruby -S gem install bundler
|
16
17
|
jruby -S bundle install
|
17
18
|
jruby -S bundle exec rspec spec
|
18
19
|
```
|
19
20
|
|
20
21
|
To build the gem:
|
21
22
|
```
|
22
|
-
git clone https://github.com/NickMRamirez/logstash-input-perfmon.git
|
23
|
-
cd logstash-input-perfmon
|
24
23
|
gem build logstash-input-perfmon.gemspec
|
25
24
|
```
|
26
25
|
|
@@ -56,6 +55,10 @@ output {
|
|
56
55
|
}
|
57
56
|
}
|
58
57
|
```
|
58
|
+
Run logstash:
|
59
|
+
```
|
60
|
+
logstash -f C:\path\to\conf
|
61
|
+
```
|
59
62
|
|
60
63
|
This configuration will produce output like:
|
61
64
|
```json
|
@@ -63,6 +66,7 @@ This configuration will produce output like:
|
|
63
66
|
"message":"06/05/2015 15:40:46.999,0.781236,7.032877,6.249891",
|
64
67
|
"@version":"1",
|
65
68
|
"@timestamp":"2015-06-05T19:40:48.468Z",
|
69
|
+
"host":"Webserver1",
|
66
70
|
"Occurred":"06/05/2015 15:40:46.999",
|
67
71
|
"PrivilegedTime":0.781236,
|
68
72
|
"ProcessorTime":7.032877,
|
@@ -70,7 +74,14 @@ This configuration will produce output like:
|
|
70
74
|
}
|
71
75
|
```
|
72
76
|
|
73
|
-
|
77
|
+
## Troubleshooting
|
78
|
+
|
79
|
+
If you get bundler errors having to do with not being able to install a gem, such as:
|
80
|
+
```
|
81
|
+
You have requested:
|
82
|
+
logstash-devutil >= 0
|
83
|
+
|
84
|
+
The bundle currently has logstash-devutil locked at 0.0.13.
|
85
|
+
Try running 'bundle update logstash-devutils'
|
74
86
|
```
|
75
|
-
|
76
|
-
```
|
87
|
+
The JRuby -S parameter looks at your PATH and it may be defaulting to another version of Ruby.
|
@@ -27,7 +27,7 @@ require_relative "typeperf_wrapper"
|
|
27
27
|
# }
|
28
28
|
# }
|
29
29
|
class LogStash::Inputs::Perfmon < LogStash::Inputs::Base
|
30
|
-
attr_reader :counters, :interval
|
30
|
+
attr_reader :counters, :interval, :host
|
31
31
|
|
32
32
|
config_name "perfmon"
|
33
33
|
|
@@ -43,17 +43,28 @@ class LogStash::Inputs::Perfmon < LogStash::Inputs::Base
|
|
43
43
|
# Sets the frequency, in seconds, at which to collect perfmon metrics
|
44
44
|
config :interval, :validate => :number, :required => false, :default => 10
|
45
45
|
|
46
|
+
# Identifies the server being monitored. Defaults to hostname, but can be overriden.
|
47
|
+
# [source,ruby]
|
48
|
+
# input {
|
49
|
+
# perfmon {
|
50
|
+
# interval => 10
|
51
|
+
# counters => ["\Processor(_Total)\% Privileged Time"],
|
52
|
+
# host => "webserver1"
|
53
|
+
# }
|
54
|
+
# }
|
55
|
+
config :host, :required => false, :default => Socket.gethostname
|
56
|
+
|
46
57
|
#------------Public Methods--------------------
|
47
58
|
public
|
48
59
|
|
49
60
|
# Registers the plugin with logstash
|
50
61
|
def register
|
51
|
-
@host = Socket.gethostname
|
52
62
|
@typeperf = TypeperfWrapper.new(PerfmonProcGetter.new, @interval)
|
53
63
|
@counters.each { |counter| @typeperf.add_counter(counter) }
|
54
64
|
end
|
55
65
|
|
56
66
|
# Runs the perf monitor and monitors its output
|
67
|
+
# [queue] The queue to add new events to
|
57
68
|
def run(queue)
|
58
69
|
@typeperf.start_monitor
|
59
70
|
|
@@ -64,6 +75,9 @@ class LogStash::Inputs::Perfmon < LogStash::Inputs::Base
|
|
64
75
|
|
65
76
|
@codec.decode(data) do |event|
|
66
77
|
decorate(event)
|
78
|
+
|
79
|
+
event['host'] = @host
|
80
|
+
|
67
81
|
queue << event
|
68
82
|
@logger.debug("Added event to queue: #{event}")
|
69
83
|
end
|
@@ -18,8 +18,8 @@ class PerfmonProcGetter
|
|
18
18
|
|
19
19
|
f.each do |line|
|
20
20
|
next if counters.any? { |counter| line.include? counter } # don't show lines that contain headers
|
21
|
-
|
22
|
-
|
21
|
+
line.gsub!('"', '') # remove quotes
|
22
|
+
line.strip!
|
23
23
|
output_queue << line
|
24
24
|
end
|
25
25
|
end
|
@@ -53,8 +53,8 @@ class TypeperfWrapper
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def open_thread_and_do_work
|
56
|
-
|
57
|
-
|
56
|
+
Thread.new do
|
57
|
+
@perfmon_proc_getter.start_process(@counters, @interval, @msg_queue)
|
58
58
|
end
|
59
59
|
|
60
60
|
@perfmon_proc_getter.wait_for_process_to_start
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-perfmon'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.2'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Logstash input for Windows Performance Monitor"
|
6
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."
|
data/spec/inputs/perfmon_spec.rb
CHANGED
@@ -7,14 +7,41 @@ describe 'IntegrationTests' do
|
|
7
7
|
subject(:plugin) do
|
8
8
|
LogStash::Inputs::Perfmon.new(
|
9
9
|
"interval" => 1,
|
10
|
-
"counters" => ["\\processor(_total)\\% processor time"]
|
10
|
+
"counters" => ["\\processor(_total)\\% processor time"],
|
11
|
+
"host" => "webserver1"
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
14
15
|
describe 'initialize' do
|
15
|
-
it 'assigns counters
|
16
|
+
it 'assigns counters' do
|
16
17
|
expect(plugin.counters).to eq ["\\processor(_total)\\% processor time"]
|
17
|
-
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'assigns interval' do
|
21
|
+
expect(plugin.interval).to eq 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'assigns hostname to host when host is not set' do
|
25
|
+
my_plugin = LogStash::Inputs::Perfmon.new(
|
26
|
+
"interval" => 1,
|
27
|
+
"counters" => ["\\processor(_total)\\% processor time"]
|
28
|
+
)
|
29
|
+
|
30
|
+
my_plugin.register
|
31
|
+
|
32
|
+
expect(my_plugin.host).to eq Socket.gethostname
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'overrides hostname as host when host is set' do
|
36
|
+
my_plugin = LogStash::Inputs::Perfmon.new(
|
37
|
+
"interval" => 1,
|
38
|
+
"counters" => ["\\processor(_total)\\% processor time"],
|
39
|
+
"host" => "webserver1"
|
40
|
+
)
|
41
|
+
|
42
|
+
my_plugin.register
|
43
|
+
|
44
|
+
expect(my_plugin.host).to eq 'webserver1'
|
18
45
|
end
|
19
46
|
end
|
20
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-perfmon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Ramirez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|