From c51968618dee9efb853a3fff3cf4bc7d532e5b8d Mon Sep 17 00:00:00 2001 From: cn Date: Fri, 3 May 2013 21:12:06 +0200 Subject: [PATCH] Show multiple vpns --- lib/openvpn-status-web.rb | 7 +- lib/openvpn-status-web/main.html.erb | 107 ++++++++++++++------------- 2 files changed, 60 insertions(+), 54 deletions(-) diff --git a/lib/openvpn-status-web.rb b/lib/openvpn-status-web.rb index 61ef56a..9e06ea9 100644 --- a/lib/openvpn-status-web.rb +++ b/lib/openvpn-status-web.rb @@ -43,8 +43,11 @@ module OpenVPNStatusWeb return [404, {"Content-Type" => "text/plain"}, ["Not Found"]] if env["PATH_INFO"] != "/" # variables for template - name = @vpns.keys.first - status = parse_status_log(@vpns[name]) + vpns = @vpns + stati = {} + @vpns.each do |name,config| + stati[name] = parse_status_log(config) + end # eval html = @main_tmpl.result(binding) diff --git a/lib/openvpn-status-web/main.html.erb b/lib/openvpn-status-web/main.html.erb index 71b09ee..a757231 100644 --- a/lib/openvpn-status-web/main.html.erb +++ b/lib/openvpn-status-web/main.html.erb @@ -42,67 +42,70 @@ thead { -

OpenVPN Status for <%= name %>

+<% vpns.each do |name,config| %> + <% status = stati[name] %> +

OpenVPN Status for <%= name %>

-

Client List

-
- - - - - - - - - +

Client List

+
+
Common NameReal AddressData ReceivedData SentConnected Since
+ + + + + + + + <% status.client_list.each do |client| %> - - - - - - - + + + + + + + <% end %> - -
Common NameReal AddressData ReceivedData SentConnected Since
<%= client[0] %><%= client[1] %><%= client[2].to_i.as_bytes %><%= client[3].to_i.as_bytes %><%= client[4] %>
<%= client[0] %><%= client[1] %><%= client[2].to_i.as_bytes %><%= client[3].to_i.as_bytes %><%= client[4] %>
-
+ + + -

Routing Table

-
- - - - - - - - +

Routing Table

+
+
Virtual AddressCommon NameReal AddressLast Ref
+ + + + + + + <% status.routing_table.each do |e| %> - - - - - - + + + + + + <% end %> - -
Virtual AddressCommon NameReal AddressLast Ref
<%= e[0] %><%= e[1] %><%= e[2] %><%= e[3] %>
<%= e[0] %><%= e[1] %><%= e[2] %><%= e[3] %>
-
+ + + -

Global Stats

-
- - +

Global Stats

+
+
+ <% status.global_stats.each do |e| %> - - - - + + + + +<% end %> + +
<%= e[0] %>:<%= e[1] %>
<%= e[0] %>:<%= e[1] %>
+
<% end %> - - -