Class: Bipbip::Plugin::FastcgiPhpFpm
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::FastcgiPhpFpm
- Defined in:
- lib/bipbip/plugin/fastcgi_php_fpm.rb
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #frequency, #metric_group, #name, #tags
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, factory_from_plugin, #initialize, #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_schema ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/bipbip/plugin/fastcgi_php_fpm.rb', line 3 def metrics_schema [ { name: 'accepted conn', type: 'counter', unit: 'Connections' }, { name: 'listen queue', type: 'gauge', unit: 'Connections' }, { name: 'active processes', type: 'gauge', unit: 'Processes' } ] end |
#monitor ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bipbip/plugin/fastcgi_php_fpm.rb', line 11 def monitor = config['host'].to_s + ':' + config['port'].to_s path = config['path'].to_s env_backup = ENV.to_hash ENV['REQUEST_METHOD'] = 'GET' ENV['SCRIPT_NAME'] = path ENV['SCRIPT_FILENAME'] = path ENV['QUERY_STRING'] = 'json' response = `cgi-fcgi -bind -connect #{.shellescape} 2>&1` ENV.replace(env_backup) body = response.split(/\r?\n\r?\n/)[1] raise "FastCGI response has no body: #{response}" unless body status = JSON.parse(body) status.reject { |k, _v| !metrics_names.include?(k) } end |