Class: Sensu::Plugin::Metric::CLI::JSON

Inherits:
CLI
  • Object
show all
Defined in:
lib/sensu-plugin/metric/cli.rb

Instance Attribute Summary

Attributes inherited from CLI

#argv

Instance Method Summary collapse

Methods inherited from CLI

#initialize, method_added, #run

Constructor Details

This class inherits a constructor from Sensu::Plugin::CLI

Instance Method Details

#output(obj = nil) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/sensu-plugin/metric/cli.rb', line 10

def output(obj=nil)
  if obj.is_a?(String) || obj.is_a?(Exception)
    puts obj.to_s
  elsif obj.is_a?(Hash)
    obj['timestamp'] ||= Time.now.to_i
    puts ::JSON.generate(obj)
  end
end