Class: Sensu::Extension::Graphite
- Inherits:
-
Handler
- Object
- Handler
- Sensu::Extension::Graphite
- Defined in:
- lib/sensu/extensions/graphite.rb
Overview
Graphite Handler
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize ⇒ Graphite
constructor
A new instance of Graphite.
- #name ⇒ Object
- #post_init ⇒ Object
- #run(event) {|"", 0| ... } ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Graphite
Returns a new instance of Graphite.
183 184 185 186 187 |
# File 'lib/sensu/extensions/graphite.rb', line 183 def initialize super @initialized = false @counter = 0 end |
Instance Method Details
#description ⇒ Object
193 194 195 |
# File 'lib/sensu/extensions/graphite.rb', line 193 def description "Extension to get metrics into Graphite" end |
#name ⇒ Object
189 190 191 |
# File 'lib/sensu/extensions/graphite.rb', line 189 def name "graphite" end |
#post_init ⇒ Object
197 198 199 200 201 202 203 204 |
# File 'lib/sensu/extensions/graphite.rb', line 197 def post_init @endpoint = Endpoint.new( @settings[:graphite][:name], @settings[:graphite][:host], @settings[:graphite][:port] ) @counter = 0 end |
#run(event) {|"", 0| ... } ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/sensu/extensions/graphite.rb', line 206 def run(event) begin event = Oj.load(event) metrics = event["check"]["output"] rescue => e logger.error("Graphite: Error setting up event object - #{e.backtrace.to_s}") end begin if @counter > 2048 logger.debug("Graphite: recycling connection") stop post_init end logger.debug("Metrics: #{metrics}") @endpoint.relay_event(metrics) @counter += 1 rescue => e logger.error("Graphite: Error posting metrics - #{e.backtrace.to_s}") end yield "", 0 end |
#stop ⇒ Object
231 232 233 |
# File 'lib/sensu/extensions/graphite.rb', line 231 def stop @endpoint.stop end |