Skip to content

Instantly share code, notes, and snippets.

@dbgrandi
Created May 8, 2009 02:13
Show Gist options
  • Save dbgrandi/108562 to your computer and use it in GitHub Desktop.
Save dbgrandi/108562 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment