(OperatingSystem os, GlobalMemory memory)
| 264 | } |
| 265 | |
| 266 | private static void printProcesses(OperatingSystem os, GlobalMemory memory) { |
| 267 | OSProcess myProc = os.getProcess(os.getProcessId()); |
| 268 | // current process will never be null. Other code should check for null here |
| 269 | oshi.add( |
| 270 | "My PID: " + myProc.getProcessID() + " with affinity " + Long.toBinaryString(myProc.getAffinityMask())); |
| 271 | oshi.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount()); |
| 272 | // Sort by highest CPU |
| 273 | List<OSProcess> procs = os.getProcesses(ProcessFiltering.ALL_PROCESSES, ProcessSorting.CPU_DESC, 5); |
| 274 | oshi.add(" PID %CPU %MEM VSZ RSS Name"); |
| 275 | for (int i = 0; i < procs.size() && i < 5; i++) { |
| 276 | OSProcess p = procs.get(i); |
| 277 | oshi.add(String.format(" %5d %5.1f %4.1f %9s %9s %s", p.getProcessID(), |
| 278 | 100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(), |
| 279 | 100d * p.getResidentSetSize() / memory.getTotal(), FormatUtil.formatBytes(p.getVirtualSize()), |
| 280 | FormatUtil.formatBytes(p.getResidentSetSize()), p.getName())); |
| 281 | } |
| 282 | OSProcess p = os.getProcess(os.getProcessId()); |
| 283 | oshi.add("Current process arguments: "); |
| 284 | for (String s : p.getArguments()) { |
| 285 | oshi.add(" " + s); |
| 286 | } |
| 287 | oshi.add("Current process environment: "); |
| 288 | for (Entry<String, String> e : p.getEnvironmentVariables().entrySet()) { |
| 289 | oshi.add(" " + e.getKey() + "=" + e.getValue()); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | private static void printServices(OperatingSystem os) { |
| 294 | oshi.add("Services: "); |
no test coverage detected