1
2
3
4
5 package oshi.hardware.platform.unix.solaris;
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 import oshi.annotation.concurrent.ThreadSafe;
11 import oshi.hardware.common.AbstractSensors;
12 import oshi.util.ExecutingCommand;
13 import oshi.util.ParseUtil;
14
15
16
17
18 @ThreadSafe
19 final class SolarisSensors extends AbstractSensors {
20
21 @Override
22 public double queryCpuTemperature() {
23 double maxTemp = 0d;
24
25 for (String line : ExecutingCommand.runNative("/usr/sbin/prtpicl -v -c temperature-sensor")) {
26 if (line.trim().startsWith("Temperature:")) {
27 int temp = ParseUtil.parseLastInt(line, 0);
28 if (temp > maxTemp) {
29 maxTemp = temp;
30 }
31 }
32 }
33
34 if (maxTemp > 1000) {
35 maxTemp /= 1000;
36 }
37 return maxTemp;
38 }
39
40 @Override
41 public int[] queryFanSpeeds() {
42 List<Integer> speedList = new ArrayList<>();
43
44 for (String line : ExecutingCommand.runNative("/usr/sbin/prtpicl -v -c fan")) {
45 if (line.trim().startsWith("Speed:")) {
46 speedList.add(ParseUtil.parseLastInt(line, 0));
47 }
48 }
49 int[] fans = new int[speedList.size()];
50 for (int i = 0; i < speedList.size(); i++) {
51 fans[i] = speedList.get(i);
52 }
53 return fans;
54 }
55
56 @Override
57 public double queryCpuVoltage() {
58 double voltage = 0d;
59 for (String line : ExecutingCommand.runNative("/usr/sbin/prtpicl -v -c voltage-sensor")) {
60 if (line.trim().startsWith("Voltage:")) {
61 voltage = ParseUtil.parseDoubleOrDefault(line.replace("Voltage:", "").trim(), 0d);
62 break;
63 }
64 }
65 return voltage;
66 }
67 }