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.
@@ -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', 'io reqs'])
20
+ plugin.set_default(:filter, ['reads reqs', 'writes reqs'])
21
21
  end
22
22
 
23
- def run
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
- state = f.split("\n").reject { |d| d =~ /(ram|loop| md| dm| sr)/ }.inject({}) do |s, line|
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
- WORDS.map do |service|
35
- next unless plugin.filter.include?(service) #TODO hardcode
36
- "#{plugin.service} #{dev} #{service}"
37
- end.zip(
38
- $2.split(/\s+/).map { |str| str.to_i }
39
- ).each do |service, value|
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
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.3.7'
3
+ VERSION = '1.3.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: