-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathredishash.js
More file actions
executable file
·34 lines (33 loc) · 1015 Bytes
/
redishash.js
File metadata and controls
executable file
·34 lines (33 loc) · 1015 Bytes
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
#!/usr/bin/env node
var redis = require('redis');
var munin = require('munin-plugin');
var main = function(host, port, sources){
var rcl = redis.createClient(port, host);
var graphs = [];
sources.forEach(function(config){
var g = new munin.Graph(config['title'],config['label'],config['category']);
var Model = munin.selectModel(config['graph']);
rcl.hgetall(config['key'], function(err, val){
if(err){
return;
}
for(var key in val){
g.add(new Model(key).setValue(parseFloat(val[key])));
}
g.sortLabel();
});
graphs.push(g);
});
rcl.quit(function(err){
munin.create(graphs);
});
}
var dir = __filename.split('/');
dir.length = dir.length - 1;
var path = dir.join('/');
var jsonfile = path + '/' + munin.getScriptName() + ".json";
munin.jsonFileRead(jsonfile, function(err, val){
if(!err){
main(val.host, val.port, val.sources);
}
});