This repository was archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmunin.js
42 lines (38 loc) · 1.44 KB
/
munin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var shared = require('./shared');
module.exports = function (service) {
var Munin = require('munin-client');
return function (funneler) {
var from = service.from;
// cast to array
if (typeof from == 'string') {
from = [from];
}
from.forEach(function (host) {
var munin = new Munin(host);
for (var sName in service.services) {
(function (serviceName) { // yum! delicious scope!
munin.fetch(serviceName, function(metrics) {
for (var metricName in metrics) {
var capture = false;
if (shared.ALL == service.services[serviceName]) {
capture = true;
} else if (service.services[serviceName].indexOf(metricName) !== -1) {
capture = true;
}
if (capture) {
funneler({
'funnel': 'munin',
'nodeName': host,
'serviceName': serviceName,
'metricName': metricName,
'reading': metrics[metricName]
});
}
}
});
})(sName);
}
munin.quit();
});
}
};