启用 sysstat 温度记录

启用 sysstat 温度记录

我正在尝试启用 sysstat 来读取温度读数,以便我可以利用过去的温度信息来诊断将来的主机故障。

我尝试使用此命令来获取温度信息:

$ sar -m TEMP
Requested activities not available in file /var/log/sysstat/sa22

以下是 sar 手册页对此的说明:

-m { keyword [,...] | ALL }
       Report power management statistics.  Note that these statistics depend on sadc's option "-S  POWER"  to
       be collected.

       Possible keywords are CPU, FAN, FREQ, IN, TEMP and USB.

       [...]

       With  the  TEMP  keyword,  statistics about devices temperature are reported.  The following values are
       displayed:

据此,默认情况下不记录电源管理信息(温度是其子集)。因此,我更改了该文件/etc/sysstat/sysstat以启用它。我改变了这个:

# Parameters for the system activity data collector (see sadc(8) manual page)
# which are used for the generation of log files.
# By default contains the `-S DISK' option responsible for generating disk
# statisitcs. Use `-S XALL' to collect all available statistics.
SADC_OPTIONS="-S DISK"

进入这个:

SADC_OPTIONS="-S DISK,POWER"

另一个问题是关于sysstat 问题跟踪器说 sysstat 需要 lm-sensors 才能运行,所以我也安装了该软件包。这是输出sensors

$ sensors
acpitz-acpi-0
Adapter: ACPI interface
temp1:        +27.8°C  (crit = +119.0°C)
temp2:        +29.8°C  (crit = +119.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +89.0°C  (high = +82.0°C, crit = +100.0°C)
Core 0:        +86.0°C  (high = +82.0°C, crit = +100.0°C)
Core 1:        +88.0°C  (high = +82.0°C, crit = +100.0°C)
Core 2:        +89.0°C  (high = +82.0°C, crit = +100.0°C)
Core 3:        +89.0°C  (high = +82.0°C, crit = +100.0°C)
Core 4:        +88.0°C  (high = +82.0°C, crit = +100.0°C)
Core 5:        +87.0°C  (high = +82.0°C, crit = +100.0°C)

nvme-pci-0800
Adapter: PCI adapter
Composite:    +38.9°C  (low  = -273.1°C, high = +84.8°C)
                       (crit = +84.8°C)
Sensor 1:     +38.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +37.9°C  (low  = -273.1°C, high = +65261.8°C)

所以这似乎确实正确地检测到我的温度传感器。

我还尝试等待十分钟以进行另一次收集。 (我的系统配置为每十分钟记录一次,时间为 :05、:15、:25 等)

不幸的是,毕竟我仍然遇到同样的错误:

$ sar -m TEMP
Requested activities not available in file /var/log/sysstat/sa22

答案1

我通过三个步骤成功地做到了这一点:

  1. 完成上述问题中的所有设置。

  2. 删除当天的 sysstat 日志文件。

    root@host:~# sar -m TEMP
    Requested activities not available in file /var/log/sysstat/sa30
    root@host:~# rm /var/log/sysstat/sa30
    
  3. 运行脚本/usr/lib/sysstat/debian-sa1 1 1(在非 Debian/Ubuntu 系统上可能有所不同)

之后,跑步sar -m TEMP就可以了。

相关内容