Class: CheckPassenger::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/check_passenger/parser.rb

Constant Summary collapse

UNIT_MULTIPLIERS =
{'s' => 1, 'm' => 60, 'h' => 3_600, 'd' => 86_400}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(passenger_status_output) ⇒ Parser

Returns a new instance of Parser.



7
8
9
10
# File 'lib/check_passenger/parser.rb', line 7

def initialize(passenger_status_output)
  @passenger_status_output = passenger_status_output
  parse_passenger_status_output
end

Instance Attribute Details

#max_pool_sizeObject (readonly)

Returns the value of attribute max_pool_size.



5
6
7
# File 'lib/check_passenger/parser.rb', line 5

def max_pool_size
  @max_pool_size
end

#passenger_status_outputObject (readonly)

Returns the value of attribute passenger_status_output.



5
6
7
# File 'lib/check_passenger/parser.rb', line 5

def passenger_status_output
  @passenger_status_output
end

#passenger_versionObject (readonly)

Returns the value of attribute passenger_version.



5
6
7
# File 'lib/check_passenger/parser.rb', line 5

def passenger_version
  @passenger_version
end

Instance Method Details

#application_namesObject



12
13
14
# File 'lib/check_passenger/parser.rb', line 12

def application_names
  @application_data.map { |app_data| app_data[:name] }
end

#live_process_count(app_name = nil) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/check_passenger/parser.rb', line 16

def live_process_count(app_name = nil)
  if app_name
    app_data = application_data(app_name)
    app_data[:live_process_count]
  else
    @application_data.reduce(0) { |a, e| a + e[:live_process_count] }
  end
end

#memory(app_name = nil) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/check_passenger/parser.rb', line 25

def memory(app_name = nil)
  if app_name
    app_data = application_data(app_name)
    app_data[:memory]
  else
    @application_data.reduce(0) { |a, e| a + e[:memory] }
  end
end

#process_count(app_name = nil) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/check_passenger/parser.rb', line 34

def process_count(app_name = nil)
  if app_name
    app_data = application_data(app_name)
    app_data[:process_count]
  else
    @process_count
  end
end

#request_count(app_name = nil) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/check_passenger/parser.rb', line 43

def request_count(app_name = nil)
  if app_name
    app_data = application_data(app_name)
    app_data[:request_count]
  else
    @application_data.reduce(@top_level_request_count) { |a, e| a + e[:request_count] }
  end
end

#top_level_request_count(_ = nil) ⇒ Object



52
53
54
# File 'lib/check_passenger/parser.rb', line 52

def top_level_request_count(_ = nil)
  @top_level_request_count
end