Sha256: 931302778a13ae0cce80b7cc571f0ccf88014a99a985873ad995a9262cfac0af
Contents?: true
Size: 1.42 KB
Versions: 63
Compression:
Stored size: 1.42 KB
Contents
<% require 'base64' require 'json' require 'date' @current_time = Time.now.utc def display_holder(holder, value) begin holder_date = Time.parse(value) status = 'success' diff = (@current_time - holder_date).round(0) status = 'warning' if diff > 3600 status = 'danger' if diff > 7200 diff_txt = "#{diff % 3600} seconds" diff_txt = "#{(diff % 86400) / 3600} hours, #{diff_txt}" if diff > 3600 diff_txt = "#{diff / 86400} days, #{diff_txt}" if diff > 86400 rescue StandardError => e status = 'info' holder_date = "Cannot parse date: #{e}" diff_txt = "Error Parsing date #{value}" end [holder, holder_date, "#{diff_txt} ago", status] end datacenters.each do |dc| kv('choregraphie', dc:dc, recurse:true).each do |tuple| ckey = tuple['Key'].gsub('/', '-') if tuple['Value'].nil? json = [] holders = [] else json = JSON.parse(Base64.decode64(tuple['Value'])) holders = json['holders'] end if holders.count > 0 holders.each_pair do |key,value| if value.is_a?(Hash) value.each_pair do |k, v| host, holder_date, diff_txt, status = display_holder(k, v) end else host, holder_date, diff_txt, status = display_holder(key, value) end %><%= "#{host} ; #{dc} ; #{holder_date} ; #{status} ; #{ckey} ; #{diff_txt}" %> <% end end end end %>
Version data entries
63 entries across 63 versions & 1 rubygems