Add a munin plugin to monitor the planet dumps and replication
authorTom Hughes <tom@compton.nu>
Tue, 17 Feb 2015 10:01:56 +0000 (10:01 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 17 Feb 2015 10:03:25 +0000 (10:03 +0000)
cookbooks/munin/files/default/plugins/planet_age [new file with mode: 0755]
cookbooks/planet/metadata.rb
cookbooks/planet/recipes/default.rb

diff --git a/cookbooks/munin/files/default/plugins/planet_age b/cookbooks/munin/files/default/plugins/planet_age
new file mode 100755 (executable)
index 0000000..3fb0def
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/ruby
+
+files = [
+  {
+    :label => "planet",
+    :name => "/store/planet/planet/planet-latest.osm.bz2",
+    :title => "Planet Dump",
+    :frequency => 7 * 24 * 60 * 60
+  },
+  {
+    :label => "day",
+    :name => "/store/planet/replication/day/state.txt",
+    :title => "Daily Replication",
+    :frequency => 24 * 60 * 60
+  },
+  {
+    :label => "hour",
+    :name => "/store/planet/replication/hour/state.txt",
+    :title => "Hourly Replication",
+    :frequency => 60 * 60
+  },
+  {
+    :label => "minute",
+    :name => "/store/planet/replication/minute/state.txt",
+    :title => "Minutely Replication",
+    :frequency => 60
+  }
+]
+
+if ARGV[0] == "config"
+  puts "graph_title Planet Age"
+  puts "graph_args --base 1000 --lower-limit 0"
+  puts "graph_scale no"
+  puts "graph_vlabel fraction of expected max age"
+  puts "graph_category planet"
+
+  files.each do |file|
+    puts "#{file[:label]}.label #{file[:title]}"
+    puts "#{file[:label]}.type GAUGE"
+    puts "#{file[:label]}.warning 0:1.05"
+    puts "#{file[:label]}.critical 0:1.1"
+  end
+else
+
+  files.each do |file|
+    value = (Time.now - File.mtime(file[:name])) / file[:frequency]
+
+    puts "#{file[:label]}.value #{value}"
+  end
+end
index 3e2f5f3cb709e985a74de6607fa4645fddaf0732..c84c69023686e6add363cc63b3790ff3fe5abca9 100644 (file)
@@ -9,3 +9,4 @@ depends           "apache"
 depends           "git"
 depends           "osmosis"
 depends           "incron"
+depends           "munin"
index 4938936fa7307186ecd3ad14db619340f6363b8e..a7bc0002270e3a54e1d56ef5026e7c4da6bcb826 100644 (file)
@@ -89,3 +89,5 @@ template "/etc/logrotate.d/apache2" do
   group "root"
   mode 0644
 end
+
+munin_plugin "planet_age"