View Javadoc
1   /*
2    * Copyright 2016-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware;
6   
7   import oshi.annotation.concurrent.ThreadSafe;
8   
9   /**
10   * Sensors include hardware sensors to monitor temperature, fan speed, and other information.
11   * <p>
12   * Drivers may or may not exist to collect this data depending on the installed hardware and Operating System. In
13   * addition, software-hardware communication may suffer intermittent errors when attempting to access this information.
14   * Users should expect, test for, and handle zero values and/or empty arrays which will result if the OS is unable to
15   * provide the information.
16   * <p>
17   * Windows information is retrieved via Windows Management Instrumentation (WMI). Unfortunately, most hardware providers
18   * do not publish values to WMI. Oshi attempts to retrieve values from <a href="https://openhardwaremonitor.org/">Open
19   * Hardware Monitor</a> if it is running, in preference to the Microsoft API, which may require elevated permissions and
20   * still may provide no results or unchanging results depending on the motherboard manufacturer.
21   */
22  @ThreadSafe
23  public interface Sensors {
24      /**
25       * CPU Temperature
26       *
27       * @return CPU Temperature in degrees Celsius if available, 0 or {@link Double#NaN} otherwise.
28       *         <p>
29       *         On Windows, if not running Open Hardware Monitor, requires elevated permissions and hardware BIOS that
30       *         supports publishing to WMI. In this case, returns the temperature of the "Thermal Zone" which may be
31       *         different than CPU temperature obtained from other sources. In addition, some motherboards may only
32       *         refresh this value on certain events.
33       */
34      double getCpuTemperature();
35  
36      /**
37       * Fan speeds
38       *
39       * @return Speed in rpm for all fans. May return empty array if no fans detected or 0 fan speed if unable to measure
40       *         fan speed.
41       */
42      int[] getFanSpeeds();
43  
44      /**
45       * CPU Voltage
46       *
47       * @return CPU Voltage in Volts if available, 0 otherwise.
48       */
49      double getCpuVoltage();
50  }