Sha256: cca774d12f51e71c0bc7f746165849829b6061b577ac267ff6a64a7c8fccaae0
Contents?: true
Size: 783 Bytes
Versions: 4
Compression:
Stored size: 783 Bytes
Contents
module Salus class CollectdRenderer < BaseRenderer def initialize(opts={}) opts[:separator] = opts.fetch(:separator, '/') super(opts) end def render(data) hostname = ENV.fetch('COLLECTD_HOSTNAME', 'localhost') options = ENV.key?('COLLECTD_INTERVAL') ? "interval=#{ENV['COLLECTD_INTERVAL']} " : '' iterate(data) do |name, metric| # Text metrics are unsupported next if metric.is_a? Salus::Text unless metric.timestamp.nil? # Effectively all salus metrics are gauges for collectd, with exception to text STDOUT.puts "PUTVAL #{hostname}#{@separator}#{name} #{options}#{metric.timestamp.to_i}:#{metric.value.nil? ? 'U' : metric.value}" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
salus-0.2.1 | lib/salus/renderer/collectd.rb |
salus-0.2.0 | lib/salus/renderer/collectd.rb |
salus-0.1.3 | lib/salus/renderer/collectd.rb |
salus-0.1.2 | lib/salus/renderer/collectd.rb |