Skip to content

Commit cf115e8

Browse files
committed
Feature: Allow xySat monitoring to be disabled for some or all servers.
1 parent a906e49 commit cf115e8

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

htdocs/js/pages/ServerUtils.class.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
776776
getProcessTable(snapshot) {
777777
// get initial html for sortable proc table
778778
var self = this;
779+
if (this.dummy) return '';
779780

780781
var proc_opts = {
781782
id: 't_snap_procs',
@@ -804,6 +805,7 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
804805
getConnectionTable(snapshot) {
805806
// get initial html for sortable conn table
806807
var self = this;
808+
if (this.dummy) return '';
807809

808810
var conn_opts = {
809811
id: 't_snap_conns',
@@ -833,6 +835,7 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
833835
getInterfaceTable(snapshot) {
834836
// get initial html for sortable iface table
835837
var self = this;
838+
if (this.dummy) return '';
836839

837840
var iface_opts = {
838841
id: 't_snap_ifaces',
@@ -866,6 +869,7 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
866869
getMountTable(snapshot) {
867870
// get initial html for sortable mount table
868871
var self = this;
872+
if (this.dummy) return '';
869873

870874
var fs_opts = {
871875
id: 't_snap_fs',
@@ -1845,6 +1849,7 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
18451849

18461850
var snapshot = server.snapshot || {};
18471851
if (!snapshot.data || !snapshot.data.docker) return;
1852+
if (snapshot.data.dummy) return;
18481853

18491854
snapshot.data.docker.containers.forEach( function(cont) {
18501855
cont_list.push({ ...cont,

htdocs/js/pages/Servers.class.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ Page.Servers = class Servers extends Page.ServerUtils {
840840
this.server = server;
841841
var snapshot = this.snapshot = data;
842842
this.online = online;
843+
this.dummy = snapshot.data && snapshot.data.dummy;
843844
this.charts = {};
844845

845846
this.updateHeaderNav();
@@ -1119,6 +1120,10 @@ Page.Servers = class Servers extends Page.ServerUtils {
11191120

11201121
SingleSelect.init( this.div.find('select.sel_chart_size') );
11211122

1123+
if (this.dummy) {
1124+
this.div.find('#d_vs_quickmon, #d_vs_mem, #d_vs_cpus, #d_vs_dash_grid, #d_vs_monitors, #d_vs_conts, #d_vs_procs, #d_vs_conns, #d_vs_ifaces, #d_vs_fs').hide();
1125+
}
1126+
11221127
this.updateServerStats();
11231128
this.renderMonitorGrid();
11241129
this.renderMemDetails();
@@ -1146,6 +1151,7 @@ Page.Servers = class Servers extends Page.ServerUtils {
11461151

11471152
renderContainers() {
11481153
// show containers if server is a docker host
1154+
if (this.dummy) return;
11491155
if (!this.snapshot || !this.snapshot.data || !this.snapshot.data.docker) {
11501156
this.div.find('#d_vs_conts').hide();
11511157
return;
@@ -1544,16 +1550,19 @@ Page.Servers = class Servers extends Page.ServerUtils {
15441550

15451551
renderMonitorGrid() {
15461552
// show grid of monitors
1553+
if (this.dummy) return;
15471554
this.div.find('#d_vs_dash_grid').html( this.getMonitorGrid(this.snapshot) );
15481555
}
15491556

15501557
renderMemDetails() {
15511558
// show memory details
1559+
if (this.dummy) return;
15521560
this.div.find('#d_vs_mem > .box_content').html( this.getMemDetails(this.snapshot) );
15531561
}
15541562

15551563
renderCPUDetails() {
15561564
// show cpu details
1565+
if (this.dummy) return;
15571566
this.div.find('#d_vs_cpus > .box_content').html( this.getCPUDetails(this.snapshot) );
15581567
}
15591568

@@ -1565,6 +1574,7 @@ Page.Servers = class Servers extends Page.ServerUtils {
15651574

15661575
// check for quickmon support on server
15671576
if (!server.info.quickmon) return;
1577+
if (this.dummy) return;
15681578

15691579
html += '<div class="chart_grid_horiz ' + (app.getPref('chart_size_quick') || 'medium') + '">';
15701580

@@ -1784,6 +1794,8 @@ Page.Servers = class Servers extends Page.ServerUtils {
17841794
var monitors = this.monitors = [];
17851795
var min_epoch = app.epoch - 3600;
17861796
var html = '';
1797+
if (this.dummy) return;
1798+
17871799
html += '<div class="chart_grid_horiz ' + (app.getPref('chart_size') || 'medium') + '">';
17881800

17891801
app.monitors.forEach( function(mon_def) {

lib/monitor.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ class Monitoring {
175175
params.data.monitors = {};
176176
params.data.deltas = {};
177177

178+
// special quick exit for dummy record (i.e. monitoring disabled on server)
179+
if (params.data.dummy) {
180+
this.logMonitor(9, "Saving dummy record for disabled monitoring: " + server.id);
181+
this.storage.put( 'hosts/' + server.id + '/data', params, function(err) {
182+
if (err) self.logError('monitor', "Failed to submit data: " + (err.message || err), {});
183+
} );
184+
return;
185+
}
186+
178187
monitor_defs.forEach( function(mon_def) {
179188
if (mon_def.groups && mon_def.groups.length && !Tools.includesAny(mon_def.groups, params.groups)) return;
180189

@@ -573,7 +582,7 @@ class Monitoring {
573582
self.storage.unlock( host_key );
574583
if (err) {
575584
// silence double-submit errors, as they are benign
576-
if (err.code != 'DOUBLE') self.logError('submit', "Failed to submit data: " + (err.message || err), {});
585+
if (err.code != 'DOUBLE') self.logError('monitor', "Failed to submit monitoring data: " + (err.message || err), {});
577586
}
578587
else {
579588
self.logMonitor(6, "Data submission complete for: " + params.hostname, { id: server.id });
@@ -742,6 +751,10 @@ class Monitoring {
742751
this.storage.get( host_key, function(err, data) {
743752
if (err) return callback(err);
744753

754+
if (data.data && data.data.dummy) {
755+
return callback( new Error("Monitoring is disabled on server: " + server_id) );
756+
}
757+
745758
// merge in params
746759
Tools.mergeHashInto(data, params);
747760

0 commit comments

Comments
 (0)