Sha256: eac4460864e650e35d800e7ff904b281f8ea7ef82547d0ffe33ab1b7166fe8e4
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
#!/usr/bin/env ruby # # Copyright 2013 FunGo Studios (team@fungostudios.com) # # Depends on librato-metrics gem # gem install librato-metrics # # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. require 'sensu-handler' require 'librato/metrics' class LibratoMetrics < Sensu::Handler # override filters from Sensu::Handler. not appropriate for metric handlers def filter end def handle source = settings['librato']['use_sensu_client_hostname_as_source'] ? @event['client']['name'] : nil queue = Librato::Metrics::Queue.new source: source @event['check']['output'].split("\n").each do |line| name, value, timestamp = line.split(/\s+/) queue.add name => { measure_time: timestamp.to_i, value: value.to_f } end Librato::Metrics.authenticate settings['librato']['email'], settings['librato']['api_key'] begin timeout(3) do queue.submit end rescue Timeout::Error puts 'librato -- timed out while sending metrics' rescue => error puts "librato -- failed to send metrics : #{error.message}" puts " #{error.backtrace.join("\n\t")}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-librato-1.0.0 | bin/handler-metrics-librato.rb |
sensu-plugins-librato-0.0.2 | bin/handler-metrics-librato.rb |