riemann-babbler 1.3.7 → 1.3.8
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.
- data/lib/riemann/babbler/plugins/diskstat.rb +13 -12
- data/lib/riemann/babbler/version.rb +1 -1
- metadata +1 -1
@@ -17,29 +17,30 @@ class Riemann::Babbler::Diskstat < Riemann::Babbler
|
|
17
17
|
def init
|
18
18
|
plugin.set_default(:service, 'diskstat')
|
19
19
|
plugin.set_default(:interval, 60)
|
20
|
-
plugin.set_default(:filter, ['reads reqs', 'writes reqs'
|
20
|
+
plugin.set_default(:filter, ['reads reqs', 'writes reqs'])
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def run_plugin
|
24
24
|
File.exists? '/proc/diskstats'
|
25
25
|
end
|
26
26
|
|
27
27
|
def collect
|
28
28
|
status = Array.new
|
29
29
|
f = File.read('/proc/diskstats')
|
30
|
-
|
30
|
+
f.split("\n").reject { |d| d =~ /(ram|loop)/ }.inject({}) do |s, line|
|
31
31
|
if line =~ /^(?:\s+\d+){2}\s+([\w\d]+) (.*)$/
|
32
32
|
dev = $1
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
next if service.nil? #TODO hardcode
|
41
|
-
status << { :service => service, :metric => value, :as_diff => true}
|
33
|
+
values = $2.split(/\s+/).map { |str| str.to_i }
|
34
|
+
# пропускаем неинтересные девайсы
|
35
|
+
# которые закнчиваются на число, но при этом не пропускаем xvd
|
36
|
+
next if !!(dev.match /\d+$/ || !(dev.match =~ /^xvd/))
|
37
|
+
# читаем все фильтры
|
38
|
+
plugin.filter.each do |filter|
|
39
|
+
status << { :service => "#{plugin.service} #{dev} #{filter}", :metric => values[WORDS.index(filter)], :as_diff => true}
|
42
40
|
end
|
41
|
+
# добавляем iops
|
42
|
+
iops = values[WORDS.index('reads reqs')].to_i + values[WORDS.index('writes reqs')].to_i
|
43
|
+
status << { :service => "#{plugin.service} #{dev} iops", :metric => iops, :as_diff => true}
|
43
44
|
end
|
44
45
|
end
|
45
46
|
status
|