-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathretriever.js
executable file
·41 lines (36 loc) · 1.01 KB
/
retriever.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
#!/usr/bin/env node
/* Copyright (C) 2012 Igalia S.L.
*
* Author: Javier Fernandez Garcia-Boente <jfernandez@igalia.com>
*
* Licensed under the MIT license */
var nodestat = require('node-stat');
var redis = require('redis').createClient();
function insert(data) {
var sysInfo = JSON.parse(data);
var time = new Date().getTime();
var stat = JSON.stringify(sysInfo.stat);
var net = JSON.stringify(sysInfo.net);
var load = JSON.stringify(sysInfo.load);
redis.multi()
.zadd('stat', time, stat)
.zadd('net', time, net)
.zadd('load', time, load)
.exec(function(err, reply) {
if(err) {
console.error('redis: '+ err);
}
});
}
setInterval(function() {
nodestat.get('stat','net','load', function(err, data) {
console.log(data);
var time = new Date().getTime();
data.id = 'localhost:'+time;
redis.zadd('localhost', time, JSON.stringify(data), function(err, reply) {
if(err) {
console.error('redis: '+ err);
}
});
});
}, 1000);