summaryrefslogtreecommitdiff
path: root/files/master/puppetlast
blob: 99a760efb8bd645cb6f44a5541d07b5620b910a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby
# Puppetlast, a script to output the last check-in time of nodes. Also outputs the cached configuration state, if expired or not.
#
# AJ "Fujin" Christensen <aj@junglist.gen.nz>
# changed by admin+puppet(at)immerda.ch to fit our needs
#
require 'puppet'

Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config
Puppet[:name] = "puppetmasterd"
Puppet::Node::Facts.terminus_class = :yaml

Puppet::Node::Facts.search("*").sort { |a,b| a.name <=> b.name }.each do |node|
    puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}last checked #{((Time.now - node.values[:_timestamp]) / 60).floor} minutes ago" if (((Time.now - node.values[:_timestamp]) / 60).floor > 60 or (not ARGV[0].nil? and ARGV[0].to_s == '--all'))
end