sysinfo
sysinfo copied to clipboard
General design: Component can gather more Hardware Monitor on Linux
- Related to #821 and #823
- State: Mostly brain dumping of an informal conversion with Guillaume and I.
On Linux at least /sys/class/hwmon
know as Hwmon
or Hardware Monitoring
sub system is able to gather data from various places in the kernel through loadable modules like amdgpu
, drivetemp
or thinkpad
module.
Nowadays we limit the reading to CPU
and GPU
monitor. The schema description of what can be read in hwmon
files is somewhat "loose", the numeric values are defined as long *
kernel side, and can include fan Rotation Per Minute, Volts, Temperature in mili celcius; read value from hardware, critical value and Max-value and also minimal functionally working value.
Exemple from hwmon
interface:
HWMON_C_xxxx | Chip attributes, for use with hwmon_chip. |
---|---|
HWMON_T_xxxx | Temperature attributes, for use with hwmon_temp. |
HWMON_I_xxxx | Voltage attributes, for use with hwmon_in. |
HWMON_C_xxxx | Current attributes, for use with hwmon_curr. Notice the prefix overlap with chip attributes. |
HWMON_P_xxxx | Power attributes, for use with hwmon_power. |
HWMON_E_xxxx | Energy attributes, for use with hwmon_energy. |
HWMON_H_xxxx | Humidity attributes, for use with hwmon_humidity. |
HWMON_F_xxxx | Fan speed attributes, for use with hwmon_fan. |
HWMON_PWM_xxxx | PWM control attributes, for use with hwmon_pwm. |
It may be interesting to design a way to expose this data in two form one low level with Components
The design may retain the "optional" availability of these data since, if the kernel module is not loaded files will not exists and must support a way to make a difference between "no data" and a default value. Aka failing to read shall return None
, so the user may get this data for his own purpose (prometheus or something else).
And maybe (not now) a unified view to monitor physical info about for example a Disk or a Network Interface Card without relying on too much vendor specific API.
Kernel Documentation
- Kernel hwmon API: https://www.kernel.org/doc/html/latest/hwmon/hwmon-kernel-api.html
- DriveTemp kernel API: https://docs.kernel.org/gpu/amdgpu/thermal.html#hwmon-interfaces
- Amdgpu hwmon interface: https://www.kernel.org/doc/html/latest/hwmon/drivetemp.html
End of the day goal
Have something like sensors
display, may need breaking Component
API or doing an other.
We could present different kind of compoents by turning the Component
struct into an enum looking like this:
enum Component {
TemperatureSensor(TemperatureSensor),
Fan(Fan),
}
And then we can create the TemperatureSensor
and Fan
types to hold the information. We could even create a RefreshComponentKind
type like we have for other refresh to only retrieve one kind of component, etc.
Faudrait que je trouve du temps pour le faire. J'avais commencer.