Sha256: d3e1749e9aacf6e30d3bc762177d2d96474a9c88e18f3a967f03671ed7257160
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#!/usr/bin/env ruby # # Released under the same terms as Sensu (the MIT license); see LICENSE # for details # # This will send the check status (0,1,2,3) to a graphite metric when a check event state changes # Based on handler-graphite-notify.rb. # Config by default is graphite_status but can be called with a specific json config # using the -j option. This allows multiple graphite handlers to be configured. require 'sensu-handler' require 'simple-graphite' class Resolve < Sensu::Handler option :json_config, description: 'Config Name', short: '-j JsonConfig', long: '--json_config JsonConfig', required: false, default: 'graphite_status' # override filters from Sensu::Handler. not appropriate for metric handlers def filter; end def handle json_config = config[:json_config] port = settings[json_config]['port'] ? settings[json_config]['port'].to_s : '2003' graphite = Graphite.new(host: settings[json_config]['host'], port: port) return unless graphite prop = @event['check']['status'] message = "#{settings[json_config]['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}" message += " #{prop} #{graphite.time_now + rand(100)}" begin graphite.push_to_graphite do |graphite_socket| graphite_socket.puts message end rescue Errno::ETIMEDOUT error_msg = "Can't connect to #{settings[json_config]['host']}:#{port} and send message #{message}'" raise error_msg end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-graphite-boutetnico-1.0.0 | bin/handler-graphite-status.rb |