Remove lower limit for API status graph
[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   "301" => "Moved Permanently",
8   "302" => "Found",
9   "303" => "See Other",
10   "304" => "Not Modified",
11   "400" => "Bad Request",
12   "401" => "Unauthorized",
13   "403" => "Forbidden",
14   "404" => "Not Found",
15   "408" => "Request Timeout",
16   "409" => "Conflict",
17   "410" => "Gone",
18   "500" => "Internal Server Error",
19   "509" => "Bandwidth Limit Exceeded"
20 }
21
22 if ARGV[0] == "config"
23   puts "graph_title HTTP response codes"
24   puts "graph_args --base 1000 --logarithmic"
25   puts "graph_vlabel Number of requests per ${graph_period}"
26   puts "graph_category api"
27
28   HTTP_STATUSES.each do |code, label|
29     puts "http#{code}.label #{label}"
30     puts "http#{code}.type DERIVE"
31   end
32 else
33   statistics = JSON.parse(File.read("/srv/www.openstreetmap.org/rails/tmp/statistics.json"))
34
35   HTTP_STATUSES.keys.each do |code|
36     count = statistics["status"][code] || 0
37     puts "http#{code}.value #{count}"
38   end
39 end