1
2
3
4
5 package oshi.driver.unix.aix;
6
7 import java.util.HashMap;
8 import java.util.List;
9 import java.util.Map;
10
11 import oshi.annotation.concurrent.ThreadSafe;
12 import oshi.util.ExecutingCommand;
13 import oshi.util.ParseUtil;
14 import oshi.util.tuples.Pair;
15
16
17
18
19 @ThreadSafe
20 public final class Lssrad {
21
22 private Lssrad() {
23 }
24
25
26
27
28
29
30 public static Map<Integer, Pair<Integer, Integer>> queryNodesPackages() {
31
32
33
34
35
36
37
38
39
40
41
42
43
44 int node = 0;
45 int slot = 0;
46 Map<Integer, Pair<Integer, Integer>> nodeMap = new HashMap<>();
47 List<String> lssrad = ExecutingCommand.runNative("lssrad -av");
48
49 if (!lssrad.isEmpty()) {
50 lssrad.remove(0);
51 }
52 for (String s : lssrad) {
53 String t = s.trim();
54 if (!t.isEmpty()) {
55 if (Character.isDigit(s.charAt(0))) {
56 node = ParseUtil.parseIntOrDefault(t, 0);
57 } else {
58 if (t.contains(".")) {
59 String[] split = ParseUtil.whitespaces.split(t, 3);
60 slot = ParseUtil.parseIntOrDefault(split[0], 0);
61 t = split.length > 2 ? split[2] : "";
62 }
63 for (Integer proc : ParseUtil.parseHyphenatedIntList(t)) {
64 nodeMap.put(proc, new Pair<>(node, slot));
65 }
66 }
67 }
68 }
69 return nodeMap;
70 }
71 }