+#!/usr/bin/ruby
+
+require "json"
+
+nodes = JSON.parse(IO.popen(["knife", "status", "-c", "/var/lib/chef/.chef/knife.rb", "-F", "json"]).read).sort_by { |node| node["name"] }
+
+if ARGV[0] == "config"
+ puts "graph_title Chef node status"
+ puts "graph_args --base 1000 --logarithmic"
+ puts "graph_vlabel Time since last checkin"
+ puts "graph_category chef"
+
+ nodes.each do |node|
+ name = node["name"].split(".").first
+
+ puts "#{name}.label #{name}"
+ puts "#{name}.type GAUGE"
+ puts "#{name}.min 0"
+ puts "#{name}.warning 14400"
+ puts "#{name}.critical 43200"
+ end
+else
+ nodes.each do |node|
+ name = node["name"].split(".").first
+ time = Time.now.to_f - node["ohai_time"]
+
+ puts "#{name}.value #{time}"
+ end
+end