ffwd-collectd 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49679083351f91e41dbd8633d41113e8382c16e
|
4
|
+
data.tar.gz: b4834244fb558ce61ac5c93b4d425a85cc083edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c621d6753759e53c1a4ea5c7532a02a1c3e6fdf86db8c4f103e39088aa291db72e04825ba131bfd35d29660a0242e8db6d01a3eca70a27707bfa404cdd62b7c
|
7
|
+
data.tar.gz: 39e84c1eea1d1c2168a6eb3375fb1708c944d32c8ed4b7301f06f13ab59a30037499b7fc99ea32652eca27ed7bdf324c2ce57fe0f55973be863e816a5cbb6c30
|
@@ -23,56 +23,87 @@ module FFWD::Plugin::Collectd
|
|
23
23
|
def initialize bind, core, config
|
24
24
|
@bind = bind
|
25
25
|
@core = core
|
26
|
-
@
|
26
|
+
@db = TypesDB.open config[:types_db]
|
27
27
|
@key = config[:key]
|
28
28
|
end
|
29
29
|
|
30
30
|
def receive_data(data)
|
31
|
-
Parser.parse(data) do |
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
Parser.parse(data) do |m|
|
32
|
+
plugin = m[:plugin]
|
33
|
+
type = m[:type]
|
34
|
+
plugin_i = m[:plugin_instance]
|
35
|
+
type_i = m[:type_instance]
|
35
36
|
|
36
|
-
|
37
|
-
"plugin" => metric[:plugin],
|
38
|
-
"type" => metric[:type],
|
39
|
-
}
|
40
|
-
|
41
|
-
if instance = metric[:plugin_instance] and not instance.empty?
|
42
|
-
attributes[:plugin_instance] = instance
|
43
|
-
end
|
44
|
-
|
45
|
-
if instance = metric[:type_instance] and not instance.empty?
|
46
|
-
attributes[:type_instance] = instance
|
47
|
-
end
|
48
|
-
|
49
|
-
# Just add a running integer to the end of the key, the 'correct'
|
50
|
-
# solution would have been to read, parse and match from a types.db.
|
51
|
-
#
|
52
|
-
# http://collectd.org/documentation/manpages/types.db.5.shtml
|
53
|
-
if values.size > 1
|
54
|
-
values.each_with_index do |v, i|
|
55
|
-
if @types_db and name = @types_db.get_name(metric[:type], i)
|
56
|
-
index_key = name
|
57
|
-
else
|
58
|
-
index_key = i.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
@core.input.metric(
|
62
|
-
:key => @key, :time => time, :value => v[1],
|
63
|
-
:host => host, :attributes => attributes)
|
64
|
-
@bind.increment :received_metrics
|
65
|
-
end
|
66
|
-
else
|
67
|
-
v = values[0]
|
37
|
+
read_values(plugin, plugin_i, type, type_i, m[:values]) do |a, v|
|
68
38
|
@core.input.metric(
|
69
|
-
:key => @key, :time => time, :value => v
|
70
|
-
:host => host, :attributes =>
|
39
|
+
:key => @key, :time => m[:time], :value => v,
|
40
|
+
:host => m[:host], :attributes => a)
|
71
41
|
@bind.increment :received_metrics
|
72
42
|
end
|
73
43
|
end
|
74
44
|
rescue => e
|
75
45
|
@bind.log.error "Failed to receive data", e
|
76
46
|
end
|
47
|
+
|
48
|
+
def read_values(plugin, plugin_i, type, type_i, values, &block)
|
49
|
+
if values.size == 1
|
50
|
+
return read_single(plugin, plugin_i, type, type_i, values[0], &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
read_multiple(plugin, plugin_i, type, type_i, values, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def read_single(plugin, plugin_i, type, type_i, v)
|
57
|
+
a = {:plugin => plugin, :type => type}
|
58
|
+
a[:plugin_instance] = plugin_i unless plugin_i.nil? or plugin_i.empty?
|
59
|
+
a[:type_instance] = type_i unless type_i.nil? or type_i.empty?
|
60
|
+
a[:value_type] = v[0]
|
61
|
+
a[:what] = format_what(a)
|
62
|
+
yield a, v[1]
|
63
|
+
end
|
64
|
+
|
65
|
+
# Handle payload with multiple values.
|
66
|
+
#
|
67
|
+
# If a database is not available, plugin_instance becomes the running
|
68
|
+
# integer, or index of the value.
|
69
|
+
#
|
70
|
+
# If a database is avaialble, it would follow the current structure and
|
71
|
+
# determine what the name of the plugin_instance is.
|
72
|
+
#
|
73
|
+
# http://collectd.org/documentation/manpages/types.db.5.shtml
|
74
|
+
def read_multiple(plugin, plugin_i, type, type_i, values)
|
75
|
+
values.each_with_index do |v, i|
|
76
|
+
a = {:plugin => plugin, :type => type}
|
77
|
+
a[:plugin_instance] = plugin_i unless plugin_i.nil? or plugin_i.empty?
|
78
|
+
a[:type_instance] = format_type_instance(type, i)
|
79
|
+
a[:value_type] = v[0]
|
80
|
+
a[:what] = format_what(a)
|
81
|
+
yield a, v[1]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def format_type_instance type, i
|
86
|
+
if @db
|
87
|
+
return @db.get_name(type, i)
|
88
|
+
end
|
89
|
+
|
90
|
+
i.to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
def format_what a
|
94
|
+
p = if a[:plugin_instance]
|
95
|
+
"#{a[:plugin]}-#{a[:plugin_instance]}"
|
96
|
+
else
|
97
|
+
a[:plugin].to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
t = if a[:type_instance]
|
101
|
+
"#{a[:type]}-#{a[:type_instance]}"
|
102
|
+
else
|
103
|
+
a[:type].to_s
|
104
|
+
end
|
105
|
+
|
106
|
+
"#{p}/#{t}"
|
107
|
+
end
|
77
108
|
end
|
78
109
|
end
|
@@ -23,15 +23,11 @@ module FFWD::Plugin::Collectd
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_name key, i
|
26
|
-
|
27
|
-
return
|
26
|
+
if entry = @database[key] and spec = entry[i]
|
27
|
+
return spec[0]
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
return nil
|
32
|
-
end
|
33
|
-
|
34
|
-
type_spec[0]
|
30
|
+
return i.to_s
|
35
31
|
end
|
36
32
|
|
37
33
|
def self.open path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffwd-collectd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John-John Tedro
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
26
|
+
version: 0.3.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|