From 7162f1c590703c213afb27351c40a4b762de1599 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 14 Dec 2005 02:59:05 +0000 Subject: [PATCH] add du command --- .../java/src/net/hyperic/sigar/cmd/Du.java | 36 +++++++++++++++++++ .../java/src/net/hyperic/sigar/cmd/Shell.java | 1 + 2 files changed, 37 insertions(+) create mode 100644 bindings/java/src/net/hyperic/sigar/cmd/Du.java diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Du.java b/bindings/java/src/net/hyperic/sigar/cmd/Du.java new file mode 100644 index 00000000..ad533fb5 --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/cmd/Du.java @@ -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); + } +} diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java index 4b112236..17313874 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java @@ -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));