Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Geoff Flarity
committed
Feb 5, 2012
1 parent
41a4bc3
commit a4d6f8e
Showing
4 changed files
with
78 additions
and
55 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
// configuration | ||
var interval = 10*1000; | ||
var interval = 1*1000; | ||
var filesystem = "/"; | ||
var filesystem_name = "root"; | ||
|
||
//deps | ||
var child_process = require('child_process'); | ||
|
||
//code | ||
var on_exec_complete = function( err, stdout, stderr ) { | ||
|
||
var lines = stdout.split('\n'); | ||
var payload = lines[1]; | ||
|
||
var matches = payload.match(/(\d+)\%/ ); | ||
|
||
console.log(matches[1]); | ||
|
||
|
||
|
||
}; | ||
|
||
//our plugin main function | ||
module.exports = function( axon ) { | ||
|
||
var on_exec_complete = function( err, stdout, stderr ) { | ||
|
||
var lines = stdout.split('\n'); | ||
var payload = lines[1]; | ||
|
||
var matches = payload.match(/(\d+)\%/ ); | ||
|
||
if ( matches && matches[1] ) { | ||
capacity = matches[1]; | ||
axon.emit( 'data', 'filesystem.capacity.' + filesystem_name, capacity ); | ||
} | ||
else { | ||
axon.emit( 'error', 'match failed' ); | ||
} | ||
}; | ||
|
||
//this checks it | ||
var check_filesystem_usage = function() { | ||
child_process.exec( 'df ' + filesystem, on_exec_complete ); | ||
}; | ||
|
||
//this checks it | ||
var check_filesystem_usage = function() { | ||
child_process.exec( 'df ' + filesystem, on_exec_complete ); | ||
setInterval( check_filesystem_usage, interval ); | ||
}; | ||
|
||
|
||
//our plugin main function | ||
module.exports = function( config ) { | ||
|
||
setInterval( check_filesystem_usage, interval ); | ||
}; |
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