summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-04-19 21:56:17 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-04-19 21:56:17 +1000
commit82b9f61bdc0f3141b8744b83978e2fe9cd2a710b (patch)
treec6bf370bbb60081f8156ea773ce1364febd20af3 /ext
parenta35450b147c8594d5bcae4facc938fe8143218f7 (diff)
downloadpuppet-82b9f61bdc0f3141b8744b83978e2fe9cd2a710b.tar.gz
puppet-82b9f61bdc0f3141b8744b83978e2fe9cd2a710b.tar.xz
puppet-82b9f61bdc0f3141b8744b83978e2fe9cd2a710b.zip
Added puppetlast script to ext directory
Diffstat (limited to 'ext')
-rwxr-xr-xext/puppetlast40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/puppetlast b/ext/puppetlast
new file mode 100755
index 000000000..e8c2ea1a7
--- /dev/null
+++ b/ext/puppetlast
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#
+# Script to print out when puppet ran successfully last
+# AJ Christensen <aj@junglist.gen.nz>
+#
+
+require 'puppet'
+require 'puppet/defaults'
+require 'yaml'
+
+Puppet[:config] = "/etc/puppet/puppet.conf"
+Puppet.parse_config
+
+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
+
+end