Class: Bipbip::Plugin::FastcgiPhpApc
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::FastcgiPhpApc
- Defined in:
- lib/bipbip/plugin/fastcgi_php_apc.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
#_fetch_apc_stats ⇒ Hash
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bipbip/plugin/fastcgi_php_apc.rb', line 13 def _fetch_apc_stats = config['host'].to_s + ':' + config['port'].to_s path = if config.key?('path') config['path'].to_s else File.join(Bipbip::Helper.data_path, 'apc-status.php') end env_backup = ENV.to_hash ENV['REQUEST_METHOD'] = 'GET' ENV['SCRIPT_NAME'] = File.basename(path) ENV['SCRIPT_FILENAME'] = path 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 JSON.parse(body) end |
#metrics_schema ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/bipbip/plugin/fastcgi_php_apc.rb', line 3 def metrics_schema [ { name: 'opcode_mem_size', type: 'gauge', unit: 'b' }, { name: 'user_mem_size', type: 'gauge', unit: 'b' }, { name: 'used_mem_size', type: 'gauge', unit: 'b' }, { name: 'used_mem_percentage', type: 'gauge', unit: '%' } ] end |
#monitor ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/bipbip/plugin/fastcgi_php_apc.rb', line 33 def monitor stats = _fetch_apc_stats { opcode_mem_size: stats['opcode_mem_size'].to_i, user_mem_size: stats['user_mem_size'].to_i, used_mem_size: stats['used_mem_size'].to_i, used_mem_percentage: (stats['used_mem_size'].to_f / stats['total_mem_size'].to_f) * 100 } end |