X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=plugins.d%2Fnode.d.plugin;h=270351e4e5582cada1876edd54eb71d481d0c71b;hb=3824a699715d85e0adf61570a4569d09922c7f5c;hp=13ac7aa8824394ea593c5b2773904a39d14fcc51;hpb=ccb789708de8b8126ddd17cfaf8e2c3623e4c073;p=netdata.git diff --git a/plugins.d/node.d.plugin b/plugins.d/node.d.plugin index 13ac7aa8..270351e4 100755 --- a/plugins.d/node.d.plugin +++ b/plugins.d/node.d.plugin @@ -1,4 +1,14 @@ -#!/usr/bin/env node +#!/usr/bin/env bash +':' //; exec "$(command -v nodejs || command -v node || command -v js || echo "ERROR node.js IS NOT AVAILABLE IN THIS SYSTEM")" "$0" "$@" + +// shebang hack from: +// http://unix.stackexchange.com/questions/65235/universal-node-js-shebang + +// Initially this is run as a shell script (#!/bin/sh). +// Then, the second line, finds nodejs or node or js in the system path +// and executes it with the shell parameters. + +// -------------------------------------------------------------------------------------------------------------------- 'use strict'; @@ -9,7 +19,6 @@ var NETDATA_PLUGINS_DIR = process.env.NETDATA_PLUGINS_DIR || __dirname; var NETDATA_CONFIG_DIR = process.env.NETDATA_CONFIG_DIR || '/etc/netdata'; var NETDATA_UPDATE_EVERY = process.env.NETDATA_UPDATE_EVERY || 1; var NODE_D_DIR = NETDATA_PLUGINS_DIR + '/../node.d'; -NETDATA_UPDATE_EVERY = NETDATA_UPDATE_EVERY * 1000; // make sure the modules are found process.mainModule.paths.unshift(NODE_D_DIR + '/node_modules'); @@ -33,12 +42,17 @@ var netdata = require('netdata'); function pluginConfig(filename) { var f = path.basename(filename); + // node.d.plugin configuration var m = f.match('.plugin' + '$'); - if(m === null) m = f.match('.node.js' + '$'); if(m !== null) return netdata.options.paths.config + '/' + f.substring(0, m.index) + '.conf'; - return netdata.options.paths.config + '/' + f + '.conf'; + // node.d modules configuration + m = f.match('.node.js' + '$'); + if(m !== null) + return netdata.options.paths.config + '/node.d/' + f.substring(0, m.index) + '.conf'; + + return netdata.options.paths.config + '/node.d/' + f + '.conf'; } // internal defaults @@ -133,14 +147,14 @@ function dumpError(err) { try { var x = parseInt(val); if(x > 0) { - netdata.options.update_every = x * 1000; + netdata.options.update_every = x; 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'); + netdata.debug('Update frequency set to ' + netdata.options.update_every + ' seconds'); } else netdata.error('Ignoring parameter: ' + val); } @@ -155,9 +169,9 @@ function dumpError(err) { }); } -if(netdata.options.update_every < 1000) { +if(netdata.options.update_every < 1) { netdata.debug('Adjusting update frequency to 1 second'); - netdata.options.update_every = 1000; + netdata.options.update_every = 1; } // -------------------------------------------------------------------------------------------------------------------- @@ -174,7 +188,7 @@ function findModules() { var n = files[len].substring(0, m.index); if(typeof(netdata.options.modules[n]) === 'undefined') - netdata.options.modules[n] = { enabled: netdata.options.modules_enable_all }; + netdata.options.modules[n] = { name: n, enabled: netdata.options.modules_enable_all }; if(netdata.options.modules[n].enabled === true) { netdata.options.modules[n].name = n; @@ -201,7 +215,7 @@ function findModules() { // load its configuration var c = { enable_autodetect: netdata.options.modules_enable_autodetect, - update_every: Math.round(netdata.options.update_every / 1000) + update_every: netdata.options.update_every }; try { netdata.debug('loading module\'s ' + netdata.options.modules[n].name + ' config ' + netdata.options.modules[n].config_filename); @@ -239,6 +253,7 @@ function findModules() { } } + // netdata.debug(netdata.options.modules); return found; }