]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/api_calls_num
Make replication delay monitoring more reliable
[chef.git] / cookbooks / munin / files / default / plugins / api_calls_num
1 #!/usr/bin/ruby
2
3 require "json"
4
5 CALL_TYPES = {
6   :map => "Map API calls",
7   :upload => "Changeset diff uploads",
8   :amf => "AMF API calls",
9   :history => "Element history fetches",
10   :full => "Full element fetches",
11   :trkpts => "GPX trackpoints calls",
12   :web => "Web site traffic",
13   :other => "Other API calls"
14 }.freeze
15
16 if ARGV[0] == "config"
17   puts "graph_title Requests processed"
18   puts "graph_args --base 1000"
19   puts "graph_vlabel Number of requests per ${graph_period}"
20   puts "graph_category api"
21
22   CALL_TYPES.each do |type, label|
23     puts "#{type}.label #{label}"
24     puts "#{type}.type DERIVE"
25     puts "#{type}.min 0"
26   end
27 else
28   statistics = JSON.parse(File.read("/srv/www.openstreetmap.org/rails/tmp/statistics.json"))
29
30   CALL_TYPES.each_key do |type|
31     count = statistics["uri"][type.to_s] || 0
32     puts "#{type}.value #{count}"
33   end
34 end