Skip to content

Instantly share code, notes, and snippets.

@cjs226
Created October 31, 2012 20:43
Show Gist options
  • Save cjs226/3989743 to your computer and use it in GitHub Desktop.
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
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