<%= render_file('common/header.html.erb', title: 'Consul Checks') %> <% # This template can be configure the following way with environment variables # Environment variables to filter services/instances # SERVICES_TAG_FILTER: basic tag filter for service (default HTTP) services_tag_filter = ENV['SERVICES_TAG_FILTER'] def status_to_class(status) if status == 'passing' 'success' elsif status == 'warning' 'warning' elsif status == 'critical' 'danger' else 'info' end end %>

Services <%= services_tag_filter ? " tag: #{services_tag_filter}" : 'No filtering' %>

<% all_services.each do |service_name, tags| passing = 0 warning = 0 critical = 0 service_state = 'passing' sum = 0 checks_for_service(service_name).each do |check| st = check['Status'] sum += 1 case st when 'warning' warning += 1 when 'passing' passing += 1 else critical += 1 end end service_state = 'warning' if warning > 0 service_state = 'critical' if critical > 0 %>

Service <%= service_name %> <%= passing > 0 ? passing : nil %> <%= warning > 0 ? warning : nil %> <%= critical > 0 ? critical : nil %>

<% if sum > 0 %>
" class="progress-bar bg-success" role="progressbar" style="width:<%= (100.0 * passing / sum).round(2) %>%" aria-valuenow="<%= passing %>" aria-valuemin="0" aria-valuemax="<%= sum %>">
" class="progress-bar bg-warning" role="progressbar" style="width:<%= (100.0 * warning / sum).round(2) %>%" aria-valuenow="<%= warning %>" aria-valuemin="0" aria-valuemax="<%= sum %>">
" class="progress-bar bg-danger" role="progressbar" style="width:<%= (100.0 * critical / sum).round(2) %>%" aria-valuenow="<%= critical %>" aria-valuemin="0" aria-valuemax="<%= sum %>">
<% end %>
<% checks_for_service(service_name).each do |check| %>
<%= check['Name'] %> / <%= check['Node'] %>
<%= check['Status'] %>

<%= ERB::Util.html_escape(check['Notes']) %>

<%= ERB::Util.html_escape(check['Output']) %>
<% end %>
<% end %>
<%= render_file('common/footer.html.erb') %>