#!/usr/bin/env ruby # # Throw this into a cron job to notify us when our chef clients # have gone AWOL. # # dave@wegoto12.com # require 'rubygems' require 'chef' require 'ruby-units' @hour_ago = "1 hour".before Chef::Config.from_file("/etc/chef/client.rb") rs = Chef::CouchDB.new.list("nodes", true) rows = rs["rows"].collect { |r| r["value"] } rows.each do |r| @last_seen = Time.at(r.ohai_time) if @last_seen < @hour_ago puts "#{r.name} has not checked in with Chef in since #{@last_seen}" end end