private List<String> getAllCommandOutput(String[] cmdArray) throws IOException {
    log.debug("Executing commands {}", Arrays.toString(cmdArray));
    Process executable = Runtime.getRuntime().exec(cmdArray);
    BufferedReader processReader;
    List<String> psOutput = new ArrayList<>();

    processReader = new BufferedReader(new InputStreamReader(executable.getInputStream()));
    String line;
    while ((line = processReader.readLine()) != null) {
      if (!line.isEmpty()) {
        psOutput.add(line);
      }
    }
    processReader.close();
    return psOutput;
  }
A convenience method to execute shell commands and return all lines of their output.

@param cmdArray the command to run
@return all lines of the output.
@throws IOException
samza-core/src/main/java/org/apache/samza/container/host/PosixCommandBasedStatisticsGetter.java