Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

improve readability for puppetd agent lastrun action #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion agent/puppetd/agent/puppetd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down