Class: Bosh::Monitor::Plugins::Graphite
- Inherits:
-
Base
- Object
- Base
- Bosh::Monitor::Plugins::Graphite
show all
- Defined in:
- lib/bosh/monitor/plugins/graphite.rb
Instance Attribute Summary
Attributes inherited from Base
#event_kinds, #logger, #options
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#process(event) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/bosh/monitor/plugins/graphite.rb', line 19
def process(event)
if (event.is_a? Bosh::Monitor::Events::Heartbeat) && event.node_id
metrics = event.metrics
unless metrics.kind_of?(Enumerable)
raise PluginError, "Invalid event metrics: Enumerable expected, #{metrics.class} given"
end
metrics.each do |metric|
metric_name = get_metric_name(event, metric)
metric_timestamp = get_metric_timestamp(metric.timestamp)
metric_value = metric.value
@connection.send_metric(metric_name, metric_value, metric_timestamp)
end
end
end
|
#run ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/bosh/monitor/plugins/graphite.rb', line 8
def run
unless EM.reactor_running?
logger.error("Graphite delivery agent can only be started when event loop is running")
return false
end
host = options["host"]
port = options["port"]
@connection = EM.connect(host, port, Bhm::GraphiteConnection, host, port)
end
|
#validate_options ⇒ Object
4
5
6
|
# File 'lib/bosh/monitor/plugins/graphite.rb', line 4
def validate_options
!!(options.kind_of?(Hash) && options["host"] && options["port"])
end
|