-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (37 loc) · 713 Bytes
/
index.js
File metadata and controls
45 lines (37 loc) · 713 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
35
36
37
38
39
40
41
42
43
44
45
var _param = require('./param.json');
var _du = require('diskspace');
var pollInterval = _param.pollInterval || 3000;
var c;
var smallestDev;
var smallest;
function checkFnc(dev)
{
return function(error, total, free, status)
{
if (!error) {
var perc = 1.0 - (free / total);
if (!smallest || smallest < perc)
{
smallest = perc;
smallestDev = dev;
}
if (!--c)
{
console.log('DISKUSE_SUMMARY %d', smallest);
}
} else {
--c;
}
}
}
function poll()
{
c = process.argv.length - 3;
smallestDev = null;
smallest = null;
for (var i = 3; i < process.argv.length; i++)
{
_du.check(process.argv[i], checkFnc(process.argv[i]));
}
}
setInterval(poll, pollInterval);