]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_requests
Make nftables block various invalid TCP flag combinations
[chef.git] / cookbooks / munin / files / default / plugins / passenger_requests
1 #!/usr/bin/env ruby
2
3 require "English"
4 require "rexml/document"
5
6 def passenger_status
7   @passenger_status ||= REXML::Document.new(`/usr/sbin/passenger-status --show=xml`)
8 end
9
10 def output_config
11   puts <<~CONFIG
12     graph_args --base 1000 --lower-limit 0
13     graph_category passenger
14     graph_title Passenger requests
15     graph_vlabel requests / ${graph_period}
16
17     total.label total
18     total.type DERIVE
19     total.max 1000000
20     total.min 0
21   CONFIG
22
23   groups = passenger_status.get_elements("//supergroup").map do |supergroup|
24     supergroup.text("name")
25   end
26
27   groups.sort.each do |name|
28     puts "#{name}.label #{name}"
29     puts "#{name}.type DERIVE"
30     puts "#{name}.max 1000000"
31     puts "#{name}.min 0"
32   end
33 end
34
35 def output_values
36   total_requests = 0
37
38   passenger_status.get_elements("//supergroup").map do |supergroup|
39     name = supergroup.text("name")
40     requests = 0
41
42     supergroup.get_elements("group/processes/process").each do |process|
43       requests += process.text("processed").to_i
44     end
45
46     total_requests += requests
47
48     puts "#{name}.value #{requests}"
49   end
50
51   puts "total.value #{total_requests}"
52 end
53
54 if ARGV[0] == "config"
55   output_config
56 else
57   output_values
58 end