summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-08-01 06:59:23 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-08-01 06:59:23 +1000
commit482489ad21e20ee3275185962f76c6a0c9a88328 (patch)
tree00a2fe6cfaff50374b6107b5e7862b74afe4d4c4 /ext
parent0bbac8dda9342b28782ae1218cdb891f5a5bfa54 (diff)
downloadpuppet-482489ad21e20ee3275185962f76c6a0c9a88328.tar.gz
puppet-482489ad21e20ee3275185962f76c6a0c9a88328.tar.xz
puppet-482489ad21e20ee3275185962f76c6a0c9a88328.zip
Revert "Fixing puppetlast to make it work with 0.24.5 / 0.25."
This reverts commit 971af69b7388cf5155bb124246f2a697578cc6e9.
Diffstat (limited to 'ext')
-rwxr-xr-xext/puppetlast39
1 files changed, 22 insertions, 17 deletions
diff --git a/ext/puppetlast b/ext/puppetlast
index c77d1ba73..e8c2ea1a7 100755
--- a/ext/puppetlast
+++ b/ext/puppetlast
@@ -15,21 +15,26 @@ print "puppetlast\n"
nodes = {}
-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: ' + $!
+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