class Appdynamics::Controller
Attributes
account_name[R]
application_id[R]
application_name[R]
applications[R]
base_uri[R]
host_name[R]
nodes[R]
password[R]
tiers[R]
user_name[R]
Public Class Methods
deserialize(datum)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 21 def self.deserialize datum YAML.load datum end
from_hash(hsh)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 36 def self.from_hash hsh controller = Controller.new hsh['host_name'], hsh['account_name'], hsh['user_name'], hsh['password'] controller.applications = hsh['applications'] controller end
new(host_name, account_name, user_name, password)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 8 def initialize host_name, account_name, user_name, password @host_name = host_name @account_name = account_name @user_name = user_name @password = password @base_uri = "http://#{host_name}/controller/rest" @auth = {username: "#{user_name}@#{account_name}", password: password} end
Public Instance Methods
applications=(applications)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 58 def applications= applications @applications = applications.map{|application| Application.from_hash application, self } end
get(path, additional_options = {})
click to toggle source
# File lib/fluent/plugin/controller.rb, line 68 def get path, additional_options = {} result = self.class.get(URI.escape(path), options(additional_options)) raise Exception.new "HTTP Error: #{result.response.code}" unless result.response.code == "200" result end
metric_data_for(metric, start_time, end_time, rollup = false)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 99 def metric_data_for metric, start_time, end_time, rollup = false path = "#{base_uri}/#{metric.relative_route(true)}" start_time = Time.parse start_time unless start_time.class == Time end_time = Time.parse end_time unless end_time.class == Time path = "#{base_uri}/#{metric.relative_route(true)}" additional_options = { 'time-range-type' => "BETWEEN_TIMES", 'start-time' => start_time.to_i * 1000, 'end-time' => end_time.to_i * 1000, 'rollup' => rollup } result = get path, options({query: additional_options}) result end
metrics_for(obj)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 90 def metrics_for obj path = "#{base_uri}/#{obj.relative_route}" path += "/metrics" if obj.class == Application result = get path result.map{|res| Metric.new self, obj, res } end
nodes_for(application)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 74 def nodes_for application path = "#{base_uri}/#{application.relative_route}/nodes" result = get path result.map{|res| Node.new self, application, res } end
reset_cache!()
click to toggle source
# File lib/fluent/plugin/controller.rb, line 64 def reset_cache! @nodes = @tiers = @applications = nil end
serialize()
click to toggle source
# File lib/fluent/plugin/controller.rb, line 17 def serialize YAML.dump self end
tiers_for(application)
click to toggle source
# File lib/fluent/plugin/controller.rb, line 82 def tiers_for application path = "#{base_uri}/#{application.relative_route}/tiers" result = get path result.map{|res| Tier.new self, application, res } end
to_hash()
click to toggle source
# File lib/fluent/plugin/controller.rb, line 25 def to_hash hsh = { host_name: @host_name, account_name: @account_name, user_name: @user_name, password: @password } hsh.merge!({applications: @applications.map{|app| app.to_hash}}) if @applications hsh end
Protected Instance Methods
options(additional_options = {})
click to toggle source
# File lib/fluent/plugin/controller.rb, line 115 def options additional_options = {} base_options = {basic_auth: @auth}.merge additional_options base_options[:query] ||= {} base_options[:query][:output] ||= 'JSON' base_options[:query][:rollup] ||= false base_options end