Class Systat

java.lang.Object
oshi.driver.common.unix.bsd.Systat

@ThreadSafe public final class Systat extends Object
Utility class parsing output from the BSD systat -ab sensors command, shared by OpenBSD and NetBSD which produce the same output format.
  • Method Details

    • querySensorLines

      public static List<String> querySensorLines()
      Runs systat -ab sensors and returns its raw output. Callers that need multiple parsed views of the same snapshot (e.g. power-source names plus battery fields for several batteries) should invoke this once and pass the result to the parse* methods to avoid spawning the command repeatedly.
      Returns:
      the raw lines returned by systat -ab sensors
    • querySensors

      public static Triplet<Double,int[],Double> querySensors()
      Runs systat -ab sensors and returns CPU temperature, fan speeds, and CPU voltage.
      Returns:
      a Triplet of (cpu temperature in °C, fan RPMs, cpu voltage in V).
    • parseSensors

      public static Triplet<Double,int[],Double> parseSensors(List<String> systatLines)
      Parses output from systat -ab sensors into CPU temperature, fan speeds, and CPU voltage.
      Parameters:
      systatLines - the raw lines returned by the command
      Returns:
      a Triplet of (cpu temperature in °C, fan RPMs, cpu voltage in V). If no CPU-specific temperature is present, the average of any other temperature sensors is returned in its place.
    • queryPowerSourceNames

      public static Set<String> queryPowerSourceNames()
      Runs systat -ab sensors and returns the set of distinct power-source device prefixes (the substring preceding .amphour/.watthour).
      Returns:
      a Set of power-source device names (e.g. "acpibat0").
    • parsePowerSourceNames

      public static Set<String> parsePowerSourceNames(List<String> systatLines)
      Parses output from systat -ab sensors and returns the set of distinct power-source device prefixes.
      Parameters:
      systatLines - the raw lines returned by the command
      Returns:
      a Set of power-source device names (e.g. "acpibat0").
    • queryBatteryFields

      public static Systat.BatteryFields queryBatteryFields(String name)
      Runs systat -ab sensors and returns the battery sensor data for the named power source.
      Parameters:
      name - the power source name (e.g. "acpibat0")
      Returns:
      parsed battery fields with sentinel defaults for any sensor not present.
    • parseBatteryFields

      public static Systat.BatteryFields parseBatteryFields(String name, List<String> systatLines)
      Parses systat -ab sensors output to extract battery readings for a single power source.
      Parameters:
      name - the power source name to match (e.g. "acpibat0")
      systatLines - the raw lines returned by systat -ab sensors
      Returns:
      parsed battery fields with sentinel defaults for any sensor not present.