Did you know that every time the chef-client
runs, it knows what time it is, and it stores that value as a node attribute, ohai_time
? Did you know that you can use this value for searching a Chef Infra Server? It's a Unix Epoch!
For example, let's look for the nodes that were updated in the last 10-15 minutes:
now=$(date +%s)
range_start=$(expr $now - 900)
range_end=$(expr $now - 600)
knife search node "ohai_time:[$range_start TO $range_end]" -a ohai_time -F json