summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorAJ Christensen <aj@junglist.gen.nz>2008-07-26 16:50:48 +1200
committerAJ Christensen <aj@junglist.gen.nz>2008-07-26 16:50:48 +1200
commit971af69b7388cf5155bb124246f2a697578cc6e9 (patch)
treeb3758686574ec820b4394a82e6a2a6997d5546eb /ext
parentaac7dd1cc2da1d90218b54ca06a5703923b63fa9 (diff)
downloadpuppet-971af69b7388cf5155bb124246f2a697578cc6e9.tar.gz
puppet-971af69b7388cf5155bb124246f2a697578cc6e9.tar.xz
puppet-971af69b7388cf5155bb124246f2a697578cc6e9.zip
Fixing puppetlast to make it work with 0.24.5 / 0.25.
Tidied up some of the code a little
Diffstat (limited to 'ext')
-rwxr-xr-xext/puppetlast39
1 files changed, 17 insertions, 22 deletions
diff --git a/ext/puppetlast b/ext/puppetlast
index e8c2ea1a7..c77d1ba73 100755
--- a/ext/puppetlast
+++ b/ext/puppetlast
@@ -15,26 +15,21 @@ 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
-
+factsdir = Puppet.settings.value(:vardir) + "/yaml/facts"
+
+begin
+ Dir.chdir(factsdir) if File.exists?(factsdir)
+ Dir.glob("*.yaml").each do |yaml|
+ data = YAML.load_file(yaml)
+ age = Time.now - data.values[:_timestamp]
+ nodes[data.name] = age.to_i
+ end
+
+ nodes.sort.each do |node,age|
+ minutes = age / 60
+ puts minutes.floor.to_s + ' minutes ago: ' + node
+ end
+
+rescue
+ puts 'error: ' + $!
end