mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 03:24:55 +00:00
add core method to query multiple pids matching a query
This commit is contained in:
parent
6f8e8a0e10
commit
bb770ea958
@ -417,12 +417,13 @@ public class PlatformUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query and get PID of another java process
|
* Query and get PID of another java process
|
||||||
*
|
*
|
||||||
* @sigarSubQuery a sigar subquery to identify a unique java process among other java processes,
|
* @sigarSubQuery a sigar subquery to identify a unique java process among
|
||||||
* for example, by class name, use: Args.*.eq=org.jboss.Main
|
* other java processes, for example, by class name, use:
|
||||||
* more examples here: http://support.hyperic.com/display/SIGAR/PTQL
|
* Args.*.eq=org.jboss.Main more examples here:
|
||||||
|
* http://support.hyperic.com/display/SIGAR/PTQL
|
||||||
*
|
*
|
||||||
* @return PID of a java process or -1 if it couldn't be determined
|
* @return PID of a java process or -1 if it couldn't be determined
|
||||||
*/
|
*/
|
||||||
@ -446,6 +447,36 @@ public class PlatformUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query and get PIDs of another java processes matching a query
|
||||||
|
*
|
||||||
|
* @sigarSubQuery a sigar subquery to identify a java processes among other
|
||||||
|
* java processes, for example, by class name, use: Args.*.eq=org.jboss.Main
|
||||||
|
* more examples here: http://support.hyperic.com/display/SIGAR/PTQL
|
||||||
|
*
|
||||||
|
* @return array of PIDs of a java processes matching the query or null if
|
||||||
|
* it couldn't be determined
|
||||||
|
*/
|
||||||
|
public static synchronized long[] getJavaPIDs(String sigarSubQuery) {
|
||||||
|
long[] jpids = null;
|
||||||
|
final String sigarQuery = "State.Name.sw=java," + sigarSubQuery;
|
||||||
|
try {
|
||||||
|
if (sigar == null) {
|
||||||
|
sigar = org.sleuthkit.autopsy.corelibs.SigarLoader.getSigar();
|
||||||
|
}
|
||||||
|
if (sigar != null) {
|
||||||
|
ProcessFinder finder = new ProcessFinder(sigar);
|
||||||
|
jpids = finder.find(sigarQuery);
|
||||||
|
} else {
|
||||||
|
System.out.println("Can't get PIDs of a java process, sigar not initialized");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Can't get PIDs for query: " + sigarQuery + ", " + e.toString());
|
||||||
|
}
|
||||||
|
return jpids;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kill a process by PID by sending signal to it using Sigar
|
* Kill a process by PID by sending signal to it using Sigar
|
||||||
*
|
*
|
||||||
@ -467,7 +498,6 @@ public class PlatformUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query and return virtual memory used by the process
|
* Query and return virtual memory used by the process
|
||||||
*
|
*
|
||||||
@ -528,7 +558,7 @@ public class PlatformUtil {
|
|||||||
+ ", " + Long.toString(freeMemory);
|
+ ", " + Long.toString(freeMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return formatted string with all memory usage (jvm, physical, native)
|
* Return formatted string with all memory usage (jvm, physical, native)
|
||||||
*
|
*
|
||||||
* @return formatted string with all memory usage info
|
* @return formatted string with all memory usage info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user