diff options
Diffstat (limited to 'node.d/node_modules/netdata.js')
-rwxr-xr-x | node.d/node_modules/netdata.js | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/node.d/node_modules/netdata.js b/node.d/node_modules/netdata.js index 5fa7752185..9834534eef 100755 --- a/node.d/node_modules/netdata.js +++ b/node.d/node_modules/netdata.js @@ -13,9 +13,9 @@ var example_chart = { title: 'title', // the title of the chart units: 'units', // the units of the chart dimensions family: 'family', // the family of the chart - category: 'category', // the category of the chart + context: 'context', // the context of the chart type: netdata.chartTypes.line, // the type of the chart - priority: 0, // the priority relative to others in the same family and category + priority: 0, // the priority relative to others in the same family update_every: 1, // the expected update frequency of the chart dimensions: { 'dim1': { @@ -150,6 +150,8 @@ var netdata = { if(typeof service === 'undefined') service = {}; + var now = new Date().getTime(); + service._current_chart = null; // the current chart we work on service._queue = ''; // data to be sent to netdata @@ -161,7 +163,6 @@ var netdata = { service.running = false; service.started = 0; service.ended = 0; - service.next_run = new Date().getTime(); if(typeof service.module === 'undefined') { service.module = { name: 'not-defined-module' }; @@ -169,8 +170,12 @@ var netdata = { service.enabled = false; } - if(typeof service.name === 'undefined') - service.name = 'unnamed@' + service.module.name + '/' + service.next_run; + if(typeof service.name === 'undefined') { + service.name = 'unnamed@' + service.module.name + '/' + now; + } + + if(typeof service.processor === 'undefined') + service.processor = netdata.processors.http; if(typeof service.update_every === 'undefined') service.update_every = service.module.update_every; @@ -178,12 +183,12 @@ var netdata = { if(typeof service.update_every === 'undefined') service.update_every = netdata.options.update_every; - if(typeof service.processor === 'undefined') - service.processor = netdata.processors.http; - if(service.update_every < netdata.options.update_every) service.update_every = netdata.options.update_every; + // align the runs + service.next_run = now - (now % (service.update_every * 1000)); + service.commit = function() { if(this.added !== true) { this.added = true; @@ -272,7 +277,7 @@ 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.category + '" "' + chart.type + '" ' + chart.priority.toString() + ' ' + chart.update_every.toString()); + 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]; @@ -387,9 +392,9 @@ var netdata = { title: 'untitled chart', units: 'a unit', family: '', - category: '', + context: '', type: netdata.chartTypes.line, - priority: 0, + priority: 50000, update_every: netdata.options.update_every, dimensions: {} }; @@ -421,9 +426,9 @@ var netdata = { c._updated = true; } - if(typeof(chart.category) !== 'undefined' && chart.category !== c.category) { - if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its category'); - c.category = chart.category; + if(typeof(chart.context) !== 'undefined' && chart.context !== c.context) { + if(netdata.options.DEBUG === true) netdata.debug('chart ' + id + ' updated its context'); + c.context = chart.context; c._updated = true; } |