forked from barttenbrinke/munin-plugins-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassenger_queue
executable file
·120 lines (93 loc) · 2.53 KB
/
passenger_queue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env ruby
pod=<<-POD
=head1 NAME
passenger_queue - Munin plugin to monitor passenger queue.
Monitors the amount of requests in global queue.
=head1 APPLICABLE SYSTEMS
All systems that have passenger installed.
=head1 CONFIGURATION
The plugin needs to execute passenger-status.
This configuration section shows the defaults of the plugin:
[passenger_*]
user root
command /usr/local/bin/ruby %c
Options
env.passenger_status '/path/to/passenger-status' # Path to passenger-status
env.apache_pid_file '/path/to/apache2.pid' # Path to passenger-status (like /var/run/apache2.pid)
env.graph_category 'App' # Graph Category. Defaults to App.
ln -s /usr/share/munin/plugins/passenger_queue /etc/munin/plugins/passenger_queue
=head1 INTERPRETATION
The plugin shows the current number of requests waiting on global queue.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.9.7
=head1 BUGS
None known
=head1 AUTHOR
Michaël Witrant - http://michael.witrant.com/
Bart ten Brinke - railsdoctors.com
Daniel Manges - http://gist.github.com/20319
=head1 LICENSE
MIT
POD
# Globals
GRAPH_CATEGORY = ENV['graph_category'] || 'App'
PASSENGER_STATUS = ENV['passenger_status'] || '/usr/local/bin/passenger-status'
#to use if you have multiple passenger on the host like phusion passenger standalone
if ENV['apache_pid_file']
PASSENGER_STATUS = "cat #{ENV['apache_pid_file']} | xargs -0 #{PASSENGER_STATUS}"
end
# Check if this plugin can run
def autoconf
begin
require 'rubygems'
gem "passenger", ">=2.0"
rescue Exception => e
puts "no (Gem not found: #{e})"
exit 1
end
status = `#{PASSENGER_STATUS}`
unless $?.success?
puts "no (error whene excuting #{PASSENGER_STATUS})"
exit 1
end
puts "yes"
exit 0
end
# Describe the graph config
def config
status = `#{PASSENGER_STATUS}`
puts <<-CONFIG
graph_category #{GRAPH_CATEGORY}
graph_title Passenger queue
graph_vlabel count
graph_args --base 1000 -l 0
graph_info The amount of requests waiting on global queue
requests.label requests
CONFIG
exit 0
end
# Collect the data
# <tt>debug</tt> Show debug information
def run(debug = false)
status = `#{PASSENGER_STATUS}`
unless $?.success?
$stderr.puts "failed executing passenger-status"
exit 1
end
puts status if debug
status =~ /Waiting on global queue:\s+(\d+)/
puts "requests.value #{$1}"
end
# Main
if ARGV[0] == "config"
config
elsif ARGV[0] == "autoconf"
autoconf
elsif ARGV[0] == "debug"
run(true)
else
run
end