diff options
author | AJ Christensen <aj@junglist.gen.nz> | 2008-07-26 16:50:48 +1200 |
---|---|---|
committer | AJ Christensen <aj@junglist.gen.nz> | 2008-07-26 16:50:48 +1200 |
commit | 971af69b7388cf5155bb124246f2a697578cc6e9 (patch) | |
tree | b3758686574ec820b4394a82e6a2a6997d5546eb /ext | |
parent | aac7dd1cc2da1d90218b54ca06a5703923b63fa9 (diff) | |
download | puppet-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-x | ext/puppetlast | 39 |
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 |