blob: 0f6c0ccf32569a895abea16783e6cc5bb1c1474d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/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'
require 'time'
Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config
Puppet[:name] = "puppetmasterd"
Puppet::Node::Facts.terminus_class = :yaml
all = false
timeout = 120
ARGV.each do |arg|
if arg.to_s == '--all'
all = true
else
timeout = arg.to_i
end
end
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 - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago" if (((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor > timeout or all)
end
|