riemann-babbler 0.1.5 → 0.1.6

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.
@@ -22,37 +22,38 @@ class Riemann::Babbler::Net
22
22
  end
23
23
 
24
24
  def init
25
- @diff = Hash.new
26
25
  @old_status = Hash.new
27
26
  end
28
27
 
29
28
  def net
30
29
  f = File.read('/proc/net/dev')
31
30
  status = Hash.new
32
- f.split("\n").inject({}) do |s, line|
33
- if line =~ /\s*(\w+?):\s*([\s\d]+)\s*/
34
- iface = $1
35
- WORDS.map do |service|
36
- "#{plugin.service} #{iface} #{service}"
37
- end.zip(
38
- $2.split(/\s+/).map { |str| str.to_i }
39
- ).each do |service, value|
40
- status.merge!({service => value})
41
- end
31
+ @diff = Hash.new
32
+ f.split("\n").each do |line|
33
+ iface = line.split(":")[0].strip
34
+ next unless line =~ /(\w*)\:\s*([\s\d]+)\s*/
35
+ WORDS.map do |service|
36
+ "#{plugin.service} #{iface} #{service}"
37
+ end.zip(
38
+ $2.split(/\s+/).map { |str| str.to_i }
39
+ ).each do |service, value|
40
+ status.merge!({service => value})
42
41
  end
43
42
  end
44
- status.each_key { |key| @diff[key] = status[key] - @old_status[key] } unless @old_status.empty?
43
+ status.each_key { |key| @diff.merge!({key => status[key] - @old_status[key]}) } unless @old_status.empty?
45
44
  @old_status = status
46
45
  @diff
47
46
  end
48
47
 
49
48
  def tick
50
- net.each do |service, value|
49
+ status = net
50
+ status.each_key do |service|
51
+ #next if status[service] == 0
51
52
  report({
52
53
  :service => service,
53
- :metric => value
54
+ :metric => status[service]
54
55
  })
55
- end unless net.nil?
56
+ end
56
57
  end
57
58
 
58
59
  end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  module Babbler
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
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: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: