我正在尝试使用来lm_sensors
检测 KVM 来宾中的主机 CPU 温度。
在主机中,与x86_pkg_temp_ Thermal插入内核模块后,sysfs 接口/sys/class/thermal/thermal_zone*/temp
会公开所需的信息。
这是主机上sensors-detect
脚本的输出:lm-sensors
$ sudo sensors-detect
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System: LENOVO 20C60065TW [ThinkPad Edge E540] (laptop)
# Kernel: 4.8.8-200.fc24.x86_64 x86_64
# Processor: Intel(R) Core(TM) i7-4702MQ CPU @ 2.20GHz (6/60/3)
This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.
Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): YES
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Intel digital thermal sensor... Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No
在运行 Fedora 24 的 KVM 客户机中,无法插入内核模块:
[root@fedora ~]# modprobe -v x86_pkg_temp_thermal
insmod /lib/modules/4.8.8300.fc25.x86_64/kernel/drivers/thermal/x86_pkg_temp_thermal.ko.xz
modprobe: ERROR: could not insert 'x86_pkg_temp_thermal': No such device
[root@fedora ~]# modprobe -v coretemp
insmod /lib/modules/4.8.8-300.fc25.x86_64/kernel/drivers/hwmon/coretemp.ko.xz
modprobe: ERROR: could not insert 'coretemp': No such device
来宾中脚本的输出sensors-detect
表明主机尚未公开此类功能。
[root@fedora ~]# sensors-detect
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System: QEMU Standard PC (i440FX + PIIX, 1996) [pc-i440fx-2.6]
# Kernel: 4.8.8-300.fc25.x86_64 x86_64
# Processor: Westmere E56xx/L56xx/X56xx (Nehalem-C) (6/44/1)
This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.
Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): YES
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Intel digital thermal sensor... No
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No
有什么方法可以将“英特尔数字热传感器”暴露给 KVM 来宾吗?
答案1
虚拟化 CPU 中不应出现温度,这是预期行为。
VM 中的 CPU 是虚拟的,它们可能无法精确地一对一映射到真实的 CPU。
在虚拟环境/VM 中也存在预期的差异/权衡,其中预计不会找到主机环境的完整模拟,并且由于性能原因通常甚至是不可取的。
因此,例如,在某些虚拟化平台中付出额外的努力来半虚拟化网络接口卡和磁盘控制器,而不是模拟完整的硬件 - 性能差异通常可以达到几个数量级。
为了捕获主机的硬件数据,即温度和其他监控数据,我建议除了监控虚拟机之外,还可以对主机进行直接监控,例如配置SNMP服务。