Class: CheckPassenger::Check
- Inherits:
-
Object
- Object
- CheckPassenger::Check
- Extended by:
- NagiosCheck
- Defined in:
- lib/check_passenger/check.rb
Constant Summary collapse
- COUNTER_LABELS =
{ live_process_count: ['%d live process', '%d live processes'], memory: '%dMB memory used', process_count: ['%d process', '%d processes'], request_count: ['%d request', '%d requests'], top_level_request_count: ['%d top-level request', '%d top-level requests'] }
Constants included from NagiosCheck
Class Attribute Summary collapse
-
.parsed_data ⇒ Object
readonly
Returns the value of attribute parsed_data.
Class Method Summary collapse
- .check_counter(counter_name, options = {}) ⇒ Object
- .method_missing(method, *args) ⇒ Object
- .respond_to?(method) ⇒ Boolean
Class Attribute Details
.parsed_data ⇒ Object (readonly)
Returns the value of attribute parsed_data.
8 9 10 |
# File 'lib/check_passenger/check.rb', line 8 def parsed_data @parsed_data end |
Class Method Details
.check_counter(counter_name, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/check_passenger/check.rb', line 18 def check_counter(counter_name, = {}) load_parsed_data() output_data = [] counter = parsed_data.send(counter_name.to_sym, [:app_name]) output_status = nagios_status(counter, ) data = { text: format('Passenger %s %s - %s', [:app_name] || parsed_data.passenger_version, output_status.to_s.upcase, counter_with_label(counter, counter_name)), counter: counter_name.to_s, value: counter, warn: [:warn], crit: [:crit], min: 0, max: nil } if ![:app_name] and [:process_count, :live_process_count].include?(counter_name.to_sym) data[:max] = parsed_data.max_pool_size end output_data << data if [:include_all] parsed_data.application_names.each do |app_name| counter = parsed_data.send(counter_name.to_sym, app_name) output_data << { text: format('%s %s', app_name, counter_with_label(counter, counter_name)), counter: app_name, value: counter } end end return [output_status, output_data] rescue NoApplicationError => e status = :crit return [status, format('Passenger %s %s - %s', e.name, status.to_s.upcase, e.to_s)] end |
.method_missing(method, *args) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/check_passenger/check.rb', line 56 def method_missing(method, *args) if COUNTER_LABELS.keys.include?(method) check_counter(method, *args) else super end end |
.respond_to?(method) ⇒ Boolean
64 65 66 67 |
# File 'lib/check_passenger/check.rb', line 64 def respond_to?(method) return true if COUNTER_LABELS.keys.include?(method) super end |