<% # 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) require 'base64' require 'json' require 'date' 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 def compute_node_status(snode) state = 'passing' return state unless snode['Checks'] snode['Checks'].each do |c| case c['Status'] when 'critical' return 'critical' when 'warning' state = 'warning' end end state end def compute_service_status(snodes) passing = 0 warning = 0 critical = 0 sum = 0 snodes.each do |snode| st = compute_node_status(snode) sum += 1 case st when 'passing' passing += 1 when 'warning' warning += 1 else critical += 1 end end [passing, warning, critical, sum] end %><%= render_file('common/header.html.erb', title: 'Services') %>

List of all datacenters

    <% datacenters.each do |dc| %>
  • <%= dc %> with <%= services(dc:dc).keys.count %> services, <%= nodes(dc:dc).count %> nodes
  • <% end %>

List all services instances sorted by node name

<% services.each do |service_name, tags| service_group = service(service_name) nodes_sorted = service_group.sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] } passing, warning, critical, sum = compute_service_status(nodes_sorted) service_state = 'passing' service_state = 'warning' if warning > 0 service_state = 'critical' if critical > 0 %>

<%= service_name %>🔗

<% 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 %>
<% nodes_sorted.each do |snode| tags = snode['Service']['Tags'].sort addr = snode['Node']['Address'] port_num = snode['Service']['Port'].to_i port = port_num && port_num > 0 ? ":#{port_num}" : '' url = if tags.include? 'https' "https://#{addr}#{port}" elsif tags.include? 'http' "http://#{addr}#{port}" elsif tags.include? 'ftp' "ftp://#{addr}#{port}" else nil end %>
><%= snode['Node']['Node'] %><%= port %> <% snode['Service']['Tags'].sort.each do |t| %><%= t %><% end %> <% snode['Checks'].each do |c| %> <%= c['Status'] %><% end if snode['Checks'] %>
<% end %>
<% end %>
<%= render_file 'common/footer.html.erb' %>