-
Notifications
You must be signed in to change notification settings - Fork 29
/
consul_template.html.erb
94 lines (89 loc) · 2.59 KB
/
consul_template.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="refresh" content="300"/>
<title>Consul Full Info</title>
<style>
.passing {
color:green;
}
.warning {
color: orange;
}
.critical {
color: red;
}
.qlink {
text-decoration: none;
}
</style>
</head>
<body>
<% require 'base64'
require 'json'
require 'date'
%>
<nav>
<ul>
<li><a href="#datacenters">DataCenters</a></li>
<li><a href="#list_services">List of services</a></li>
<li><a href="#services">Services with instances</a></li>
<li><a href="#nodes">All Nodes</a></li>
<li><a href="#kv">Key/Value Store</a></li>
</ul>
</nav>
<h1 id="datacenters">List of all datacenters</h1>
<ul>
<% datacenters.each do |dc| %>
<li id="dc_<%=dc %>%"><%= dc %> with <%= services(dc:dc).keys.count %> services, <%= nodes(dc:dc).count %> nodes</li>
<% end %>
</ul>
<h1 id="list_services">List of all services in current DC</h1>
<ul>
<% services.each do |service_name, tags|
%>
<li><a href="#service_<%= service_name %>"><%= service_name %></a> <%= tags.sort %></li>
<% end %>
</ul>
<h1 id="services">List all services instances sorted by node name</h1>
<% services.each do |service_name, tags|
%><h2 id="service_<%= service_name %>" title="<%= tags.join(', ') %>"><%= service_name %> <a class="qlink" href="#service_<%= service_name %>">🔗</a></h2>
<ul>
<% service(service_name).sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
tags = snode['Service']['Tags'].sort
addr = snode.service_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
%><li><a <%= url ? "href=\"#{url}\"" : nil %>><%=
snode['Node']['Node'] %><%= port %></a>
<span class="tags"><%= snode['Service']['Tags'].sort %></span>
<span class="statuses"><%
snode['Checks'].each do |c| %> <span title="<%= c['Name']%>" class="<%= c['Status'] %>"><%= c['Status']
%></span><% end if snode['Checks'] %></span></li>
<% end%>
</ul>
<% end%>
<h1 id="nodes">List all nodes for DC, sorted by name</h1>
<ul>
<% nodes.sort {|a,b| a['Node'] <=> b['Node'] }.each do |snode|
%> <li id="node_<%= snode['ID'] %>"><%= snode['Address'].ljust(16) %> <%= snode['Node'] %></li>
<% end %>
</ul>
<h1 id="kv">KV of Current DC</h1>
<ul>
<% kv(keys:true).each do |key|
%><li id="kv_<%= key %>"><%= key %></li>
<% end %>
</ul>
</body>
</html>