diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java index 8c6c457b..09d898d5 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java @@ -74,6 +74,7 @@ public class Shell extends ShellBase { registerCommandHandler("mps", new MultiPs(this)); registerCommandHandler("sysinfo", new SysInfo(this)); registerCommandHandler("time", new Time(this)); + registerCommandHandler("ulimit", new Ulimit(this)); registerCommandHandler("who", new Who(this)); if (SigarLoader.IS_WIN32) { registerCommandHandler("service", new Win32Service(this)); diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java b/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java new file mode 100644 index 00000000..a1c6eb7b --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/cmd/Ulimit.java @@ -0,0 +1,58 @@ +package net.hyperic.sigar.cmd; + +import net.hyperic.sigar.ResourceLimit; +import net.hyperic.sigar.SigarException; + +/** + * Display system resource limits. + */ +public class Ulimit extends SigarCommandBase { + + public Ulimit(Shell shell) { + super(shell); + } + + public Ulimit() { + super(); + } + + public String getUsageShort() { + return "Display system resource limits"; + } + + private static String format(ResourceLimit rlimit, long val) { + if (val == rlimit.getUnlimited()) { + return "unlimited"; + } + else { + return String.valueOf(val); + } + } + + public void output(String[] args) throws SigarException { + ResourceLimit rlimit = this.sigar.getResourceLimit(); + + println("core file size......." + + format(rlimit, rlimit.getCoreCur())); + println("data seg size........" + + format(rlimit, rlimit.getDataCur())); + println("file size............" + + format(rlimit, rlimit.getFileSizeCur())); + println("max memory size......" + + format(rlimit, rlimit.getMemoryCur())); + println("open files..........." + + format(rlimit, rlimit.getOpenFilesCur())); + println("stack size..........." + + format(rlimit, rlimit.getStackCur())); + println("cpu time............." + + format(rlimit, rlimit.getCpuCur())); + println("max user processes..." + + format(rlimit, rlimit.getProcessesCur())); + println("virual memory........" + + format(rlimit, rlimit.getVirtualMemoryCur())); + } + + public static void main(String[] args) throws Exception { + new Ulimit().processCommand(args); + } +}