ProcessUtils { public static ProcessStats getProcessStats() throws IOException { final String pid = PidFile.processId(); if (pid == null) { return null; } final String ps = run("ps", "-o", "rss=", "-o", "pcpu=", "-p", pid); final String[] parts = ps.split("\\s+"); return new ProcessStats( Long.valueOf(parts[0]), Float.valueOf(parts[1]) ); }  static String run(String... command); static ProcessStats getProcessStats();  }
@Test public void processStats() throws Exception { System.out.println(ProcessUtils.getProcessStats()); }