基础知识_08hwmon子系统

使用较为简单

数据组织方式​

Linux的hwmon子系统将所有硬件传感器(温度、风扇、电压等)以​​文件形式​​暴露在/sys/class/hwmon/目录下,每个传感器设备对应一个hwmonX目录(如hwmon0hwmon7等)。
每个目录中包含以下关键文件:

文件/目录名作用示例值/说明
name设备名称(驱动标识)fan_controlk10temp
label传感器标签(用户友好名称)CPU TempFan1
pwm1风扇调速(PWM占空比)93(范围通常0-255或0-100)
fan1_input风扇转速(RPM)2500(转/分钟)
temp1_input温度(毫摄氏度)45000(表示45.0°C)
## 常用命令
name,label概览,大致包含那些数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
ls -alh  /sys/class/hwmon/hwmon*/name
cat /sys/class/hwmon/hwmon*/name

ls -alh /sys/class/hwmon/hwmon*/*label
cat /sys/class/hwmon/hwmon*/*label


(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ ls -alh /sys/class/hwmon/hwmon*/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon0/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon1/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon2/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon3/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/name
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon5/name
(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ cat /sys/class/hwmon/hwmon*/name
ACAD
BAT1
nvme
k10temp
amdgpu
hidpp_battery_0

(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ ls -alh /sys/class/hwmon/hwmon*/*label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon2/temp1_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon2/temp2_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon2/temp3_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon3/temp1_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/freq1_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/in0_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/in1_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/power1_label
-r--r--r-- 1 root root 4.0K 4月 20 15:55 /sys/class/hwmon/hwmon4/temp1_label
(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ cat /sys/class/hwmon/hwmon*/*label
Composite
Sensor 1
Sensor 2
Tctl
sclk
vddgfx
vddnb
PPT
edge
(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$

温度数据有哪些

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
综合命令:
ls /sys/class/hwmon/hwmon*/ | grep -i "temp"
cat /sys/class/hwmon/hwmon*/temp*


(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ ls /sys/class/hwmon/hwmon*/ | grep -i "temp"
temp1_alarm
temp1_crit
temp1_input
temp1_label
temp1_max
temp1_min
temp2_input
temp2_label
temp2_max
temp2_min
temp3_input
temp3_label
temp3_max
temp3_min
temp1_input
temp1_label
temp1_input
temp1_label
(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$ cat /sys/class/hwmon/hwmon*/temp*
0
84850
43850
Composite
83850
-273150
43850
Sensor 1
65261850
-273150
40850
Sensor 2
65261850
-273150
41000
Tctl
40000
edge
(base) john@john-HLYL-WXX9:/sys/class/hwmon/hwmon4$

参考

Linux hwmon子系统分析之一 系统框架说明:https://blog.csdn.net/lickylin/article/details/106449262
Linux hwmon 子系统分析之三 新版本hwmon子系统说明;https://blog.csdn.net/lickylin/article/details/106449418

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×