bipbip 0.5.9 → 0.5.10
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 +4 -4
- data/README.md +1 -0
- data/lib/bipbip/plugin.rb +2 -2
- data/lib/bipbip/plugin/command.rb +67 -0
- data/lib/bipbip/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf1d48bb34bcf5158a9389079923fff2fe8eb55f
|
4
|
+
data.tar.gz: d02e8c7f9b4edc8379995501390e366507e1a73e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c108d106ff9a506aefbf4b39bcf0d0e90082360f5954b41dc835527c8e0e0bedd934dc3da1acd7dc05f1a42b44dd2de285e15444c01f82f2b884d3b2b688d4ef
|
7
|
+
data.tar.gz: 20978afd5260bd4cd32b3ef33c7496ef2411e5b54a90c440e8e0b6e420dea52c238ab5c7baf09638af14fd57b8d9e03dc97850193ce2bea920a8274b0d2034ff
|
data/README.md
CHANGED
data/lib/bipbip/plugin.rb
CHANGED
@@ -68,9 +68,9 @@ module Bipbip
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def source_identifier
|
71
|
-
identifier = Bipbip.fqdn
|
71
|
+
identifier = Bipbip.fqdn + '::' + metric_group
|
72
72
|
unless config.empty?
|
73
|
-
identifier += '::' + config.values.first.to_s
|
73
|
+
identifier += '::' + config.values.first.to_s.gsub(/[^\w]/, '_')
|
74
74
|
end
|
75
75
|
identifier
|
76
76
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Bipbip
|
5
|
+
|
6
|
+
class Plugin::Command < Plugin
|
7
|
+
|
8
|
+
attr_accessor :schema
|
9
|
+
|
10
|
+
def metrics_schema
|
11
|
+
@schema ||= find_schema
|
12
|
+
end
|
13
|
+
|
14
|
+
def monitor
|
15
|
+
Hash[command_output.map { |metric, value| [metric, metric_value(value)] }]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def metric_value(value)
|
21
|
+
value = value['value'] if detect_operation_mode(value) == :advanced
|
22
|
+
value = 1 if value == 'true' or value == true
|
23
|
+
value = 0 if value == 'false' or value == false
|
24
|
+
value
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_schema
|
28
|
+
command_output.map do |metric, value|
|
29
|
+
case detect_operation_mode(value)
|
30
|
+
when :simple
|
31
|
+
{:name => "#{metric}", :type => 'gauge'}
|
32
|
+
when :advanced
|
33
|
+
{:name => "#{metric}", :type => value['type'], :unit => value['unit']}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def detect_operation_mode(value)
|
39
|
+
{true => :advanced, false => :simple}.fetch(value.is_a?(Hash))
|
40
|
+
end
|
41
|
+
|
42
|
+
def command_output
|
43
|
+
JSON.parse(exec_command)
|
44
|
+
end
|
45
|
+
|
46
|
+
def exec_command
|
47
|
+
command = config['command'].to_s
|
48
|
+
|
49
|
+
output_stdout = output_stderr = exit_code = nil
|
50
|
+
Open3.popen3(command) { |stdin, stdout, stderr, wait_thr|
|
51
|
+
output_stdout = stdout.read.chomp
|
52
|
+
output_stderr = stderr.read.chomp
|
53
|
+
exit_code = wait_thr.value
|
54
|
+
}
|
55
|
+
|
56
|
+
unless exit_code.success?
|
57
|
+
message = ['Command execution failed:', command]
|
58
|
+
message.push 'STDOUT:', output_stdout unless output_stdout.empty?
|
59
|
+
message.push 'STDERR:', output_stderr unless output_stderr.empty?
|
60
|
+
raise message.join("\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
output_stdout
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/lib/bipbip/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bipbip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-01-
|
13
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- lib/bipbip/helper.rb
|
226
226
|
- lib/bipbip/plugin.rb
|
227
227
|
- lib/bipbip/plugin/apache2.rb
|
228
|
+
- lib/bipbip/plugin/command.rb
|
228
229
|
- lib/bipbip/plugin/elasticsearch.rb
|
229
230
|
- lib/bipbip/plugin/fastcgi_php_apc.rb
|
230
231
|
- lib/bipbip/plugin/fastcgi_php_fpm.rb
|