diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-02-04 01:29:29 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-02-04 01:29:29 +0200 |
commit | ccb789708de8b8126ddd17cfaf8e2c3623e4c073 (patch) | |
tree | 517f4feae573c8495b83159402f5c0c61539aeac /plugins.d | |
parent | b371719501373ffc0aa67e7fbb915169e994a228 (diff) |
added command line arguments in node.d.plugin to enabled selected modules; refactored netdata.js for clearance
Diffstat (limited to 'plugins.d')
-rwxr-xr-x | plugins.d/node.d.plugin | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/plugins.d/node.d.plugin b/plugins.d/node.d.plugin index 304b7aeb33..13ac7aa882 100755 --- a/plugins.d/node.d.plugin +++ b/plugins.d/node.d.plugin @@ -97,43 +97,63 @@ function dumpError(err) { // -------------------------------------------------------------------------------------------------------------------- // get command line arguments +{ + var found_myself = false; + var found_number = false; + var found_modules = false; + process.argv.forEach(function (val, index, array) { + netdata.debug('PARAM: ' + val); + + if(!found_myself) { + if(val === __filename) + found_myself = true; + } + else { + switch(val) { + case 'debug': + netdata.options.DEBUG = true; + netdata.debug('DEBUG enabled'); + break; + + default: + if(found_number === true) { + if(found_modules === false) { + for(var i in netdata.options.modules) + netdata.options.modules[i].enabled = false; + } -var found_myself = false; -process.argv.forEach(function (val, index, array) { - netdata.debug('PARAM: ' + val); + if(typeof netdata.options.modules[val] === 'undefined') + netdata.options.modules[val] = {}; - if(!found_myself) { - if(val === __filename) - found_myself = true; - } - else { - switch(val) { - case 'debug': - netdata.options.DEBUG = true; - netdata.debug('DEBUG enabled'); - break; - - default: - try { - var x = parseInt(val); - if(x > 0) { - netdata.options.update_every = x * 1000; - if(netdata.options.update_every < NETDATA_UPDATE_EVERY) { - netdata.options.update_every = NETDATA_UPDATE_EVERY; - netdata.debug('Update frequency ' + x + 's is too low'); + netdata.options.modules[val].enabled = true; + netdata.options.modules_enable_all = false; + netdata.debug('enabled module ' + val); + } + else { + try { + var x = parseInt(val); + if(x > 0) { + netdata.options.update_every = x * 1000; + if(netdata.options.update_every < NETDATA_UPDATE_EVERY) { + netdata.options.update_every = NETDATA_UPDATE_EVERY; + netdata.debug('Update frequency ' + x + 's is too low'); + } + + found_number = true; + netdata.debug('Update frequency set to ' + netdata.options.update_every + ' ms'); + } + else netdata.error('Ignoring parameter: ' + val); + } + catch(e) { + netdata.error('Cannot get value of parameter: ' + val); + dumpError(e); } - - netdata.debug('Update frequency set to ' + netdata.options.update_every + ' ms'); } - else netdata.error('Ignoring parameter: ' + val); - } - catch(e) { - netdata.error('Cannot get value of parameter: ' + val); - dumpError(e); - } + break; + } } - } -}); + }); +} if(netdata.options.update_every < 1000) { netdata.debug('Adjusting update frequency to 1 second'); |