Class: NewRelic::Plugin::Agent::Base
- Inherits:
-
Object
- Object
- NewRelic::Plugin::Agent::Base
- Defined in:
- lib/newrelic_plugin/agent.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.config_options_list ⇒ Object
Returns the value of attribute config_options_list.
-
.guid ⇒ Object
readonly
Returns the value of attribute guid.
-
.instance_label_proc ⇒ Object
readonly
Returns the value of attribute instance_label_proc.
-
.label ⇒ Object
readonly
Returns the value of attribute label.
-
.version ⇒ Object
readonly
Returns the value of attribute version.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Instance Info.
Class Method Summary collapse
-
.agent_config_options(*args) ⇒ Object
Specify name of configuration values used in plugin implementation.
-
.agent_guid(str) ⇒ Object
Define the GUID for this agent.
-
.agent_human_labels(label, &block) ⇒ Object
Human Readable labels for plugin.
-
.agent_version(str) ⇒ Object
Define version for this agent.
- .config_required? ⇒ Boolean
-
.no_config_required ⇒ Object
Support for single instance, non-configurable agents.
Instance Method Summary collapse
- #guid ⇒ Object
-
#initialize(context, options = {}) ⇒ Base
constructor
Instantiate a newrelic_plugin instance.
- #instance_label ⇒ Object
- #label ⇒ Object
-
#report_metric(metric_name, units, value, opts = {}) ⇒ Object
Setup & Report Metrics.
-
#run(request) ⇒ Object
Execute a poll cycle.
- #version ⇒ Object
Constructor Details
#initialize(context, options = {}) ⇒ Base
Instantiate a newrelic_plugin instance
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/newrelic_plugin/agent.rb', line 91 def initialize context, = {} @context = context @options = if self.class. self.class..each do |config| self.send("#{config}=",[config]) end end @last_time = nil # # Run agent-specific metric setup, if necessary setup_metrics if respond_to? :setup_metrics @component = @context.create_component(instance_label, guid) end |
Class Attribute Details
.config_options_list ⇒ Object
Returns the value of attribute config_options_list.
13 14 15 |
# File 'lib/newrelic_plugin/agent.rb', line 13 def @config_options_list end |
.guid ⇒ Object (readonly)
Returns the value of attribute guid.
12 13 14 |
# File 'lib/newrelic_plugin/agent.rb', line 12 def guid @guid end |
.instance_label_proc ⇒ Object (readonly)
Returns the value of attribute instance_label_proc.
12 13 14 |
# File 'lib/newrelic_plugin/agent.rb', line 12 def instance_label_proc @instance_label_proc end |
.label ⇒ Object (readonly)
Returns the value of attribute label.
12 13 14 |
# File 'lib/newrelic_plugin/agent.rb', line 12 def label @label end |
.version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/newrelic_plugin/agent.rb', line 12 def version @version end |
Instance Attribute Details
#name ⇒ Object (readonly)
Instance Info
72 73 74 |
# File 'lib/newrelic_plugin/agent.rb', line 72 def name @name end |
Class Method Details
.agent_config_options(*args) ⇒ Object
Specify name of configuration values used in plugin implementation.
60 61 62 63 64 65 66 |
# File 'lib/newrelic_plugin/agent.rb', line 60 def *args @config_options_list||=[] args.each do |config| attr_accessor config @config_options_list << config end end |
.agent_guid(str) ⇒ Object
Define the GUID for this agent.
19 20 21 22 |
# File 'lib/newrelic_plugin/agent.rb', line 19 def agent_guid str raise "Did not set GUID" if str.nil? or str=="" @guid=str end |
.agent_human_labels(label, &block) ⇒ Object
Human Readable labels for plugin. label - Name of the plugin block return - Name of a particular instance of a plugin component.
38 39 40 41 |
# File 'lib/newrelic_plugin/agent.rb', line 38 def agent_human_labels label,&block @label=label @instance_label_proc=block end |
.agent_version(str) ⇒ Object
Define version for this agent
27 28 29 |
# File 'lib/newrelic_plugin/agent.rb', line 27 def agent_version str @version = str end |
.config_required? ⇒ Boolean
51 52 53 |
# File 'lib/newrelic_plugin/agent.rb', line 51 def config_required? !@no_config_required end |
.no_config_required ⇒ Object
Support for single instance, non-configurable agents.
48 49 50 |
# File 'lib/newrelic_plugin/agent.rb', line 48 def no_config_required @no_config_required=true end |
Instance Method Details
#guid ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/newrelic_plugin/agent.rb', line 73 def guid return @guid if @guid @guid = self.class.guid # # Verify GUID is set correctly... # invalid_guids = ["", "guid", "_TYPE_YOUR_GUID_HERE_"] raise "Did not set GUID" if @guid.nil? or invalid_guids.include?(@guid) @guid end |
#instance_label ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/newrelic_plugin/agent.rb', line 107 def instance_label if !respond_to? :instance_label_proc_method mod=Module.new mod.send :define_method,:instance_label_proc_method,self.class.instance_label_proc self.extend mod end self.instance_label_proc_method end |
#label ⇒ Object
86 87 88 |
# File 'lib/newrelic_plugin/agent.rb', line 86 def label self.class.label end |
#report_metric(metric_name, units, value, opts = {}) ⇒ Object
Setup & Report Metrics
121 122 123 124 |
# File 'lib/newrelic_plugin/agent.rb', line 121 def report_metric(metric_name, units, value, opts = {} ) return if value.nil? @request.add_metric(@component, "Component/#{metric_name}[#{units}]", value, opts) end |
#run(request) ⇒ Object
Execute a poll cycle
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/newrelic_plugin/agent.rb', line 131 def run(request) @request = request # # Start of cycle work, if any cycle_start if respond_to? :cycle_start # # Collect Data poll_cycle # # End of cycle work, if any cycle_end if respond_to? :cycle_end end |
#version ⇒ Object
83 84 85 |
# File 'lib/newrelic_plugin/agent.rb', line 83 def version self.class.version end |