From 7df4eabf27357731cbdf6946591df92ac15e8ed2 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 7 Aug 2010 01:31:17 +0200 Subject: improve checklastrun script --- files/master/puppetlast | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'files') diff --git a/files/master/puppetlast b/files/master/puppetlast index 752d6ca..0f6c0cc 100644 --- a/files/master/puppetlast +++ b/files/master/puppetlast @@ -12,6 +12,16 @@ Puppet.parse_config Puppet[:name] = "puppetmasterd" Puppet::Node::Facts.terminus_class = :yaml +all = false +timeout = 120 +ARGV.each do |arg| + if arg.to_s == '--all' + all = true + else + timeout = arg.to_i + end +end + Puppet::Node::Facts.search("*").sort { |a,b| a.name <=> b.name }.each do |node| - puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}last checked #{((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago" if (((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor > 120 or (not ARGV[0].nil? and ARGV[0].to_s == '--all')) + puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}last checked #{((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago" if (((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor > timeout or all) end -- cgit v1.2.3