use -s to test single-process ptql queries
This commit is contained in:
parent
4b5a270033
commit
84dcdd1fa6
|
@ -26,6 +26,8 @@ import org.hyperic.sigar.SigarPermissionDeniedException;
|
||||||
*/
|
*/
|
||||||
public class ProcInfo extends SigarCommandBase {
|
public class ProcInfo extends SigarCommandBase {
|
||||||
|
|
||||||
|
private boolean isSingleProcess;
|
||||||
|
|
||||||
public ProcInfo(Shell shell) {
|
public ProcInfo(Shell shell) {
|
||||||
super(shell);
|
super(shell);
|
||||||
}
|
}
|
||||||
|
@ -47,11 +49,28 @@ public class ProcInfo extends SigarCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void output(String[] args) throws SigarException {
|
public void output(String[] args) throws SigarException {
|
||||||
|
this.isSingleProcess = false;
|
||||||
|
|
||||||
|
if ((args.length != 0) && args[0].startsWith("-s")) {
|
||||||
|
this.isSingleProcess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isSingleProcess) {
|
||||||
|
for (int i=1; i<args.length; i++) {
|
||||||
|
try {
|
||||||
|
output(args[i]);
|
||||||
|
} catch (SigarException e) {
|
||||||
|
println("(" + e.getMessage() + ")");
|
||||||
|
}
|
||||||
|
println("\n------------------------\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
long[] pids = this.shell.findPids(args);
|
long[] pids = this.shell.findPids(args);
|
||||||
|
|
||||||
for (int i=0; i<pids.length; i++) {
|
for (int i=0; i<pids.length; i++) {
|
||||||
try {
|
try {
|
||||||
output(pids[i]);
|
output(String.valueOf(pids[i]));
|
||||||
} catch (SigarPermissionDeniedException e) {
|
} catch (SigarPermissionDeniedException e) {
|
||||||
println(this.shell.getUserDeniedMessage(pids[i]));
|
println(this.shell.getUserDeniedMessage(pids[i]));
|
||||||
} catch (SigarException e) {
|
} catch (SigarException e) {
|
||||||
|
@ -60,12 +79,17 @@ public class ProcInfo extends SigarCommandBase {
|
||||||
println("\n------------------------\n");
|
println("\n------------------------\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void output(long pid) throws SigarException {
|
public void output(String pid) throws SigarException {
|
||||||
println("pid=" + pid);
|
println("pid=" + pid);
|
||||||
try {
|
try {
|
||||||
println("state=" + sigar.getProcState(pid));
|
println("state=" + sigar.getProcState(pid));
|
||||||
} catch (SigarException e) {}
|
} catch (SigarException e) {
|
||||||
|
if (this.isSingleProcess) {
|
||||||
|
println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
println("mem=" + sigar.getProcMem(pid));
|
println("mem=" + sigar.getProcMem(pid));
|
||||||
} catch (SigarException e) {}
|
} catch (SigarException e) {}
|
||||||
|
|
Loading…
Reference in New Issue