Class: CheckPassenger::Check

Inherits:
Object
  • Object
show all
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

NagiosCheck::EXIT_CODES

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.parsed_dataObject (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, options = {})
  load_parsed_data(options)
  output_data = []

  counter = parsed_data.send(counter_name.to_sym, options[:app_name])
  output_status = nagios_status(counter, options)

  data = {
    text: format('Passenger %s %s - %s',
                 options[: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: options[:warn], crit: options[:crit],
    min: 0, max: nil
  }
  if !options[: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 options[: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

Returns:

  • (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