add ulimit command

This commit is contained in:
Doug MacEachern 2005-07-08 01:25:06 +00:00
parent 5b68d679a7
commit 545ec710e4
2 changed files with 59 additions and 0 deletions

View File

@ -74,6 +74,7 @@ public class Shell extends ShellBase {
registerCommandHandler("mps", new MultiPs(this)); registerCommandHandler("mps", new MultiPs(this));
registerCommandHandler("sysinfo", new SysInfo(this)); registerCommandHandler("sysinfo", new SysInfo(this));
registerCommandHandler("time", new Time(this)); registerCommandHandler("time", new Time(this));
registerCommandHandler("ulimit", new Ulimit(this));
registerCommandHandler("who", new Who(this)); registerCommandHandler("who", new Who(this));
if (SigarLoader.IS_WIN32) { if (SigarLoader.IS_WIN32) {
registerCommandHandler("service", new Win32Service(this)); registerCommandHandler("service", new Win32Service(this));

View File

@ -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);
}
}