Created
October 31, 2012 20:43
-
-
Save cjs226/3989743 to your computer and use it in GitHub Desktop.
Using Chef to determine the system with role www that's been up the longest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
old_node = "x" | |
old_bod = 9999999999 | |
search(:node, "role:www") do |matching_node| | |
bod = "#{matching_node['ohai_time']}".to_i - "#{matching_node['uptime_seconds']}".to_i | |
if bod < old_bod | |
old_node = matching_node | |
old_bod = bod | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment