]> arthur.barton.de Git - netdata.git/blob - node.d/named.node.js
Merge pull request #138 from clickthisnick/chore-remove-trailing-spaces
[netdata.git] / node.d / named.node.js
1 'use strict';
2
3 // collect statistics from bind (named) v9.10+
4 //
5 // bind statistics documentation at:
6 // http://jpmens.net/2013/03/18/json-in-bind-9-s-statistics-server/
7 // https://ftp.isc.org/isc/bind/9.10.3/doc/arm/Bv9ARM.ch06.html#statistics
8
9 // example configuration in /etc/netdata/named.conf
10 // the module supports auto-detection if bind is running in localhost
11
12 /*
13 {
14         "enable_autodetect": true,
15         "update_every": 5,
16         "servers": [
17                 {
18                         "name": "bind1",
19                         "url": "http://127.0.0.1:8888/json/v1/server",
20                         "update_every": 1
21                 },
22                 {
23                         "name": "bind2",
24                         "url": "http://10.0.0.1:8888/xml/v3/server",
25                         "update_every": 2
26                 }
27         ]
28 }
29 */
30
31 // the following is the bind named.conf configuration required
32
33 /*
34 statistics-channels {
35         inet 127.0.0.1 port 8888 allow { 127.0.0.1; };
36 };
37 */
38
39 var url = require('url');
40 var http = require('http');
41 var XML = require('pixl-xml');
42 var netdata = require('netdata');
43
44 if(netdata.options.DEBUG === true) netdata.debug('loaded ' + __filename + ' plugin');
45
46 var named = {
47         name: __filename,
48         enable_autodetect: true,
49         update_every: 1,
50         base_priority: 60000,
51         charts: {},
52
53         chartFromMembersCreate: function(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor) {
54                 var chart = {
55                         id: id,                                                                                 // the unique id of the chart
56                         name: '',                                                                               // the unique name of the chart
57                         title: service.name + ' ' + title_suffix,               // the title of the chart
58                         units: units,                                                                   // the units of the chart dimensions
59                         family: family,                                                                 // the family of the chart
60                         context: context,                                                               // the context of the chart
61                         type: type,                                                                             // the type of the chart
62                         priority: priority,                                                             // the priority relative to others in the same family
63                         update_every: service.update_every,                     // the expected update frequency of the chart
64                         dimensions: {}
65                 }
66
67                 var found = 0;
68                 for(var x in obj) {
69                         if(typeof(obj[x]) !== 'undefined' && obj[x] !== 0) {
70                                 found++;
71                                 chart.dimensions[x] = {
72                                         id: x,                                  // the unique id of the dimension
73                                         name: x,                                // the name of the dimension
74                                         algorithm: algorithm,   // the id of the netdata algorithm
75                                         multiplier: multiplier, // the multiplier
76                                         divisor: divisor,               // the divisor
77                                         hidden: false                   // is hidden (boolean)
78                                 }
79                         }
80                 }
81
82                 if(found === false)
83                         return null;
84
85                 chart = service.chart(id, chart);
86                 this.charts[id] = chart;
87                 return chart;
88         },
89
90         chartFromMembers: function(service, obj, id_suffix, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor) {
91                 var id = 'named_' + service.name + '.' + id_suffix;
92                 var chart = this.charts[id];
93
94                 if(typeof chart === 'undefined') {
95                         chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
96                         if(chart === null) return false;
97                 }
98                 else {
99                         // check if we need to re-generate the chart
100                         for(var x in obj) {
101                                 if(typeof(chart.dimensions[x]) === 'undefined') {
102                                         chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
103                                         if(chart === null) return false;
104                                         break;
105                                 }
106                         }
107                 }
108
109                 var found = 0;
110                 service.begin(chart);
111                 for(var x in obj) {
112                         if(typeof(chart.dimensions[x]) !== 'undefined') {
113                                 found++;
114                                 service.set(x, obj[x]);
115                         }
116                 }
117                 service.end();
118
119                 if(found > 0) return true;
120                 return false;
121         },
122
123         // an index to map values to different charts
124         lookups: {
125                 nsstats: {},
126                 resolver_stats: {},
127                 numfetch: {}
128         },
129
130         // transform the XML response of bind
131         // to the JSON response of bind
132         xml2js: function(service, data_xml) {
133                 var d = XML.parse(data_xml);
134                 if(d === null) return null;
135
136                 var data = {};
137                 var len = d.server.counters.length;
138                 while(len--) {
139                         var a = d.server.counters[len];
140                         if(typeof a.counter === 'undefined') continue;
141                         if(a.type === 'opcode') a.type = 'opcodes';
142                         else if(a.type === 'qtype') a.type = 'qtypes';
143                         else if(a.type === 'nsstat') a.type = 'nsstats';
144                         var aa = data[a.type] = {};
145                         var alen = 0
146                         var alen2 = a.counter.length;
147                         while(alen < alen2) {
148                                 aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data);
149                                 alen++;
150                         }
151                 }
152
153                 data.views = {};
154                 var vlen = d.views.view.length;
155                 while(vlen--) {
156                         var vname = d.views.view[vlen].name;
157                         data.views[vname] = { resolver: {} };
158                         var len = d.views.view[vlen].counters.length;
159                         while(len--) {
160                                 var a = d.views.view[vlen].counters[len];
161                                 if(typeof a.counter === 'undefined') continue;
162                                 if(a.type === 'resstats') a.type = 'stats';
163                                 else if(a.type === 'resqtype') a.type = 'qtypes';
164                                 else if(a.type === 'adbstat') a.type = 'adb';
165                                 var aa = data.views[vname].resolver[a.type] = {};
166                                 var alen = 0;
167                                 var alen2 = a.counter.length;
168                                 while(alen < alen2) {
169                                         aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data);
170                                         alen++;
171                                 }
172                         }
173                 }
174
175                 return data;
176         },
177
178         processResponse: function(service, data) {
179                 if(data !== null) {
180                         var r;
181
182                         // parse XML or JSON
183                         // pepending on the URL given
184                         if(service.request.path.match(/^\/xml/) !== null)
185                                 r = named.xml2js(service, data);
186                         else
187                                 r = JSON.parse(data);
188
189                         if(typeof r === 'undefined' || r === null) {
190                                 netdata.serviceError(service, "Cannot parse these data: " + data);
191                                 return;
192                         }
193
194                         if(service.added !== true)
195                                 service.commit();
196
197                         if(typeof r.nsstats !== 'undefined') {
198                                 // we split the nsstats object to several others
199                                 var global_requests = {}, global_requests_enable = false;
200                                 var global_failures = {}, global_failures_enable = false;
201                                 var global_failures_detail = {}, global_failures_detail_enable = false;
202                                 var global_updates = {}, global_updates_enable = false;
203                                 var protocol_queries = {}, protocol_queries_enable = false;
204                                 var global_queries = {}, global_queries_enable = false;
205                                 var global_queries_success = {}, global_queries_success_enable = false;
206                                 var default_enable = false;
207                                 var RecursClients = 0;
208
209                                 // RecursClients is an absolute value
210                                 if(typeof r.nsstats['RecursClients'] !== 'undefined') {
211                                         RecursClients = r.nsstats['RecursClients'];
212                                         delete r.nsstats['RecursClients'];
213                                 }
214
215                                 for( var x in r.nsstats ) {
216                                         // we maintain an index of the values found
217                                         // mapping them to objects splitted
218
219                                         var look = named.lookups.nsstats[x];
220                                         if(typeof look === 'undefined') {
221                                                 // a new value, not found in the index
222                                                 // index it:
223                                                 if(x === 'Requestv4') {
224                                                         named.lookups.nsstats[x] = {
225                                                                 name: 'IPv4',
226                                                                 type: 'global_requests'
227                                                         };
228                                                 }
229                                                 else if(x === 'Requestv6') {
230                                                         named.lookups.nsstats[x] = {
231                                                                 name: 'IPv6',
232                                                                 type: 'global_requests'
233                                                         };
234                                                 }
235                                                 else if(x === 'QryFailure') {
236                                                         named.lookups.nsstats[x] = {
237                                                                 name: 'failures',
238                                                                 type: 'global_failures'
239                                                         };
240                                                 }
241                                                 else if(x === 'QryUDP') {
242                                                         named.lookups.nsstats[x] = {
243                                                                 name: 'UDP',
244                                                                 type: 'protocol_queries'
245                                                         };
246                                                 }
247                                                 else if(x === 'QryTCP') {
248                                                         named.lookups.nsstats[x] = {
249                                                                 name: 'TCP',
250                                                                 type: 'protocol_queries'
251                                                         };
252                                                 }
253                                                 else if(x === 'QrySuccess') {
254                                                         named.lookups.nsstats[x] = {
255                                                                 name: 'queries',
256                                                                 type: 'global_queries_success'
257                                                         };
258                                                 }
259                                                 else if(x.match(/QryRej$/) !== null) {
260                                                         named.lookups.nsstats[x] = {
261                                                                 name: x,
262                                                                 type: 'global_failures_detail'
263                                                         };
264                                                 }
265                                                 else if(x.match(/^Qry/) !== null) {
266                                                         named.lookups.nsstats[x] = {
267                                                                 name: x,
268                                                                 type: 'global_queries'
269                                                         };
270                                                 }
271                                                 else if(x.match(/^Update/) !== null) {
272                                                         named.lookups.nsstats[x] = {
273                                                                 name: x,
274                                                                 type: 'global_updates'
275                                                         };
276                                                 }
277                                                 else {
278                                                         // values not mapped, will remain
279                                                         // in the default map
280                                                         named.lookups.nsstats[x] = {
281                                                                 name: x,
282                                                                 type: 'default'
283                                                         };
284                                                 }
285
286                                                 look = named.lookups.nsstats[x];
287                                                 // netdata.error('lookup nsstats value: ' + x + ' >>> ' + named.lookups.nsstats[x].type);
288                                         }
289
290                                         switch(look.type) {
291                                                 case 'global_requests': global_requests[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_requests_enable = true; break;
292                                                 case 'global_queries': global_queries[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_queries_enable = true; break;
293                                                 case 'global_queries_success': global_queries_success[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_queries_success_enable = true; break;
294                                                 case 'global_updates': global_updates[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_updates_enable = true; break;
295                                                 case 'protocol_queries': protocol_queries[look.name] = r.nsstats[x]; delete r.nsstats[x]; protocol_queries_enable = true; break;
296                                                 case 'global_failures': global_failures[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_failures_enable = true; break;
297                                                 case 'global_failures_detail': global_failures_detail[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_failures_detail_enable = true; break;
298                                                 default: default_enable = true; break;
299                                         }
300                                 }
301
302                                 if(global_requests_enable == true)
303                                         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);
304
305                                 if(global_queries_success_enable == true)
306                                         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);
307
308                                 if(protocol_queries_enable == true)
309                                         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);
310
311                                 if(global_queries_enable == true)
312                                         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);
313
314                                 if(global_updates_enable == true)
315                                         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);
316
317                                 if(global_failures_enable == true)
318                                         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);
319
320                                 if(global_failures_detail_enable == true)
321                                         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);
322
323                                 if(default_enable === true)
324                                         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);
325
326                                 // RecursClients chart
327                                 {
328                                         var id = 'named_' + service.name + '.recursive_clients';
329                                         var chart = named.charts[id];
330
331                                         if(typeof chart === 'undefined') {
332                                                 chart = {
333                                                         id: id,                                                                                 // the unique id of the chart
334                                                         name: '',                                                                               // the unique name of the chart
335                                                         title: service.name + ' Bind, Current Recursive Clients',               // the title of the chart
336                                                         units: 'clients',                                                               // the units of the chart dimensions
337                                                         family: 'clients',                                                              // the family of the chart
338                                                         context: 'named.recursive.clients',                             // the context of the chart
339                                                         type: netdata.chartTypes.line,                                  // the type of the chart
340                                                         priority: named.base_priority + 1,                              // the priority relative to others in the same family
341                                                         update_every: service.update_every,                             // the expected update frequency of the chart
342                                                         dimensions: {
343                                                                 'clients': {
344                                                                         id: 'clients',                                                          // the unique id of the dimension
345                                                                         name: '',                                                                       // the name of the dimension
346                                                                         algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
347                                                                         multiplier: 1,                                                          // the multiplier
348                                                                         divisor: 1,                                                                     // the divisor
349                                                                         hidden: false                                                           // is hidden (boolean)
350                                                                 }
351                                                         }
352                                                 };
353
354                                                 chart = service.chart(id, chart);
355                                                 named.charts[id] = chart;
356                                         }
357
358                                         service.begin(chart);
359                                         service.set('clients', RecursClients);
360                                         service.end();
361                                 }
362                         }
363
364                         if(typeof r.opcodes !== 'undefined')
365                                 service.module.chartFromMembers(service, r.opcodes, 'in_opcodes', 'Bind, Global Incoming Requests by OpCode', 'requests/s', 'requests', 'named.in.opcodes', netdata.chartTypes.stacked, named.base_priority + 9, netdata.chartAlgorithms.incremental, 1, 1);
366
367                         if(typeof r.qtypes !== 'undefined')
368                                 service.module.chartFromMembers(service, r.qtypes, 'in_qtypes', 'Bind, Global Incoming Requests by Query Type', 'requests/s', 'requests', 'named.in.qtypes', netdata.chartTypes.stacked, named.base_priority + 10, netdata.chartAlgorithms.incremental, 1, 1);
369
370                         if(typeof r.sockstats !== 'undefined')
371                                 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);
372
373                         if(typeof r.views !== 'undefined') {
374                                 for( var x in r.views ) {
375                                         var resolver = r.views[x].resolver;
376
377                                         if(typeof resolver !== 'undefined') {
378                                                 if(typeof resolver.stats !== 'undefined') {
379                                                         var NumFetch = 0;
380                                                         var key = service.name + '.' + x;
381                                                         var default_enable = false;
382                                                         var rtt = {}, rtt_enable = false;
383
384                                                         // NumFetch is an absolute value
385                                                         if(typeof resolver.stats['NumFetch'] !== 'undefined') {
386                                                                 named.lookups.numfetch[key] = true;
387                                                                 NumFetch = resolver.stats['NumFetch'];
388                                                                 delete resolver.stats['NumFetch'];
389                                                         }
390                                                         if(typeof resolver.stats['BucketSize'] !== 'undefined') {
391                                                                 delete resolver.stats['BucketSize'];
392                                                         }
393
394                                                         // split the QryRTT* from the main chart
395                                                         for( var y in resolver.stats ) {
396                                                                 // we maintain an index of the values found
397                                                                 // mapping them to objects splitted
398
399                                                                 var look = named.lookups.resolver_stats[y];
400                                                                 if(typeof look === 'undefined') {
401                                                                         if(y.match(/^QryRTT/) !== null) {
402                                                                                 named.lookups.resolver_stats[y] = {
403                                                                                         name: y,
404                                                                                         type: 'rtt'
405                                                                                 };
406                                                                         }
407                                                                         else {
408                                                                                 named.lookups.resolver_stats[y] = {
409                                                                                         name: y,
410                                                                                         type: 'default'
411                                                                                 };
412                                                                         }
413
414                                                                         look = named.lookups.resolver_stats[y];
415                                                                         // netdata.error('lookup resolver stats value: ' + y + ' >>> ' + look.type);
416                                                                 }
417
418                                                                 switch(look.type) {
419                                                                         case 'rtt': rtt[look.name] = resolver.stats[y]; delete resolver.stats[y]; rtt_enable = true; break;
420                                                                         default: default_enable = true; break;
421                                                                 }
422                                                         }
423
424                                                         if(rtt_enable)
425                                                                 service.module.chartFromMembers(service, rtt, 'view_resolver_rtt_' + x, 'Bind, ' + x + ' View, Resolver Round Trip Timings', 'queries/s', 'view_' + x, 'named.resolver.rtt', netdata.chartTypes.stacked, named.base_priority + 12, netdata.chartAlgorithms.incremental, 1, 1);
426
427                                                         if(default_enable)
428                                                                 service.module.chartFromMembers(service, resolver.stats, 'view_resolver_stats_' + x, 'Bind, ' + x + ' View, Resolver Statistics', 'operations/s', 'view_' + x, 'named.resolver.stats', netdata.chartTypes.line, named.base_priority + 13, netdata.chartAlgorithms.incremental, 1, 1);
429
430                                                         // NumFetch chart
431                                                         if(typeof named.lookups.numfetch[key] !== 'undefined') {
432                                                                 var id = 'named_' + service.name + '.view_resolver_numfetch_' + x;
433                                                                 var chart = named.charts[id];
434
435                                                                 if(typeof chart === 'undefined') {
436                                                                         chart = {
437                                                                                 id: id,                                                                                 // the unique id of the chart
438                                                                                 name: '',                                                                               // the unique name of the chart
439                                                                                 title: service.name + ' Bind, ' + x + ' View, Resolver Active Queries',         // the title of the chart
440                                                                                 units: 'queries',                                                               // the units of the chart dimensions
441                                                                                 family: 'view_' + x,                                                    // the family of the chart
442                                                                                 context: 'named.resolver.active.queries',               // the context of the chart
443                                                                                 type: netdata.chartTypes.line,                                  // the type of the chart
444                                                                                 priority: named.base_priority + 1001,                   // the priority relative to others in the same family
445                                                                                 update_every: service.update_every,                             // the expected update frequency of the chart
446                                                                                 dimensions: {
447                                                                                         'queries': {
448                                                                                                 id: 'queries',                                                          // the unique id of the dimension
449                                                                                                 name: '',                                                                       // the name of the dimension
450                                                                                                 algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
451                                                                                                 multiplier: 1,                                                          // the multiplier
452                                                                                                 divisor: 1,                                                                     // the divisor
453                                                                                                 hidden: false                                                           // is hidden (boolean)
454                                                                                         }
455                                                                                 }
456                                                                         };
457
458                                                                         chart = service.chart(id, chart);
459                                                                         named.charts[id] = chart;
460                                                                 }
461
462                                                                 service.begin(chart);
463                                                                 service.set('queries', NumFetch);
464                                                                 service.end();
465                                                         }
466                                                 }
467                                         }
468
469                                         if(typeof resolver.qtypes !== 'undefined')
470                                                 service.module.chartFromMembers(service, resolver.qtypes, 'view_resolver_qtypes_' + x, 'Bind, ' + x + ' View, Requests by Query Type', 'requests/s', 'view_' + x, 'named.resolver.qtypes', netdata.chartTypes.stacked, named.base_priority + 14, netdata.chartAlgorithms.incremental, 1, 1);
471
472                                         //if(typeof resolver.cache !== 'undefined')
473                                         //      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);
474
475                                         if(typeof resolver.cachestats['CacheHits'] !== 'undefined' && resolver.cachestats['CacheHits'] > 0) {
476                                                 var id = 'named_' + service.name + '.view_resolver_cachehits_' + x;
477                                                 var chart = named.charts[id];
478
479                                                 if(typeof chart === 'undefined') {
480                                                         chart = {
481                                                                 id: id,                                                                                 // the unique id of the chart
482                                                                 name: '',                                                                               // the unique name of the chart
483                                                                 title: service.name + ' Bind, ' + x + ' View, Resolver Cache Hits',             // the title of the chart
484                                                                 units: 'operations/s',                                                  // the units of the chart dimensions
485                                                                 family: 'view_' + x,                                                    // the family of the chart
486                                                                 context: 'named.resolver.cache.hits',                   // the context of the chart
487                                                                 type: netdata.chartTypes.area,                                  // the type of the chart
488                                                                 priority: named.base_priority + 1100,                   // the priority relative to others in the same family
489                                                                 update_every: service.update_every,                             // the expected update frequency of the chart
490                                                                 dimensions: {
491                                                                         'CacheHits': {
492                                                                                 id: 'CacheHits',                                                        // the unique id of the dimension
493                                                                                 name: 'hits',                                                           // the name of the dimension
494                                                                                 algorithm: netdata.chartAlgorithms.incremental,// the id of the netdata algorithm
495                                                                                 multiplier: 1,                                                          // the multiplier
496                                                                                 divisor: 1,                                                                     // the divisor
497                                                                                 hidden: false                                                           // is hidden (boolean)
498                                                                         },
499                                                                         'CacheMisses': {
500                                                                                 id: 'CacheMisses',                                                      // the unique id of the dimension
501                                                                                 name: 'misses',                                                         // the name of the dimension
502                                                                                 algorithm: netdata.chartAlgorithms.incremental,// the id of the netdata algorithm
503                                                                                 multiplier: -1,                                                         // the multiplier
504                                                                                 divisor: 1,                                                                     // the divisor
505                                                                                 hidden: false                                                           // is hidden (boolean)
506                                                                         }
507                                                                 }
508                                                         };
509
510                                                         chart = service.chart(id, chart);
511                                                         named.charts[id] = chart;
512                                                 }
513
514                                                 service.begin(chart);
515                                                 service.set('CacheHits', resolver.cachestats['CacheHits']);
516                                                 service.set('CacheMisses', resolver.cachestats['CacheMisses']);
517                                                 service.end();
518                                         }
519
520                                         // this is wrong, it contains many types of info:
521                                         // 1. CacheHits, CacheMisses - incremental (added above)
522                                         // 2. QueryHits, QueryMisses - incremental
523                                         // 3. DeleteLRU, DeleteTTL - incremental
524                                         // 4. CacheNodes, CacheBuckets - absolute
525                                         // 5. TreeMemTotal, TreeMemInUse - absolute
526                                         // 6. HeapMemMax, HeapMemTotal, HeapMemInUse - absolute
527                                         //if(typeof resolver.cachestats !== 'undefined')
528                                         //      service.module.chartFromMembers(service, resolver.cachestats, 'view_resolver_cachestats_' + x, 'Bind, ' + x + ' View, Cache Statistics', 'requests/s', 'view_' + x, 'named.resolver.cache.stats', netdata.chartTypes.line, named.base_priority + 1001, netdata.chartAlgorithms.incremental, 1, 1);
529
530                                         //if(typeof resolver.adb !== 'undefined')
531                                         //      service.module.chartFromMembers(service, resolver.adb, 'view_resolver_adb_' + x, 'Bind, ' + x + ' View, ADB Statistics', 'entries', 'view_' + x, 'named.resolver.adb', netdata.chartTypes.line, named.base_priority + 1002, netdata.chartAlgorithms.absolute, 1, 1);
532                                 }
533                         }
534                 }
535         },
536
537         // module.serviceExecute()
538         // this function is called only from this module
539         // its purpose is to prepare the request and call
540         // netdata.serviceExecute()
541         serviceExecute: function(name, a_url, update_every) {
542                 if(netdata.options.DEBUG === true) netdata.debug(this.name + ': ' + name + ': url: ' + a_url + ', update_every: ' + update_every);
543                 var service = netdata.service({
544                         name: name,
545                         request: netdata.requestFromURL(a_url),
546                         update_every: update_every,
547                         module: this
548                 });
549
550                 service.execute(this.processResponse);
551         },
552
553         configure: function(config) {
554                 var added = 0;
555
556                 if(this.enable_autodetect === true) {
557                         this.serviceExecute('local', 'http://localhost:8888/json/v1/server', this.update_every);
558                         added++;
559                 }
560                 
561                 if(typeof(config.servers) !== 'undefined') {
562                         var len = config.servers.length;
563                         while(len--) {
564                                 if(typeof config.servers[len].update_every === 'undefined')
565                                         config.servers[len].update_every = this.update_every;
566
567                                 this.serviceExecute(config.servers[len].name, config.servers[len].url, config.servers[len].update_every);
568                                 added++;
569                         }
570                 }
571
572                 return added;
573         },
574
575         // module.update()
576         // this is called repeatidly to collect data, by calling
577         // netdata.serviceExecute()
578         update: function(service, callback) {
579                 service.execute(function(serv, data) {
580                         service.module.processResponse(serv, data);
581                         callback();
582                 });
583         },
584 };
585
586 module.exports = named;