dbgrandi (owner)

Forks

Revisions

gist: 108562 Download_button fork
public
Public Clone URL: git://gist.github.com/108562.git
Embed All Files: show embed
Text #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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