forked from coredump/hoardd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
df.coffee
23 lines (20 loc) · 910 Bytes
/
df.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Exec = require('child_process').exec
module.exports = (server) ->
run = () ->
metricPrefix = "#{server.fqdn}.df"
server.cli.debug "Running the plugin"
nameArray = [
'used', 'available', 'percent', 'mount_point'
]
# Depends on vmstat
# Timeouts on sampleInterval seconds, will cause problems with sampleIntervals too small
Exec 'df -P', { timeout: server.conf.sampleInterval * 1000}, (err, stdout, stderr) ->
lines = stdout.trim().split '\n'
statObj = {}
for line in lines
if line.match /^\//
statArray = line.replace(/%/, '').split(/\s+/)[2..]
statArray[3] = 'root' if statArray[3] == '/'
statObj[key] = statArray[i] for key, i in nameArray
server.push_metric("#{metricPrefix}.#{statObj.mount_point}.#{key}",
value) for key, value of statObj when key isnt 'mount_point'