openvpn-status-web/lib/openvpn-status-web/main.html.erb

144 lines
2.7 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="60">
<title>OpenVPN Status</title>
<style type="text/css">
table {
border-collapse: collapse;
}
h1 {
font-size: 24px;
}
h2 {
font-size: 16px;
font-weight: normal;
margin-top: 20px;
margin-bottom: 10px;
}
div {
margin-left: 15px;
}
td {
margin: 0px;
}
td.first {
padding: 0px 6px 0px 0px;
}
td.middle {
padding: 0px 6px 0px 6px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}
td.last {
padding: 0px 0px 0px 6px;
}
thead {
font-weight: bold;
border-bottom: 1px solid #ccc;
}
</style>
</head>
<body>
<% vpns.each do |name,config| %>
<% status = stati[name] %>
<h1>OpenVPN Status for <%= name %></h1>
<h2>Client List</h2>
<div>
<table>
<thead>
<% status.client_list_headers.each_with_index do |header,i| %>
<% if i == 0 %>
<td class="first">
<% elsif i == status.client_list_headers.size-1 %>
<td class="last">
<% else %>
<td class="middle">
<% end %>
<%= header %></td>
<% end %>
</thead>
<tbody>
<% status.client_list.each do |client| %>
<tr>
<% status.client_list_headers.each_with_index do |header,i| %>
<% if i == 0 %>
<td class="first">
<% elsif i == status.client_list_headers.size-1 %>
<td class="last">
<% else %>
<td class="middle">
<% end %>
<% if header =~ /(Received|Sent)/ %>
<%= client[i].as_bytes %></td>
<% elsif client[i].is_a? DateTime %>
<%= client[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
<% else %>
<%= client[i] %></td>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<h2>Routing Table</h2>
<div>
<table>
<thead>
<% status.routing_table_headers.each_with_index do |header,i| %>
<% if i == 0 %>
<td class="first">
<% elsif i == status.routing_table_headers.size-1 %>
<td class="last">
<% else %>
<td class="middle">
<% end %>
<%= header %></td>
<% end %>
</thead>
<tbody>
<% status.routing_table.each do |route| %>
<tr>
<% status.routing_table_headers.each_with_index do |header,i| %>
<% if i == 0 %>
<td class="first">
<% elsif i == status.routing_table_headers.size-1 %>
<td class="last">
<% else %>
<td class="middle">
<% end %>
<% if route[i].is_a? DateTime %>
<%= route[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
<% else %>
<%= route[i] %></td>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<h2>Global Stats</h2>
<div>
<table>
<tbody>
<% status.global_stats.each do |global| %>
<tr>
<td><%= global[0] %>:</td>
<td><%= global[1] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</body>
</html>