summaryrefslogtreecommitdiffstats
path: root/node.d
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-01-07 01:23:32 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-01-07 18:50:53 +0200
commitbe5b69fcd142bb7698d98ddfb0e6c912f6d6667a (patch)
tree496369821094e02aca1ceeade1704e63b6e03912 /node.d
parent280dc08fd612fe8ec14143d577f83fb81a9bb4c5 (diff)
changes suggested by codeclimate
Diffstat (limited to 'node.d')
-rw-r--r--node.d/named.node.js163
-rw-r--r--node.d/node_modules/netdata.js127
2 files changed, 169 insertions, 121 deletions
diff --git a/node.d/named.node.js b/node.d/named.node.js
index 54e80388a3..3d79465577 100644
--- a/node.d/named.node.js
+++ b/node.d/named.node.js
@@ -41,7 +41,7 @@ var http = require('http');
var XML = require('pixl-xml');
var netdata = require('netdata');
-if(netdata.options.DEBUG === true) netdata.debug('loaded ' + __filename + ' plugin');
+if(netdata.options.DEBUG === true) netdata.debug('loaded', __filename, 'plugin');
var named = {
name: __filename,
@@ -62,10 +62,14 @@ var named = {
priority: priority, // the priority relative to others in the same family
update_every: service.update_every, // the expected update frequency of the chart
dimensions: {}
- }
+ };
var found = 0;
- for(var x in obj) {
+ var dims = Object.keys(obj);
+ var len = dims.length;
+ for(var i = 0; i < len ;i++) {
+ var x = dims[i];
+
if(typeof(obj[x]) !== 'undefined' && obj[x] !== 0) {
found++;
chart.dimensions[x] = {
@@ -90,6 +94,7 @@ var named = {
chartFromMembers: function(service, obj, id_suffix, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor) {
var id = 'named_' + service.name + '.' + id_suffix;
var chart = this.charts[id];
+ var dims, len, x, i;
if(typeof chart === 'undefined') {
chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
@@ -97,7 +102,10 @@ var named = {
}
else {
// check if we need to re-generate the chart
- for(var x in obj) {
+ dims = Object.keys(obj);
+ len = dims.length;
+ for(i = 0; i < len ;i++) {
+ x = dims[i];
if(typeof(chart.dimensions[x]) === 'undefined') {
chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
if(chart === null) return false;
@@ -106,18 +114,22 @@ var named = {
}
}
- var found = 0;
service.begin(chart);
- for(var x in obj) {
+
+ var found = 0;
+ dims = Object.keys(obj);
+ len = dims.length;
+ for(i = 0; i < len ;i++) {
+ x = dims[i];
if(typeof(chart.dimensions[x]) !== 'undefined') {
found++;
service.set(x, obj[x]);
}
}
+
service.end();
- if(found > 0) return true;
- return false;
+ return (found > 0);
},
// an index to map values to different charts
@@ -133,19 +145,21 @@ var named = {
var d = XML.parse(data_xml);
if(d === null) return null;
+ var a, aa, alen, alen2;
+
var data = {};
var len = d.server.counters.length;
while(len--) {
- var a = d.server.counters[len];
+ a = d.server.counters[len];
if(typeof a.counter === 'undefined') continue;
if(a.type === 'opcode') a.type = 'opcodes';
else if(a.type === 'qtype') a.type = 'qtypes';
else if(a.type === 'nsstat') a.type = 'nsstats';
- var aa = data[a.type] = {};
- var alen = 0
- var alen2 = a.counter.length;
+ aa = data[a.type] = {};
+ alen = 0;
+ alen2 = a.counter.length;
while(alen < alen2) {
- aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data);
+ aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data, 10);
alen++;
}
}
@@ -155,18 +169,18 @@ var named = {
while(vlen--) {
var vname = d.views.view[vlen].name;
data.views[vname] = { resolver: {} };
- var len = d.views.view[vlen].counters.length;
+ len = d.views.view[vlen].counters.length;
while(len--) {
- var a = d.views.view[vlen].counters[len];
+ a = d.views.view[vlen].counters[len];
if(typeof a.counter === 'undefined') continue;
if(a.type === 'resstats') a.type = 'stats';
else if(a.type === 'resqtype') a.type = 'qtypes';
else if(a.type === 'adbstat') a.type = 'adb';
- var aa = data.views[vname].resolver[a.type] = {};
- var alen = 0;
- var alen2 = a.counter.length;
+ aa = data.views[vname].resolver[a.type] = {};
+ alen = 0;
+ alen2 = a.counter.length;
while(alen < alen2) {
- aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data);
+ aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data, 10);
alen++;
}
}
@@ -177,7 +191,7 @@ var named = {
processResponse: function(service, data) {
if(data !== null) {
- var r;
+ var r, x, look, id, chart, keys, len;
// parse XML or JSON
// pepending on the URL given
@@ -212,11 +226,15 @@ var named = {
delete r.nsstats['RecursClients'];
}
- for( var x in r.nsstats ) {
+ keys = Object.keys(r.nsstats);
+ len = keys.length;
+ while(len--) {
+ x = keys[len];
+
// we maintain an index of the values found
// mapping them to objects splitted
- var look = named.lookups.nsstats[x];
+ look = named.lookups.nsstats[x];
if(typeof look === 'undefined') {
// a new value, not found in the index
// index it:
@@ -299,66 +317,64 @@ var named = {
}
}
- if(global_requests_enable == true)
+ if(global_requests_enable === true)
service.module.chartFromMembers(service, global_requests, 'received_requests', 'Bind, Global Received Requests by IP version', 'requests/s', 'requests', 'named.requests', netdata.chartTypes.stacked, named.base_priority + 1, netdata.chartAlgorithms.incremental, 1, 1);
- if(global_queries_success_enable == true)
+ if(global_queries_success_enable === true)
service.module.chartFromMembers(service, global_queries_success, 'global_queries_success', 'Bind, Global Successful Queries', 'queries/s', 'queries', 'named.queries_succcess', netdata.chartTypes.line, named.base_priority + 2, netdata.chartAlgorithms.incremental, 1, 1);
- if(protocol_queries_enable == true)
+ if(protocol_queries_enable === true)
service.module.chartFromMembers(service, protocol_queries, 'protocols_queries', 'Bind, Global Queries by IP Protocol', 'queries/s', 'queries', 'named.protocol_queries', netdata.chartTypes.stacked, named.base_priority + 3, netdata.chartAlgorithms.incremental, 1, 1);
- if(global_queries_enable == true)
+ if(global_queries_enable === true)
service.module.chartFromMembers(service, global_queries, 'global_queries', 'Bind, Global Queries Analysis', 'queries/s', 'queries', 'named.global_queries', netdata.chartTypes.stacked, named.base_priority + 4, netdata.chartAlgorithms.incremental, 1, 1);
- if(global_updates_enable == true)
+ if(global_updates_enable === true)
service.module.chartFromMembers(service, global_updates, 'received_updates', 'Bind, Global Received Updates', 'updates/s', 'updates', 'named.global_updates', netdata.chartTypes.stacked, named.base_priority + 5, netdata.chartAlgorithms.incremental, 1, 1);
- if(global_failures_enable == true)
+ if(global_failures_enable === true)
service.module.chartFromMembers(service, global_failures, 'query_failures', 'Bind, Global Query Failures', 'failures/s', 'failures', 'named.global_failures', netdata.chartTypes.line, named.base_priority + 6, netdata.chartAlgorithms.incremental, 1, 1);
- if(global_failures_detail_enable == true)
+ if(global_failures_detail_enable === true)
service.module.chartFromMembers(service, global_failures_detail, 'query_failures_detail', 'Bind, Global Query Failures Analysis', 'failures/s', 'failures', 'named.global_failures_detail', netdata.chartTypes.stacked, named.base_priority + 7, netdata.chartAlgorithms.incremental, 1, 1);
if(default_enable === true)
service.module.chartFromMembers(service, r.nsstats, 'nsstats', 'Bind, Other Global Server Statistics', 'operations/s', 'other', 'named.nsstats', netdata.chartTypes.line, named.base_priority + 8, netdata.chartAlgorithms.incremental, 1, 1);
// RecursClients chart
- {
- var id = 'named_' + service.name + '.recursive_clients';
- var chart = named.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Bind, Current Recursive Clients', // the title of the chart
- units: 'clients', // the units of the chart dimensions
- family: 'clients', // the family of the chart
- context: 'named.recursive_clients', // the context of the chart
- type: netdata.chartTypes.line, // the type of the chart
- priority: named.base_priority + 1, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'clients': {
- id: 'clients', // the unique id of the dimension
- name: '', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- }
+ id = 'named_' + service.name + '.recursive_clients';
+ chart = named.charts[id];
+
+ if(typeof chart === 'undefined') {
+ chart = {
+ id: id, // the unique id of the chart
+ name: '', // the unique name of the chart
+ title: service.name + ' Bind, Current Recursive Clients', // the title of the chart
+ units: 'clients', // the units of the chart dimensions
+ family: 'clients', // the family of the chart
+ context: 'named.recursive_clients', // the context of the chart
+ type: netdata.chartTypes.line, // the type of the chart
+ priority: named.base_priority + 1, // the priority relative to others in the same family
+ update_every: service.update_every, // the expected update frequency of the chart
+ dimensions: {
+ 'clients': {
+ id: 'clients', // the unique id of the dimension
+ name: '', // the name of the dimension
+ algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
+ multiplier: 1, // the multiplier
+ divisor: 1, // the divisor
+ hidden: false // is hidden (boolean)
}
- };
-
- chart = service.chart(id, chart);
- named.charts[id] = chart;
- }
+ }
+ };
- service.begin(chart);
- service.set('clients', RecursClients);
- service.end();
+ chart = service.chart(id, chart);
+ named.charts[id] = chart;
}
+
+ service.begin(chart);
+ service.set('clients', RecursClients);
+ service.end();
}
if(typeof r.opcodes !== 'undefined')
@@ -371,15 +387,18 @@ var named = {
service.module.chartFromMembers(service, r.sockstats, 'in_sockstats', 'Bind, Global Socket Statistics', 'operations/s', 'sockets', 'named.in_sockstats', netdata.chartTypes.line, named.base_priority + 11, netdata.chartAlgorithms.incremental, 1, 1);
if(typeof r.views !== 'undefined') {
- for( var x in r.views ) {
+ keys = Object.keys(r.views);
+ len = keys.length;
+ while(len--) {
+ x = keys[len];
var resolver = r.views[x].resolver;
if(typeof resolver !== 'undefined') {
if(typeof resolver.stats !== 'undefined') {
var NumFetch = 0;
var key = service.name + '.' + x;
- var default_enable = false;
var rtt = {}, rtt_enable = false;
+ default_enable = false;
// NumFetch is an absolute value
if(typeof resolver.stats['NumFetch'] !== 'undefined') {
@@ -392,11 +411,15 @@ var named = {
}
// split the QryRTT* from the main chart
- for( var y in resolver.stats ) {
+ var ykeys = Object.keys(resolver.stats);
+ var ylen = ykeys.length;
+ while(ylen--) {
+ var y = ykeys[ylen];
+
// we maintain an index of the values found
// mapping them to objects splitted
- var look = named.lookups.resolver_stats[y];
+ look = named.lookups.resolver_stats[y];
if(typeof look === 'undefined') {
if(y.match(/^QryRTT/) !== null) {
named.lookups.resolver_stats[y] = {
@@ -429,8 +452,8 @@ var named = {
// NumFetch chart
if(typeof named.lookups.numfetch[key] !== 'undefined') {
- var id = 'named_' + service.name + '.view_resolver_numfetch_' + x;
- var chart = named.charts[id];
+ id = 'named_' + service.name + '.view_resolver_numfetch_' + x;
+ chart = named.charts[id];
if(typeof chart === 'undefined') {
chart = {
@@ -473,8 +496,8 @@ var named = {
// service.module.chartFromMembers(service, resolver.cache, 'view_resolver_cache_' + x, 'Bind, ' + x + ' View, Cache Entries', 'entries', 'view_' + x, 'named.resolver_cache', netdata.chartTypes.stacked, named.base_priority + 15, netdata.chartAlgorithms.absolute, 1, 1);
if(typeof resolver.cachestats['CacheHits'] !== 'undefined' && resolver.cachestats['CacheHits'] > 0) {
- var id = 'named_' + service.name + '.view_resolver_cachehits_' + x;
- var chart = named.charts[id];
+ id = 'named_' + service.name + '.view_resolver_cachehits_' + x;
+ chart = named.charts[id];
if(typeof chart === 'undefined') {
chart = {
@@ -580,7 +603,7 @@ var named = {
service.module.processResponse(serv, data);
callback();
});
- },
+ }
};
module.exports = named;
diff --git a/node.d/node_modules/netdata.js b/node.d/node_modules/netdata.js
index 992da481c2..11202061e4 100644
--- a/node.d/node_modules/netdata.js
+++ b/node.d/node_modules/netdata.js
@@ -48,7 +48,7 @@ var netdata = {
options: {
filename: __filename,
DEBUG: false,
- update_every: 1,
+ update_every: 1
},
chartAlgorithms: {
@@ -74,10 +74,13 @@ var netdata = {
name: 'http',
process: function(service, callback) {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': making ' + this.name + ' request: ' + netdata.stringify(service.request));
+ var __DEBUG = netdata.options.DEBUG;
+
+ if(__DEBUG === true)
+ netdata.debug(service.module.name + ': ' + service.name + ': making ' + this.name + ' request: ' + netdata.stringify(service.request));
var req = http.request(service.request, function(response) {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': got server response...');
+ if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': got server response...');
var end = false;
var data = '';
@@ -87,7 +90,7 @@ var netdata = {
if(end === false) {
service.error('Got HTTP code ' + response.statusCode + ', failed to get data.');
end = true;
- callback(null);
+ return callback(null);
}
}
@@ -99,28 +102,28 @@ var netdata = {
if(end === false) {
service.error(': Read error, failed to get data.');
end = true;
- callback(null);
+ return callback(null);
}
});
response.on('end', function() {
if(end === false) {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': read completed.');
+ if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': read completed.');
end = true;
- callback(data);
+ return callback(data);
}
});
});
req.on('error', function(e) {
- if(netdata.options.DEBUG === true) netdata.debug('Failed to make request: ' + netdata.stringify(service.request) + ', message: ' + e.message);
+ if(__DEBUG === true) netdata.debug('Failed to make request: ' + netdata.stringify(service.request) + ', message: ' + e.message);
service.error('Failed to make request, message: ' + e.message);
- callback(null);
+ return callback(null);
});
// write data to request body
if(typeof service.postData !== 'undefined' && service.request.method === 'POST') {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': posting data: ' + service.postData);
+ if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': posting data: ' + service.postData);
req.write(service.postData);
}
@@ -215,18 +218,18 @@ var netdata = {
}
};
- service.execute = function(callback) {
- if(service.enabled === false) {
- callback(null);
- return;
- }
+ service.execute = function(responseProcessor) {
+ var __DEBUG = netdata.options.DEBUG;
+
+ if(service.enabled === false)
+ return responseProcessor(null);
this.module.active++;
this.running = true;
this.started = Date.now();
this.updates++;
- if(netdata.options.DEBUG === true)
+ if(__DEBUG === true)
netdata.debug(this.module.name + ': ' + this.name + ': making ' + this.processor.name + ' request: ' + netdata.stringify(this));
this.processor.process(this, function(response) {
@@ -239,35 +242,40 @@ var netdata = {
if(response !== null)
service.errorClear();
- if(netdata.options.DEBUG === true)
+ if(__DEBUG === true)
netdata.debug(service.module.name + ': ' + service.name + ': processing ' + service.processor.name + ' response (received in ' + (service.ended - service.started).toString() + ' ms)');
- callback(service, response);
+ responseProcessor(service, response);
service.running = false;
service.module.active--;
if(service.module.active < 0) {
service.module.active = 0;
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': active module counter below zero.');
+ if(__DEBUG === true)
+ netdata.debug(service.module.name + ': active module counter below zero.');
}
if(service.module.active === 0) {
// check if we run under configure
if(service.module.configure_callback !== null) {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': configuration finish callback called from processResponse().');
- var ccallback = service.module.configure_callback;
+ if(__DEBUG === true)
+ netdata.debug(service.module.name + ': configuration finish callback called from processResponse().');
+
+ var configure_callback = service.module.configure_callback;
service.module.configure_callback = null;
- ccallback();
+ configure_callback();
}
}
});
};
service.update = function() {
- if(netdata.options.DEBUG === true) netdata.debug(this.module.name + ': ' + this.name + ': starting data collection...');
+ if(netdata.options.DEBUG === true)
+ netdata.debug(this.module.name + ': ' + this.name + ': starting data collection...');
this.module.update(this, function() {
- if(netdata.options.DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': data collection ended in ' + service.duration.toString() + ' ms.');
+ if(netdata.options.DEBUG === true)
+ netdata.debug(service.module.name + ': ' + service.name + ': data collection ended in ' + service.duration.toString() + ' ms.');
});
};
@@ -291,13 +299,17 @@ var netdata = {
service._send_chart_to_netdata = function(chart) {
// internal function to send a chart to netdata
this.queue('CHART "' + chart.id + '" "' + chart.name + '" "' + chart.title + '" "' + chart.units + '" "' + chart.family + '" "' + chart.context + '" "' + chart.type + '" ' + chart.priority.toString() + ' ' + chart.update_every.toString());
-
- for(var dim in chart.dimensions) {
- var d = chart.dimensions[dim];
- this.queue('DIMENSION "' + d.id + '" "' + d.name + '" "' + d.algorithm + '" ' + d.multiplier.toString() + ' ' + d.divisor.toString() + ' ' + ((d.hidden === true)?'hidden':'').toString());
- d._created = true;
- d._updated = false;
+ if(typeof(chart.dimensions) !== 'undefined') {
+ var dims = Object.keys(chart.dimensions);
+ var len = dims.length;
+ while(len--) {
+ var d = chart.dimensions[dims[len]];
+
+ this.queue('DIMENSION "' + d.id + '" "' + d.name + '" "' + d.algorithm + '" ' + d.multiplier.toString() + ' ' + d.divisor.toString() + ' ' + ((d.hidden === true) ? 'hidden' : '').toString());
+ d._created = true;
+ d._updated = false;
+ }
}
chart._created = true;
@@ -311,7 +323,7 @@ var netdata = {
this.end();
}
- if(typeof(chart.id) === 'undefined' || netdata.charts[chart.id] != chart) {
+ if(typeof(chart.id) === 'undefined' || netdata.charts[chart.id] !== chart) {
this.error('Called begin() for chart ' + chart.id + ' that is not mine. Where did you find it? Ignoring it.');
return false;
}
@@ -396,6 +408,8 @@ var netdata = {
// create a netdata chart
service.chart = function(id, chart) {
+ var __DEBUG = netdata.options.DEBUG;
+
if(typeof(netdata.charts[id]) === 'undefined') {
netdata.charts[id] = {
_created: false,
@@ -420,55 +434,59 @@ var netdata = {
var c = netdata.charts[id];
if(typeof(chart.name) !== 'undefined' && chart.name !== c.name) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its name');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its name');
c.name = chart.name;
c._updated = true;
}
if(typeof(chart.title) !== 'undefined' && chart.title !== c.title) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its title');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its title');
c.title = chart.title;
c._updated = true;
}
if(typeof(chart.units) !== 'undefined' && chart.units !== c.units) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its units');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its units');
c.units = chart.units;
c._updated = true;
}
if(typeof(chart.family) !== 'undefined' && chart.family !== c.family) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its family');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its family');
c.family = chart.family;
c._updated = true;
}
if(typeof(chart.context) !== 'undefined' && chart.context !== c.context) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its context');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its context');
c.context = chart.context;
c._updated = true;
}
if(typeof(chart.type) !== 'undefined' && chart.type !== c.type) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its type');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its type');
c.type = chart.type;
c._updated = true;
}
if(typeof(chart.priority) !== 'undefined' && chart.priority !== c.priority) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its priority');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its priority');
c.priority = chart.priority;
c._updated = true;
}
if(typeof(chart.update_every) !== 'undefined' && chart.update_every !== c.update_every) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its update_every from ' + c.update_every + ' to ' + chart.update_every);
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its update_every from ' + c.update_every + ' to ' + chart.update_every);
c.update_every = chart.update_every;
c._updated = true;
}
if(typeof(chart.dimensions) !== 'undefined') {
- for(var x in chart.dimensions) {
+ var dims = Object.keys(chart.dimensions);
+ var len = dims.length;
+ while(len--) {
+ var x = dims[len];
+
if(typeof(c.dimensions[x]) === 'undefined') {
c._dimensions_count++;
@@ -480,10 +498,10 @@ var netdata = {
algorithm: netdata.chartAlgorithms.absolute, // the id of the netdata algorithm
multiplier: 1, // the multiplier
divisor: 1, // the divisor
- hidden: false, // is hidden (boolean)
+ hidden: false // is hidden (boolean)
};
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' created dimension ' + x);
+ if(__DEBUG === true) netdata.debug('chart ' + id + ' created dimension ' + x);
c._updated = true;
}
@@ -491,31 +509,31 @@ var netdata = {
var d = c.dimensions[x];
if(typeof(dim.name) !== 'undefined' && d.name !== dim.name) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its name');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its name');
d.name = dim.name;
d._updated = true;
}
if(typeof(dim.algorithm) !== 'undefined' && d.algorithm !== dim.algorithm) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its algorithm from ' + d.algorithm + ' to ' + dim.algorithm);
+ if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its algorithm from ' + d.algorithm + ' to ' + dim.algorithm);
d.algorithm = dim.algorithm;
d._updated = true;
}
if(typeof(dim.multiplier) !== 'undefined' && d.multiplier !== dim.multiplier) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its multiplier');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its multiplier');
d.multiplier = dim.multiplier;
d._updated = true;
}
if(typeof(dim.divisor) !== 'undefined' && d.divisor !== dim.divisor) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its divisor');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its divisor');
d.divisor = dim.divisor;
d._updated = true;
}
if(typeof(dim.hidden) !== 'undefined' && d.hidden !== dim.hidden) {
- if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its hidden status');
+ if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its hidden status');
d.hidden = dim.hidden;
d._updated = true;
}
@@ -557,7 +575,10 @@ var netdata = {
if(this.services.length === 0) {
this.disableNodePlugin();
- process.exit(1);
+
+ // eslint suggested way to exit
+ var exit = process.exit;
+ exit(1);
}
else this.runAllServices();
},
@@ -565,7 +586,10 @@ var netdata = {
// disable the whole node.js plugin
disableNodePlugin: function() {
this.send('DISABLE');
- process.exit(1);
+
+ // eslint suggested way to exit
+ var exit = process.exit;
+ exit(1);
},
requestFromParams: function(protocol, hostname, port, path, method) {
@@ -616,13 +640,14 @@ var netdata = {
if(module.configure_callback !== null && added === 0) {
if(netdata.options.DEBUG === true) this.debug(module.name + ': configuration finish callback called from configure().');
+ var configure_callback = module.configure_callback;
module.configure_callback = null;
- callback();
+ configure_callback();
}
return added;
}
};
-if(netdata.options.DEBUG === true) netdata.debug('loaded netdata from: ' + __filename);
+if(netdata.options.DEBUG === true) netdata.debug('loaded netdata from:', __filename);
module.exports = netdata;