Class: ChefInfluxDB
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- ChefInfluxDB
- Defined in:
- lib/chef-handler-influxdb.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pass ⇒ Object
readonly
Returns the value of attribute pass.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#series ⇒ Object
readonly
Returns the value of attribute series.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #client ⇒ Object
- #defaults ⇒ Object
- #generate_data ⇒ Object
-
#initialize(options = defaults) ⇒ ChefInfluxDB
constructor
A new instance of ChefInfluxDB.
- #report ⇒ Object
Constructor Details
#initialize(options = defaults) ⇒ ChefInfluxDB
Returns a new instance of ChefInfluxDB.
30 31 32 33 34 35 36 37 38 |
# File 'lib/chef-handler-influxdb.rb', line 30 def initialize( = defaults) @database = [:database] @series = [:series] @host = [:host] @port = [:port] @user = [:user] @pass = [:pass] @data = [:data] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def data @data end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def database @database end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def host @host end |
#pass ⇒ Object (readonly)
Returns the value of attribute pass.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def pass @pass end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def port @port end |
#series ⇒ Object (readonly)
Returns the value of attribute series.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def series @series end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
28 29 30 |
# File 'lib/chef-handler-influxdb.rb', line 28 def user @user end |
Instance Method Details
#client ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/chef-handler-influxdb.rb', line 51 def client return InfluxDB::Client.new( @database, :host => @host, :port => @port, :username => @user, :password => @pass ) end |
#defaults ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef-handler-influxdb.rb', line 40 def defaults return { :user => 'root', :pass => 'root', :host => 'localhost', :port => 8086, :database => nil, :series => nil } end |
#generate_data ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/chef-handler-influxdb.rb', line 61 def generate_data return { :host => node.name, :status => run_status.success? ? 1 : 0, :resources_updated => run_status.updated_resources.length, :elapsed_time => run_status.elapsed_time, :end_time => Time.now.to_s }.merge(@data || {}) end |
#report ⇒ Object
71 72 73 74 |
# File 'lib/chef-handler-influxdb.rb', line 71 def report Chef::Log.info 'Exporting Chef run data to InfluxDB' client.write_point(@series, generate_data) end |