From 3a92ffe1ad170901962dd7e4a657051c3b196128 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 6 May 2015 12:18:25 +0200 Subject: [PATCH] Monitor page refactoring --- contrib/monitor/css/eddn.css | 11 + contrib/monitor/index.html | 304 ++++++++++++++++------- contrib/monitor/js/eddn.js | 132 ++++++---- contrib/status/css/{edn.css => eddn.css} | 0 4 files changed, 317 insertions(+), 130 deletions(-) rename contrib/status/css/{edn.css => eddn.css} (100%) diff --git a/contrib/monitor/css/eddn.css b/contrib/monitor/css/eddn.css index e69de29..ac9cd66 100644 --- a/contrib/monitor/css/eddn.css +++ b/contrib/monitor/css/eddn.css @@ -0,0 +1,11 @@ +body { + padding-top: 70px; +} + +section.container { + margin-bottom: 20px; +} + + .container h2 { + margin-top: 0; + } \ No newline at end of file diff --git a/contrib/monitor/index.html b/contrib/monitor/index.html index 1410554..cd0244a 100644 --- a/contrib/monitor/index.html +++ b/contrib/monitor/index.html @@ -1,14 +1,14 @@ - - - - + + + + EDDN Status - - + + @@ -18,92 +18,220 @@ - - - -
-
-
-

EDDN Status

+ + + +
+ +
+ +
+
+
+

+ This page shows transaction information (messages sent/received) for key points of the EDDN, over a one-, five- and sixty-minute period.
+ Values automatically update every minute. +

+
-
+ +
+
+
+

Gateway

+
+
+
+ +
+
-
-
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1 min5 min60 min
Messages received---
Invalid messages---
Messages passed to relay---
+
+
+ +
+
+

+ EDDN version N/A. +

+
+
+

+ Uptime: N/A. +

+
+
+

+ Last updated N/A. +

+
+
+
+
+
+
+ + +
+
+
+

Relay

+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
1 min5 min60 min
Messages received---
Messages passed to subscribers---
+
+
+ +
+
+

+ EDDN version N/A. +

+
+
+

+ Uptime: N/A. +

+
+
+

+ Last updated N/A. +

+
+
+
+
+
+
+
+ +
+
+
+

Software

+
+
+
+ +
+
+
+

Uploader

+
+
+
+ +
+ +
+ - - - + + + \ No newline at end of file diff --git a/contrib/monitor/js/eddn.js b/contrib/monitor/js/eddn.js index c12f38d..f015f6c 100644 --- a/contrib/monitor/js/eddn.js +++ b/contrib/monitor/js/eddn.js @@ -1,3 +1,16 @@ +var updateInterval = 60000, + + monitorEndPoint = 'http://eddn-monitor.ed-td.space:9091/', + + gatewayBottlePort = 8080, + relayBottlePort = 9090, + + relays = [ + 'eddn-gateway.elite-markets.net', + 'eddn-gateway.ed-td.space' + ]; + + secondsToDurationString = function(seconds) { var hours = Math.floor(seconds / 3600); var minutes = Math.floor((seconds - (hours * 3600)) / 60); @@ -21,42 +34,35 @@ secondsToDurationString = function(seconds) { } } +displayStats = function(el, stats){ + el.find(".inbound_1min").html((stats["inbound"] || {})["1min"] || 0); + el.find(".inbound_5min").html((stats["inbound"] || {})["5min"] || 0); + el.find(".inbound_60min").html((stats["inbound"] || {})["60min"] || 0); + + el.find(".invalid_1min").html((stats["invalid"] || {})["1min"] || 0); + el.find(".invalid_5min").html((stats["invalid"] || {})["5min"] || 0); + el.find(".invalid_60min").html((stats["invalid"] || {})["60min"] || 0); + + el.find(".outbound_1min").html((stats["outbound"] || {})["1min"] || 0); + el.find(".outbound_5min").html((stats["outbound"] || {})["5min"] || 0); + el.find(".outbound_60min").html((stats["outbound"] || {})["60min"] || 0); + + d = new Date(); + el.find(".update_timestamp").html(d.toString("yyyy-MM-dd HH:mm:ss")); + el.find(".version").html(stats['version'] || "N/A"); + + if (stats['uptime']) + el.find(".uptime").html(secondsToDurationString(stats['uptime'])); + + formatStats(); +} + displayGatewayStats = function(stats) { - $("#gateway_inbound_1min").html((stats["inbound"] || {})["1min"] || 0); - $("#gateway_inbound_5min").html((stats["inbound"] || {})["5min"] || 0); - $("#gateway_inbound_60min").html((stats["inbound"] || {})["60min"] || 0); - - $("#gateway_invalid_1min").html((stats["invalid"] || {})["1min"] || 0); - $("#gateway_invalid_5min").html((stats["invalid"] || {})["5min"] || 0); - $("#gateway_invalid_60min").html((stats["invalid"] || {})["60min"] || 0); - - $("#gateway_outbound_1min").html((stats["outbound"] || {})["1min"] || 0); - $("#gateway_outbound_5min").html((stats["outbound"] || {})["5min"] || 0); - $("#gateway_outbound_60min").html((stats["outbound"] || {})["60min"] || 0); - d = new Date(); - $("#update_gateway_timestamp").html(d.toString("yyyy-MM-dd HH:mm:ss")); - $("#gateway_version").html(stats['version'] || "N/A"); - if (stats['uptime']) { - $("#gateway_uptime").html(secondsToDurationString(stats['uptime'])); - } - formatStats(); + return displayStats($('#gateway'), stats) } displayRelayStats = function(stats) { - $("#relay_inbound_1min").html((stats["inbound"] || {})["1min"] || 0); - $("#relay_inbound_5min").html((stats["inbound"] || {})["5min"] || 0); - $("#relay_inbound_60min").html((stats["inbound"] || {})["60min"] || 0); - - $("#relay_outbound_1min").html((stats["outbound"] || {})["1min"] || 0); - $("#relay_outbound_5min").html((stats["outbound"] || {})["5min"] || 0); - $("#relay_outbound_60min").html((stats["outbound"] || {})["60min"] || 0); - d = new Date(); - $("#update_relay_timestamp").html(d.toString("yyyy-MM-dd HH:mm:ss")); - $("#relay_version").html(stats['version'] || "N/A"); - if (stats['uptime']) { - $("#relay_uptime").html(secondsToDurationString(stats['uptime'])); - } - formatStats(); + return displayStats($('#relay'), stats) } formatStats = function() { @@ -70,26 +76,68 @@ formatStats = function() { }); } -doUpdate = function(url, success, failure) { +doUpdate = function(url, success) { $.ajax({ dataType: "json", url: url, - success: success, - failure: failure + success: success }); } getGatewayUrl = function() { - return $("#gateway").val(); + return $("select[name=gateway]").val(); } getRelayUrl = function() { - return $("#relay").val(); + return $("select[name=relay]").val(); } -$("#gateway").change(function() {doUpdate(getGatewayUrl(), displayGatewayStats);}) -$("#relay").change(function() {doUpdate(getRelayUrl(), displayRelayStats);}) -doUpdate(getGatewayUrl(), displayGatewayStats); -doUpdate(getRelayUrl(), displayRelayStats); -setInterval(function() {doUpdate(getGatewayUrl(), displayGatewayStats); doUpdate(getRelayUrl(), displayRelayStats)}, 60000); \ No newline at end of file + +/** + * Launch monitoring + */ +var start = function(){ + // Grab gateways from monitor + $.ajax({ + dataType: "json", + url: monitorEndPoint + 'getGateways/', + success: function(gateways){ + gateways = gateways.sort(); + $.each(gateways, function(k, gateway){ + gateway = gateway.replace('tcp://', ''); + gateway = gateway.replace(':8500', ''); + + $("select[name=gateway]").append($('