check_passenger 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/TODO.md +12 -0
- data/bin/check_passenger +101 -0
- data/check_passenger.gemspec +29 -0
- data/lib/check_passenger.rb +13 -0
- data/lib/check_passenger/check.rb +96 -0
- data/lib/check_passenger/nagios_check.rb +66 -0
- data/lib/check_passenger/parser.rb +120 -0
- data/lib/check_passenger/passenger_status.rb +29 -0
- data/lib/check_passenger/status_output_error.rb +10 -0
- data/lib/check_passenger/version.rb +3 -0
- data/test/passenger-status +82 -0
- data/test/sample_output_1.txt +76 -0
- data/test/sample_output_2.txt +64 -0
- data/test/test_check.rb +122 -0
- data/test/test_helper.rb +9 -0
- data/test/test_nagios_check.rb +72 -0
- data/test/test_parser.rb +166 -0
- data/test/test_passenger_status.rb +32 -0
- metadata +158 -0
data/test/test_parser.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe CheckPassenger::Parser do
|
4
|
+
describe 'minimum data processing' do
|
5
|
+
before do
|
6
|
+
@sample_output = <<-HEREDOC
|
7
|
+
Version : 4.0.46
|
8
|
+
Date : 2014-09-11 00:57:57 +0200
|
9
|
+
Instance: 32028
|
10
|
+
----------- General information -----------
|
11
|
+
Max pool size : 40
|
12
|
+
Processes : 26
|
13
|
+
Requests in top-level queue : 0
|
14
|
+
|
15
|
+
----------- Application groups -----------
|
16
|
+
HEREDOC
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'correctly handles process life' do
|
20
|
+
begin
|
21
|
+
parser = CheckPassenger::Parser.new(@sample_output)
|
22
|
+
rescue Exception => e
|
23
|
+
assert false, 'Exception %s raised with message: %s' % [e.class.to_s, e.to_s]
|
24
|
+
end
|
25
|
+
|
26
|
+
last_used = '23x 4d 5h 4s'
|
27
|
+
assert_raises CheckPassenger::StatusOutputError do
|
28
|
+
parser.send(:'is_process_alive?', last_used)
|
29
|
+
end
|
30
|
+
|
31
|
+
last_used = '4d 5h 4s'
|
32
|
+
|
33
|
+
begin
|
34
|
+
life_in_seconds = parser.send(:life_to_seconds, last_used)
|
35
|
+
rescue Exception => e
|
36
|
+
assert false, 'Exception %s raised with message: %s' % [e.class.to_s, e.to_s]
|
37
|
+
end
|
38
|
+
assert_equal 363_604, life_in_seconds
|
39
|
+
|
40
|
+
refute parser.send(:'is_process_alive?', last_used)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'correctly parses max pool size' do
|
44
|
+
parser = CheckPassenger::Parser.new(@sample_output)
|
45
|
+
assert_equal 40, parser.max_pool_size
|
46
|
+
|
47
|
+
sample_output = @sample_output.gsub('Max pool size : 40', 'Max pool size : b40')
|
48
|
+
assert_raises CheckPassenger::StatusOutputError do
|
49
|
+
parser = CheckPassenger::Parser.new(sample_output)
|
50
|
+
end
|
51
|
+
|
52
|
+
sample_output = @sample_output.gsub('Max pool size : 40', '')
|
53
|
+
assert_raises CheckPassenger::StatusOutputError do
|
54
|
+
parser = CheckPassenger::Parser.new(sample_output)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'gets Passenger version' do
|
59
|
+
parser = CheckPassenger::Parser.new(@sample_output)
|
60
|
+
assert_respond_to parser, :passenger_version
|
61
|
+
assert_equal '4.0.46', parser.passenger_version
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'sample output 1' do
|
66
|
+
before do
|
67
|
+
output = File.read(File.expand_path('sample_output_1.txt', File.dirname(__FILE__)))
|
68
|
+
@parser = CheckPassenger::Parser.new(output)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'finds the names of the applications' do
|
72
|
+
refute_empty @parser.application_names
|
73
|
+
assert_equal 4, @parser.application_names.size
|
74
|
+
assert_includes @parser.application_names, '/home/application_3/Site'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'reports the maximum number of processes' do
|
78
|
+
refute_nil @parser.max_pool_size
|
79
|
+
assert_equal 40, @parser.max_pool_size
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'for all applications' do
|
83
|
+
it 'reports all memory used' do
|
84
|
+
refute @parser.memory.nil?
|
85
|
+
assert @parser.memory > 0
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'reports the total count of processes' do
|
89
|
+
assert_equal 26, @parser.process_count
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'reports the number of live processes' do
|
93
|
+
assert_equal 9, @parser.live_process_count
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'for a specific application' do
|
98
|
+
it 'reports memory used' do
|
99
|
+
assert_equal 65, @parser.memory('application_2')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'reports the process count' do
|
103
|
+
assert_equal 12, @parser.process_count('application_1')
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'reports the live process count' do
|
107
|
+
assert_equal 3, @parser.live_process_count('application_1')
|
108
|
+
assert_equal 4, @parser.live_process_count('application_4')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'raises exception if term matches multiple apps' do
|
112
|
+
assert_raises ArgumentError do
|
113
|
+
@parser.memory('application')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'sample output 2' do
|
120
|
+
before do
|
121
|
+
output = File.read(File.expand_path('sample_output_2.txt', File.dirname(__FILE__)))
|
122
|
+
@parser = CheckPassenger::Parser.new(output)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'finds the names of the applications' do
|
126
|
+
refute_empty @parser.application_names
|
127
|
+
assert_equal 3, @parser.application_names.size
|
128
|
+
assert_includes @parser.application_names, '/home/application_2/Site'
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'reports the maximum number of processes' do
|
132
|
+
refute_nil @parser.max_pool_size
|
133
|
+
assert_equal 40, @parser.max_pool_size
|
134
|
+
end
|
135
|
+
|
136
|
+
describe 'for all applications' do
|
137
|
+
it 'reports all memory used' do
|
138
|
+
refute @parser.memory.nil?
|
139
|
+
assert @parser.memory > 0
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'reports the total count of processes' do
|
143
|
+
assert_equal 22, @parser.process_count
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'reports the number of live processes' do
|
147
|
+
assert_equal 7, @parser.live_process_count
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe 'for a specific application' do
|
152
|
+
it 'reports memory used' do
|
153
|
+
assert_equal 2935, @parser.memory('application_3')
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'reports the process count' do
|
157
|
+
assert_equal 4, @parser.process_count('application_2')
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'reports the live process count' do
|
161
|
+
assert_equal 4, @parser.live_process_count('application_1')
|
162
|
+
assert_equal 0, @parser.live_process_count('application_2')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe CheckPassenger::PassengerStatus do
|
4
|
+
it 'raises an exception when cannot find the executable' do
|
5
|
+
CheckPassenger::PassengerStatus.path = '/tmp'
|
6
|
+
assert_raises Errno::ENOENT do
|
7
|
+
CheckPassenger::PassengerStatus.run
|
8
|
+
end
|
9
|
+
|
10
|
+
CheckPassenger::PassengerStatus.path = '/tmp/passenger-status'
|
11
|
+
assert_raises Errno::ENOENT do
|
12
|
+
CheckPassenger::PassengerStatus.run
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'can find the executable in a directory' do
|
17
|
+
CheckPassenger::PassengerStatus.path = File.dirname(__FILE__)
|
18
|
+
begin
|
19
|
+
output = CheckPassenger::PassengerStatus.run
|
20
|
+
rescue Exception => e
|
21
|
+
assert false, e.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns passenger-status output' do
|
26
|
+
CheckPassenger::PassengerStatus.path = File.expand_path('passenger-status', File.dirname(__FILE__))
|
27
|
+
output = CheckPassenger::PassengerStatus.run
|
28
|
+
assert_includes output, 'Version'
|
29
|
+
assert_includes output, 'App root'
|
30
|
+
assert_includes output, 'Requests in queue'
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_passenger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alvaro Redondo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: minitest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: minitest-reporters
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: thor
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.19.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.19.1
|
94
|
+
description:
|
95
|
+
email:
|
96
|
+
- alvaro@redondo.name
|
97
|
+
executables:
|
98
|
+
- check_passenger
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- .gitignore
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- TODO.md
|
108
|
+
- bin/check_passenger
|
109
|
+
- check_passenger.gemspec
|
110
|
+
- lib/check_passenger.rb
|
111
|
+
- lib/check_passenger/check.rb
|
112
|
+
- lib/check_passenger/nagios_check.rb
|
113
|
+
- lib/check_passenger/parser.rb
|
114
|
+
- lib/check_passenger/passenger_status.rb
|
115
|
+
- lib/check_passenger/status_output_error.rb
|
116
|
+
- lib/check_passenger/version.rb
|
117
|
+
- test/passenger-status
|
118
|
+
- test/sample_output_1.txt
|
119
|
+
- test/sample_output_2.txt
|
120
|
+
- test/test_check.rb
|
121
|
+
- test/test_helper.rb
|
122
|
+
- test/test_nagios_check.rb
|
123
|
+
- test/test_parser.rb
|
124
|
+
- test/test_passenger_status.rb
|
125
|
+
homepage: ''
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.8.29
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: Nagios check to monitor Passenger processes and memory
|
150
|
+
test_files:
|
151
|
+
- test/passenger-status
|
152
|
+
- test/sample_output_1.txt
|
153
|
+
- test/sample_output_2.txt
|
154
|
+
- test/test_check.rb
|
155
|
+
- test/test_helper.rb
|
156
|
+
- test/test_nagios_check.rb
|
157
|
+
- test/test_parser.rb
|
158
|
+
- test/test_passenger_status.rb
|