Class Systat
java.lang.Object
oshi.driver.common.unix.bsd.Systat
Utility class parsing output from the BSD
systat -ab sensors command, shared by OpenBSD and NetBSD which
produce the same output format.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutable holder for battery sensor readings parsed fromsystat -ab sensors. -
Method Summary
Modifier and TypeMethodDescriptionstatic Systat.BatteryFieldsparseBatteryFields(String name, List<String> systatLines) Parsessystat -ab sensorsoutput to extract battery readings for a single power source.parsePowerSourceNames(List<String> systatLines) Parses output fromsystat -ab sensorsand returns the set of distinct power-source device prefixes.parseSensors(List<String> systatLines) Parses output fromsystat -ab sensorsinto CPU temperature, fan speeds, and CPU voltage.static Systat.BatteryFieldsqueryBatteryFields(String name) Runssystat -ab sensorsand returns the battery sensor data for the named power source.Runssystat -ab sensorsand returns the set of distinct power-source device prefixes (the substring preceding.amphour/.watthour).Runssystat -ab sensorsand returns its raw output.Runssystat -ab sensorsand returns CPU temperature, fan speeds, and CPU voltage.
-
Method Details
-
querySensorLines
Runssystat -ab sensorsand 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 theparse*methods to avoid spawning the command repeatedly.- Returns:
- the raw lines returned by
systat -ab sensors
-
querySensors
-
parseSensors
Parses output fromsystat -ab sensorsinto 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
-
parsePowerSourceNames
Parses output fromsystat -ab sensorsand 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
Runssystat -ab sensorsand 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
Parsessystat -ab sensorsoutput 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 bysystat -ab sensors- Returns:
- parsed battery fields with sentinel defaults for any sensor not present.
-