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