Skip to content

Commit

Permalink
Merge branch 'master' of github.com:walmartlabs/hapi
Browse files Browse the repository at this point in the history
  • Loading branch information
thegoleffect committed Aug 1, 2012
2 parents a737481 + 0cc0231 commit 4b8c7e3
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions lib/monitor/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,34 @@ OSMonitor.prototype.disk = function (filesystem, callback) {

filesystem = filesystem || '/';

ChildProcess.exec('df -m ' + filesystem + ' | tail -1 | awk \'{print $2 \",\" $3}\'', function (err, stdout, stderr) {

ChildProcess.exec('df -m ' + filesystem + ' | tail -1 | tr -s " "', function (err, stdout, stderr) {
if (err || stderr !== '') {

return callback(err || stderr);
}

// require('util').debug(stdout);
var values = stdout.replace(/\s/g, '').split(',')

var values = stdout.replace(/^\s+/g, '').split(' ')

if (isNaN(parseInt(values[0]))) {

var total = values[1];
var used = values[2];
} else {

var total = values[0];
var used = values[1]
}


var output = {

total: parseInt(values[0]),
used: parseInt(values[1])
total: parseInt(total),
used: parseInt(used)
};

return callback(null, output);

// return callback(null, stdout.replace(/\s/g, '').replace('%', ''));
});
};
Expand Down

0 comments on commit 4b8c7e3

Please sign in to comment.