Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / passenger / passenger_status @ b0b39b01

Historique | Voir | Annoter | Télécharger (1,47 ko)

1 0ddf1ea4 Fabien Jakimowicz
#!/usr/bin/env ruby
2 17f78427 Lars Kruse
3 0ddf1ea4 Fabien Jakimowicz
def output_config
4 b0b39b01 Lars Kruse
  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 0ddf1ea4 Fabien Jakimowicz
  exit 0
26
end
27 17f78427 Lars Kruse
28 0ddf1ea4 Fabien Jakimowicz
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 17f78427 Lars Kruse
37 0ddf1ea4 Fabien Jakimowicz
  status =~ /count\s+=\s+(\d+)/
38
  puts "running.value #{$1}"
39 17f78427 Lars Kruse
40 0ddf1ea4 Fabien Jakimowicz
  status =~ /active\s+=\s+(\d+)/
41
  puts "active.value #{$1}"
42 17f78427 Lars Kruse
43 0ddf1ea4 Fabien Jakimowicz
  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 17f78427 Lars Kruse
51 0ddf1ea4 Fabien Jakimowicz
if ARGV[0] == "config"
52
  output_config
53
else
54
  output_values
55 63351ab5 dipohl
end