root / plugins / passenger / passenger_status @ b0b39b01
Historique | Voir | Annoter | Télécharger (1,47 ko)
| 1 |
#!/usr/bin/env ruby |
|---|---|
| 2 |
|
| 3 |
def output_config |
| 4 |
puts <<~END |
| 5 |
graph_category webserver |
| 6 |
graph_title status |
| 7 |
graph_vlabel count |
| 8 |
graph_info This graph shows how much passenger process are working, available and how much queries are waiting. |
| 9 |
max.label max processes |
| 10 |
max.draw AREA |
| 11 |
max.info Maximum processes allowed to run simultaneously. |
| 12 |
sessions.label queued requests |
| 13 |
sessions.draw LINE2 |
| 14 |
sessions.info Requests queued, waiting to be processed. |
| 15 |
running.label running processes |
| 16 |
running.draw LINE1 |
| 17 |
running.info The number of application instances that are currently alive. |
| 18 |
active.label active processes |
| 19 |
active.draw LINE1 |
| 20 |
active.info The number of application instances that are currently processing requests. |
| 21 |
waiting.label waiting requests |
| 22 |
waiting.draw LINE2 |
| 23 |
waiting.info Requests waiting to be queued. |
| 24 |
END |
| 25 |
exit 0 |
| 26 |
end |
| 27 |
|
| 28 |
def output_values |
| 29 |
status = `sudo passenger-status` |
| 30 |
unless $?.success? |
| 31 |
$stderr.puts "failed executing passenger-status" |
| 32 |
exit 1 |
| 33 |
end |
| 34 |
status =~ /max\s+=\s+(\d+)/ |
| 35 |
puts "max.value #{$1}"
|
| 36 |
|
| 37 |
status =~ /count\s+=\s+(\d+)/ |
| 38 |
puts "running.value #{$1}"
|
| 39 |
|
| 40 |
status =~ /active\s+=\s+(\d+)/ |
| 41 |
puts "active.value #{$1}"
|
| 42 |
|
| 43 |
status =~ /Waiting on global queue:\s+(\d+)/ |
| 44 |
puts "waiting.value #{$1}"
|
| 45 |
|
| 46 |
total_sessions = 0 |
| 47 |
status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i }
|
| 48 |
puts "sessions.value #{total_sessions}"
|
| 49 |
end |
| 50 |
|
| 51 |
if ARGV[0] == "config" |
| 52 |
output_config |
| 53 |
else |
| 54 |
output_values |
| 55 |
end |
