]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/api_calls_status
Fix munin replication plugin to work with osmium based state
[chef.git] / cookbooks / munin / files / default / plugins / api_calls_status
1 #!/usr/bin/ruby
2
3 require "json"
4
5 HTTP_STATUSES = {
6   "200" => "OK",
7   "206" => "Partial Content",
8   "301" => "Moved Permanently",
9   "302" => "Found",
10   "303" => "See Other",
11   "304" => "Not Modified",
12   "400" => "Bad Request",
13   "401" => "Unauthorized",
14   "403" => "Forbidden",
15   "404" => "Not Found",
16   "405" => "Method Not Allowed",
17   "408" => "Request Timeout",
18   "409" => "Conflict",
19   "410" => "Gone",
20   "412" => "Precondition Failed",
21   "416" => "Requested Range Not Satisfiable",
22   "422" => "Unprocessable Entity",
23   "500" => "Internal Server Error",
24   "502" => "Bad Gateway",
25   "503" => "Service Unavailable",
26   "509" => "Bandwidth Limit Exceeded"
27 }.freeze
28
29 if ARGV[0] == "config"
30   puts "graph_title HTTP response codes"
31   puts "graph_args --base 1000"
32   puts "graph_vlabel Number of requests per ${graph_period}"
33   puts "graph_category api"
34
35   HTTP_STATUSES.each do |code, label|
36     puts "http#{code}.label #{code} #{label}"
37     puts "http#{code}.type DERIVE"
38     puts "http#{code}.min 0"
39   end
40 else
41   statistics = JSON.parse(File.read("/srv/www.openstreetmap.org/rails/tmp/statistics.json"))
42
43   HTTP_STATUSES.each_key do |code|
44     count = statistics["status"][code] || 0
45     puts "http#{code}.value #{count}"
46   end
47 end