#!/usr/bin/ruby files = [ { :label => "planet", :name => "/store/planet/planet/planet-latest.osm.bz2", :title => "Planet Dump", :frequency => 7 * 24 * 60 * 60, :warning => 1.05, :critical => 1.1 }, { :label => "day", :name => "/store/planet/replication/day/state.txt", :title => "Daily Replication", :frequency => 24 * 60 * 60, :warning => 1.05, :critical => 1.1 }, { :label => "hour", :name => "/store/planet/replication/hour/state.txt", :title => "Hourly Replication", :frequency => 60 * 60, :warning => 1.05, :critical => 1.1 }, { :label => "minute", :name => "/store/planet/replication/minute/state.txt", :title => "Minutely Replication", :frequency => 60, :warning => 5, :critical => 10 } ] 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:#{file[:warning]}" puts "#{file[:label]}.critical 0:#{file[:critical]}" end else files.each do |file| value = (Time.now - File.mtime(file[:name])) / file[:frequency] puts "#{file[:label]}.value #{value}" end end