riemann-babbler 0.2.0 → 0.2.1

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.
@@ -19,6 +19,7 @@ module Riemann
19
19
 
20
20
  def initialize
21
21
  @configatron = $configatron
22
+ @storage = Hash.new
22
23
  init
23
24
  end
24
25
 
@@ -38,6 +39,14 @@ module Riemann
38
39
  riemann << event
39
40
  end
40
41
 
42
+ def report_with_diff(event)
43
+ current_metric = event[:metric]
44
+ event[:metric] = @storage[ event[:service] ] - current_metric if @storage.has_key? event[:service]
45
+ @storage[ event[:service] ] = current_metric
46
+ event[:state] = state(current_metric) unless plugin.states.critical.nil?
47
+ report(event)
48
+ end
49
+
41
50
  def host
42
51
  hostname = `hostname`.chomp.downcase
43
52
  hostname += options.riemann.suffix unless options.riemann.suffix.nil?
@@ -28,7 +28,6 @@ class Riemann::Babbler::Net
28
28
  def net
29
29
  f = File.read('/proc/net/dev')
30
30
  status = Hash.new
31
- @diff = Hash.new
32
31
  f.split("\n").each do |line|
33
32
  iface = line.split(":")[0].strip
34
33
  iface.gsub!(/\./,"_")
@@ -41,16 +40,14 @@ class Riemann::Babbler::Net
41
40
  status.merge!({service => value})
42
41
  end
43
42
  end
44
- status.each_key { |key| @diff.merge!({key => status[key] - @old_status[key]}) } unless @old_status.empty?
45
- @old_status = status
46
- @diff
43
+ status
47
44
  end
48
45
 
49
46
  def tick
50
47
  status = net
51
48
  status.each_key do |service|
52
49
  #next if status[service] == 0
53
- report({
50
+ report_with_diff({
54
51
  :service => service,
55
52
  :metric => status[service]
56
53
  })
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  module Babbler
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
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.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: