Skip to content

Instantly share code, notes, and snippets.

@chrisboulton
Created August 31, 2011 01:14
Show Gist options
  • Save chrisboulton/1182577 to your computer and use it in GitHub Desktop.
Save chrisboulton/1182577 to your computer and use it in GitHub Desktop.
exec = require('child_process').exec
{Plugin} = require '../plugin'
module.exports = class Plugin_Disk_Space extends Plugin
collect: ->
df = exec 'df -P -l', (err, stdout, stderr) =>
[head, mounts...] = stdout.split "\n"
for line in mounts
continue if not line
[fs, total, used, avail, junk, mount] = line.match(/[^\s]+/g)
fs = fs.replace(/[^a-z0-9\-_]/ig, '_')
mount = mount.replace(/[^a-z0-9\-_]/ig, '_')
@submit(
['gauge', 'device.' + fs + '.total', total],
['gauge', 'device.' + fs + '.used', used],
['gauge', 'mount.' + mount + '.total', total],
['gauge', 'mount.' + mount + '.used', used],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment