var webbox = {
name: __filename,
enable_autodetect: true,
- update_every: 1000,
-
+ update_every: 1,
+ base_priority: 60000,
charts: {},
processResponse: function(service, data) {
// add the service
if(found > 0 && service.added !== true)
- netdata.serviceAdd(service);
+ service.commit();
// Grid Current Power Chart
if(d['GriPwr'].value !== null) {
name: '', // the unique name of the chart
title: service.name + ' Current Grid Power', // the title of the chart
units: d['GriPwr'].unit, // the units of the chart dimensions
- family: 'sma_webbox_' + service.name, // the family of the chart
- category: 'sma_webbox_' + service.name, // the category of the chart
+ family: 'now', // the family of the chart
+ context: 'sma_webbox.grid.power', // the context of the chart
type: netdata.chartTypes.area, // the type of the chart
- priority: 1000, // the priority relative to others in the same family and category
- update_every: Math.round(service.update_every / 1000), // the expected update frequency of the chart
+ priority: webbox.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: {
'GriPwr': {
id: 'GriPwr', // the unique id of the dimension
name: '', // the unique name of the chart
title: service.name + ' Today Grid Power', // the title of the chart
units: d['GriEgyTdy'].unit, // the units of the chart dimensions
- family: 'sma_webbox_' + service.name, // the family of the chart
- category: 'sma_webbox_' + service.name, // the category of the chart
+ family: 'today', // the family of the chart
+ context: 'sma_webbox.grid.power.today', // the context of the chart
type: netdata.chartTypes.area, // the type of the chart
- priority: 1000, // the priority relative to others in the same family and category
- update_every: Math.round(service.update_every / 1000), // the expected update frequency of the chart
+ priority: webbox.base_priority + 2, // the priority relative to others in the same family
+ update_every: service.update_every, // the expected update frequency of the chart
dimensions: {
'GriEgyTdy': {
id: 'GriEgyTdy', // the unique id of the dimension
name: '', // the unique name of the chart
title: service.name + ' Total Grid Power', // the title of the chart
units: d['GriEgyTot'].unit, // the units of the chart dimensions
- family: 'sma_webbox_' + service.name, // the family of the chart
- category: 'sma_webbox_' + service.name, // the category of the chart
+ family: 'total', // the family of the chart
+ context: 'sma_webbox.grid.power.total', // the context of the chart
type: netdata.chartTypes.area, // the type of the chart
- priority: 1000, // the priority relative to others in the same family and category
- update_every: Math.round(service.update_every / 1000), // the expected update frequency of the chart
+ priority: webbox.base_priority + 3, // the priority relative to others in the same family
+ update_every: service.update_every, // the expected update frequency of the chart
dimensions: {
'GriEgyTot': {
id: 'GriEgyTot', // the unique id of the dimension
serviceExecute: function(name, hostname, update_every) {
if(netdata.options.DEBUG === true) netdata.debug(this.name + ': ' + name + ': hostname: ' + hostname + ', update_every: ' + update_every);
- var service = {
+ var service = netdata.service({
name: name,
request: netdata.requestFromURL('http://' + hostname + '/rpc'),
update_every: update_every,
module: this
- };
+ });
service.postData = 'RPC={"proc":"GetPlantOverview","format":"JSON","version":"1.0","id":"1"}';
service.request.method = 'POST';
service.request.headers['Content-Length'] = service.postData.length;
- netdata.serviceExecute(service, this.processResponse);
+ service.execute(this.processResponse);
},
configure: function(config) {
while(len--) {
if(typeof config.servers[len].update_every === 'undefined')
config.servers[len].update_every = this.update_every;
- else
- config.servers[len].update_every = config.servers[len].update_every * 1000;
- if(config.servers[len].update_every < 5000)
- config.servers[len].update_every = 5000;
+ if(config.servers[len].update_every < 5)
+ config.servers[len].update_every = 5;
this.serviceExecute(config.servers[len].name, config.servers[len].hostname, config.servers[len].update_every);
added++;
// this is called repeatidly to collect data, by calling
// netdata.serviceExecute()
update: function(service, callback) {
- netdata.serviceExecute(service, function(serv, data) {
+ service.execute(function(serv, data) {
service.module.processResponse(serv, data);
callback();
});