* @throws IOException Error starting the collector
* @throws InterruptedException Interrupted waiting for commands
*/
public void start() throws IOException, InterruptedException {
// Locate the process with collector, starting with user processes.
cmd = new Command("/usr/bin/ps", "-u", System.getProperty("user.name"));
cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
String result = null;
try {
processRef = cmd.execute();
result = new String(processRef.fetchOutput(Command.STDOUT));
} catch (IOException e) {
logger.log(Level.WARNING, "Error executing ps", e);
return;
} catch (InterruptedException e) {
logger.log(Level.WARNING, "Interrupted executing ps", e);
return;
}
int startIdx = 0;
int endIdx = result.indexOf('\n');
while (endIdx > 0) {
String line = result.substring(startIdx, endIdx).trim();
startIdx = endIdx + 1;
endIdx = result.indexOf('\n', startIdx);
if (line == null || line.length() == 0)
continue;
if (line.startsWith("PID ")) // skip header
continue;
String pid = line.substring(0, line.indexOf(' '));
cmd = new Command("/usr/bin/pldd", pid);
cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
// Check for process that started with collector.
try {
processRef = cmd.execute();