add du command
This commit is contained in:
parent
2e7bb972fd
commit
7162f1c590
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ public class Shell extends ShellBase {
|
||||||
|
|
||||||
public void registerCommands() throws ShellCommandInitException {
|
public void registerCommands() throws ShellCommandInitException {
|
||||||
registerCommandHandler("df", new Df(this));
|
registerCommandHandler("df", new Df(this));
|
||||||
|
registerCommandHandler("du", new Du(this));
|
||||||
registerCommandHandler("iostat", new Iostat(this));
|
registerCommandHandler("iostat", new Iostat(this));
|
||||||
registerCommandHandler("free", new Free(this));
|
registerCommandHandler("free", new Free(this));
|
||||||
registerCommandHandler("pargs", new ShowArgs(this));
|
registerCommandHandler("pargs", new ShowArgs(this));
|
||||||
|
|
Loading…
Reference in New Issue