monitor: Move configuration into separate file

This will allow for running more than one monitor without editing actual
source.
This commit is contained in:
Athanasius 2022-03-13 15:55:03 +00:00
parent 8c62afb869
commit 063322df4f
3 changed files with 36 additions and 28 deletions

View File

@ -400,6 +400,8 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://code.highcharts.com/5.0.12/highcharts.js"></script>
<script src="https://code.highcharts.com/5.0.12/modules/drilldown.js"></script>
<!-- config file -->
<script src="./js/eddn-config.js"></script>
<script src="./js/eddn.js"></script>
</body>
</html>

View File

@ -0,0 +1,22 @@
/* vim: wrapmargin=0 textwidth=0 tabstop=4 softtabstop=4 expandtab shiftwidth=4
*/
var eddn_config = {
updateInterval: 60000,
eddn_host: 'eddn.miggy.org',
monitorEndPoint: 'https://eddn.miggy.org/dev/monitor/',
gatewayStats: '/dev/stats/',
relayStats: '/dev/relay/stats/',
relayBottlePort: 9110,
gateways: [
'eddn.miggy.org'
], //TODO: Must find a way to bind them to monitor
relays: [
'eddn.miggy.org'
] //TODO: Must find a way to bind them to monitor
};

View File

@ -1,21 +1,5 @@
/* vim: wrapmargin=0 textwidth=0 tabstop=4 softtabstop=4 expandtab shiftwidth=4
*/
var updateInterval = 60000,
monitorEndPoint = 'https://eddn.edcd.io:9091/',
//gatewayBottlePort = 8080,
gatewayBottlePort = 4430,
relayBottlePort = 9090,
gateways = [
'eddn.edcd.io'
], //TODO: Must find a way to bind them to monitor
relays = [
'eddn.edcd.io'
]; //TODO: Must find a way to bind them to monitor
var stats = {
'gateways' : {},
'relays' : {}
@ -435,11 +419,11 @@ var doUpdateSoftwares = function()
*/
$.ajax({
dataType: "json",
url: monitorEndPoint + 'getSoftwares/?dateStart=' + yesterday + '&dateEnd = ' + today,
url: eddn_config.monitorEndPoint + 'getSoftwares/?dateStart=' + yesterday + '&dateEnd = ' + today,
success: function(softwaresTodayYesterday){
$.ajax({
dataType: "json",
url: monitorEndPoint + 'getTotalSoftwares/',
url: eddn_config.monitorEndPoint + 'getTotalSoftwares/',
success: function(softwaresTotals){
// Might happen when nothing is received...
if(softwaresTodayYesterday[yesterday] == undefined)
@ -524,7 +508,7 @@ var doUpdateSchemas = function()
$.ajax({
dataType: "json",
url: monitorEndPoint + 'getSchemas/?dateStart=' + yesterday + '&dateEnd = ' + today,
url: eddn_config.monitorEndPoint + 'getSchemas/?dateStart=' + yesterday + '&dateEnd = ' + today,
success: function(schemasTodayYesterday){
// Might happen when nothing is received...
if(schemasTodayYesterday[yesterday] == undefined)
@ -534,7 +518,7 @@ var doUpdateSchemas = function()
$.ajax({
dataType: "json",
url: monitorEndPoint + 'getTotalSchemas/',
url: eddn_config.monitorEndPoint + 'getTotalSchemas/',
success: function(schemasTotals){
var chart = $('#schemas .chart').highcharts(),
series = chart.get('schemas');
@ -807,12 +791,12 @@ var start = function(){
// Grab gateways
//gateways = gateways.sort();
$.each(gateways, function(k, gateway){
$.each(eddn_config.gateways, function(k, gateway){
gateway = gateway.replace('tcp://', '');
gateway = gateway.replace(':8500', '');
$("select[name=gateways]").append($('<option>', {
value: 'https://' + gateway + ':' + gatewayBottlePort + '/stats/',
value: eddn_config.gatewayStats,
text : gateway
}));
@ -853,13 +837,13 @@ var start = function(){
doUpdates('gateways');
setInterval(function(){
doUpdates('gateways');
}, updateInterval);
}, eddn_config.updateInterval);
// Grab relays
//relays = relays.sort();
$.each(relays, function(k, relay){
$.each(eddn_config.relays, function(k, relay){
$("select[name=relays]").append($('<option>', {
value: 'https://' + relay + ':' + relayBottlePort + '/stats/',
value: eddn_config.relayStats,
text : relay
}));
@ -903,7 +887,7 @@ var start = function(){
doUpdates('relays');
setInterval(function(){
doUpdates('relays');
}, updateInterval);
}, eddn_config.updateInterval);
// Grab software from monitor
$('#software .chart').highcharts({
@ -926,7 +910,7 @@ var start = function(){
doUpdateSoftwares();
setInterval(function(){
doUpdateSoftwares();
}, updateInterval);
}, eddn_config.updateInterval);
// Grab uploader from monitor
$('#uploaders .chart').highcharts({
@ -965,7 +949,7 @@ var start = function(){
doUpdateSchemas();
setInterval(function(){
doUpdateSchemas();
}, updateInterval);
}, eddn_config.updateInterval);
// Attach events
$("select[name=gateways]").change(function(){