Created
August 31, 2011 01:14
-
-
Save chrisboulton/1182578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Plugin, Plugin_Disk_Space, exec; | |
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { | |
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } | |
function ctor() { this.constructor = child; } | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor; | |
child.__super__ = parent.prototype; | |
return child; | |
}, __slice = Array.prototype.slice, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | |
exec = require('child_process').exec; | |
Plugin = require('../plugin').Plugin; | |
module.exports = Plugin_Disk_Space = (function() { | |
__extends(Plugin_Disk_Space, Plugin); | |
function Plugin_Disk_Space() { | |
Plugin_Disk_Space.__super__.constructor.apply(this, arguments); | |
} | |
Plugin_Disk_Space.prototype.collect = function() { | |
var df; | |
return df = exec('df -P -l', __bind(function(err, stdout, stderr) { | |
var avail, fs, head, junk, line, mount, mounts, total, used, _i, _len, _ref, _ref2, _results; | |
_ref = stdout.split("\n"), head = _ref[0], mounts = 2 <= _ref.length ? __slice.call(_ref, 1) : []; | |
_results = []; | |
for (_i = 0, _len = mounts.length; _i < _len; _i++) { | |
line = mounts[_i]; | |
if (!line) { | |
continue; | |
} | |
_ref2 = line.match(/[^\s]+/g), fs = _ref2[0], total = _ref2[1], used = _ref2[2], avail = _ref2[3], junk = _ref2[4], mount = _ref2[5]; | |
fs = fs.replace(/[^a-z0-9\-_]/ig, '_'); | |
mount = mount.replace(/[^a-z0-9\-_]/ig, '_'); | |
_results.push(this.submit(['gauge', 'device.' + fs + '.total', total], ['gauge', 'device.' + fs + '.used', used], ['gauge', 'mount.' + mount + '.total', total], ['gauge', 'mount.' + mount + '.used', used])); | |
} | |
return _results; | |
}, this)); | |
}; | |
return Plugin_Disk_Space; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment