lib/riemann/babbler/plugin.rb in riemann-babbler-0.2.0 vs lib/riemann/babbler/plugin.rb in riemann-babbler-0.2.1
- old
+ new
@@ -17,10 +17,11 @@
end
end
def initialize
@configatron = $configatron
+ @storage = Hash.new
init
end
def log
@logger ||= $logger
@@ -34,9 +35,17 @@
def report(event)
event[:tags] = options.riemann.tags unless options.riemann.tags.nil?
event[:host] = host
log.debug "Report status: #{event.inspect}"
riemann << event
+ end
+
+ def report_with_diff(event)
+ current_metric = event[:metric]
+ event[:metric] = @storage[ event[:service] ] - current_metric if @storage.has_key? event[:service]
+ @storage[ event[:service] ] = current_metric
+ event[:state] = state(current_metric) unless plugin.states.critical.nil?
+ report(event)
end
def host
hostname = `hostname`.chomp.downcase
hostname += options.riemann.suffix unless options.riemann.suffix.nil?