From c5b3cd666d9433fd724aabf3552a069044dac14b Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Thu, 12 Jul 2012 11:47:21 -0700 Subject: [PATCH] improve readability for puppetd agent lastrun action --- agent/puppetd/agent/puppetd.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/puppetd/agent/puppetd.rb b/agent/puppetd/agent/puppetd.rb index 1c622ed..77f3c78 100644 --- a/agent/puppetd/agent/puppetd.rb +++ b/agent/puppetd/agent/puppetd.rb @@ -73,7 +73,14 @@ def set_status reply[:stopped] = reply[:status] == 'stopped' ? 1 : 0 reply[:lastrun] = 0 reply[:lastrun] = File.stat(@statefile).mtime.to_i if File.exists?(@statefile) - reply[:output] = "Currently #{reply[:status]}; last completed run #{Time.now.to_i - reply[:lastrun]} seconds ago" + diff = Time.now.to_i - reply[:lastrun] + if diff < 60 + reply[:output] = "Currently #{reply[:status]}; last completed run #{diff} seconds ago" + elsif diff > 60 && diff < 3600 + reply[:output] = "Currently #{reply[:status]}; last completed run #{diff/60} minutes ago" + else + reply[:output] = "Currently #{reply[:status]}; last completed run #{diff/3600} hours ago" + end end def puppet_daemon_status