]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/planet_age
a3f37093fb3c2a85499d38ab4b340e793b649400
[chef.git] / cookbooks / munin / files / default / plugins / planet_age
1 #!/usr/bin/ruby
2
3 files = [
4   {
5     :label => "planet",
6     :name => "/store/planet/planet/planet-latest.osm.bz2",
7     :title => "Planet Dump",
8     :frequency => 7 * 24 * 60 * 60,
9     :warning => 1.05,
10     :critical => 1.1
11   },
12   {
13     :label => "day",
14     :name => "/store/planet/replication/day/state.txt",
15     :title => "Daily Replication",
16     :frequency => 24 * 60 * 60,
17     :warning => 1.05,
18     :critical => 1.1
19   },
20   {
21     :label => "hour",
22     :name => "/store/planet/replication/hour/state.txt",
23     :title => "Hourly Replication",
24     :frequency => 60 * 60,
25     :warning => 1.05,
26     :critical => 1.1
27   },
28   {
29     :label => "minute",
30     :name => "/store/planet/replication/minute/state.txt",
31     :title => "Minutely Replication",
32     :frequency => 60,
33     :warning => 3,
34     :critical => 5
35   }
36 ]
37
38 if ARGV[0] == "config"
39   puts "graph_title Planet Age"
40   puts "graph_args --base 1000 --lower-limit 0"
41   puts "graph_scale no"
42   puts "graph_vlabel fraction of expected max age"
43   puts "graph_category planet"
44
45   files.each do |file|
46     puts "#{file[:label]}.label #{file[:title]}"
47     puts "#{file[:label]}.type GAUGE"
48     puts "#{file[:label]}.warning 0:#{file[:warning]}"
49     puts "#{file[:label]}.critical 0:#{file[:critical]}"
50   end
51 else
52
53   files.each do |file|
54     value = (Time.now - File.mtime(file[:name])) / file[:frequency]
55
56     puts "#{file[:label]}.value #{value}"
57   end
58 end