add ulimit command
This commit is contained in:
parent
5b68d679a7
commit
545ec710e4
|
@ -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));
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue