add du command

This commit is contained in:
Doug MacEachern 2005-12-14 02:59:05 +00:00
parent 2e7bb972fd
commit 7162f1c590
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package net.hyperic.sigar.cmd;
import net.hyperic.sigar.DirUsage;
import net.hyperic.sigar.SigarException;
/**
* Display usage for a directory recursively
*/
public class Du extends SigarCommandBase {
public Du(Shell shell) {
super(shell);
}
public Du() {
super();
}
public String getUsageShort() {
return "Display usage for a directory recursively";
}
protected boolean validateArgs(String[] args) {
return args.length == 1;
}
public void output(String[] args) throws SigarException {
String dir = args[0];
DirUsage du = this.sigar.getDirUsage(dir);
println(du.getDiskUsage() + "\t" + dir);
}
public static void main(String[] args) throws Exception {
new Du().processCommand(args);
}
}

View File

@ -60,6 +60,7 @@ public class Shell extends ShellBase {
public void registerCommands() throws ShellCommandInitException {
registerCommandHandler("df", new Df(this));
registerCommandHandler("du", new Du(this));
registerCommandHandler("iostat", new Iostat(this));
registerCommandHandler("free", new Free(this));
registerCommandHandler("pargs", new ShowArgs(this));