Class: Bipbip::Plugin::Nginx

Inherits:
Bipbip::Plugin show all
Defined in:
lib/bipbip/plugin/nginx.rb

Instance Attribute Summary

Attributes inherited from Bipbip::Plugin

#config, #metric_group, #name, #pid

Instance Method Summary collapse

Methods inherited from Bipbip::Plugin

factory, #frequency, #initialize, #interrupt, #interrupted?, #metrics_names, #run, #source_identifier

Methods included from InterruptibleSleep

#interrupt_sleep, #interruptible_sleep

Constructor Details

This class inherits a constructor from Bipbip::Plugin

Instance Method Details

#metrics_schemaObject



5
6
7
8
9
# File 'lib/bipbip/plugin/nginx.rb', line 5

def metrics_schema
  [
      {:name => 'connections_requested', :type => 'counter', :unit => 'Requests'},
  ]
end

#monitorObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bipbip/plugin/nginx.rb', line 11

def monitor
  uri = URI.parse(config['url'])
  response = Net::HTTP.get_response(uri)

  raise "Invalid response from server at #{config['url']}" unless response.code == "200"

  nstats = response.body.split(/\r*\n/)
  connections_requested = nstats[2].lstrip.split(/\s+/)[2].to_i

  {:connections_requested => connections_requested}
end