Paste: nagios-aggregate

Author: crhancoc
Mode: ruby
Date: Tue, 16 Apr 2013 16:48:12
Plain Text |
module MCollective
  class Aggregate
    class Ngtetest_summation<Base
      # Before function is run processing
      def startup_hook
        @result[:value] = {}
        @result[:type] = :collection

        @status_map = ["OK", "WARN", "CRIT", "UNKNOWN"]
        @status_map.each {|s| @result[:value][s] = 0}

        # set default aggregate_format if it is undefined
        @aggregate_format = "%10s : %s" unless @aggregate_format
      end

      # Increments the correct field in the result hash based
      # on the result of the nrpe command.
      def process_result(value, reply)
	p value
        value.each do |k,v|
	   status = @result[:value][k]
	   @result[:value][k] += v
	end
      end
      def summarize
	result_class(@result[:type]).new(@result,@aggregate_format,@action)
      end
    end
  end
end

New Annotation

Summary:
Author:
Mode:
Body: