summaryrefslogtreecommitdiffstats
path: root/ext/puppetlast
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-18 11:47:40 -0500
committerLuke Kanies <luke@madstop.com>2008-08-18 11:47:40 -0500
commite3971b9751141cd448a8197da024be43581f6dcd (patch)
tree3ae780db3d9dae0a4df10ec24f928bf3a844e749 /ext/puppetlast
parent025edc5c3737f476119df4bab73ebdc68be19430 (diff)
parent2ec4e298c3274abc8eaad4230bca8d39a48d2e35 (diff)
downloadpuppet-e3971b9751141cd448a8197da024be43581f6dcd.tar.gz
puppet-e3971b9751141cd448a8197da024be43581f6dcd.tar.xz
puppet-e3971b9751141cd448a8197da024be43581f6dcd.zip
Merge branch '0.24.x'
Conflicts: CHANGELOG test/util/posixtest.rb
Diffstat (limited to 'ext/puppetlast')
-rwxr-xr-xext/puppetlast37
1 files changed, 6 insertions, 31 deletions
diff --git a/ext/puppetlast b/ext/puppetlast
index e8c2ea1a7..d9b698cfe 100755
--- a/ext/puppetlast
+++ b/ext/puppetlast
@@ -1,40 +1,15 @@
#!/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.
#
-# Script to print out when puppet ran successfully last
-# AJ Christensen <aj@junglist.gen.nz>
+# AJ "Fujin" Christensen <aj@junglist.gen.nz>
#
-
require 'puppet'
-require 'puppet/defaults'
-require 'yaml'
Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config
+Puppet[:name] = "puppetmasterd"
+Puppet::Node::Facts.terminus_class = :yaml
-print "puppetlast\n"
-
-nodes = {}
-
-yfdir = Puppet.settings.value(:vardir) + "/yaml/facts"
-
-if yfdir
- begin
- Dir.chdir(yfdir) do
- Dir.glob("*.yaml").each do |yaml|
- data = YAML.load_file(yaml)
- t = Time.now
- age = t - data.version
- nodes[data.name] = age.to_i
- end
- end
-
- nodes.sort.each do |node,age|
- minutes = age / 60 + 0.5
- print minutes.floor.to_s + ' minutes ago: ' + node + "\n"
- end
-
- rescue
- print 'error: ' + $! + "\n"
- end
-
+Puppet::Node::Facts.search("*").sort.each do |node|
+ puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}checked in #{((Time.now - node.values[:_timestamp]) / 60).floor} minutes ago"
end