Temperature

啟用 sysstat 溫度記錄

  • March 30, 2022

我正在嘗試啟用 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. 完成上述問題中的所有設置。
  2. 刪除當天的 sysstat 日誌文件。
root@host:~# sar -m TEMP
Requested activities not available in file /var/log/sysstat/sa30
root@host:~# rm /var/log/sysstat/sa30
  1. 執行腳本/usr/lib/sysstat/debian-sa1 1 1(在非 Debian/Ubuntu 系統上可能不同)

在此之後,執行sar -m TEMP工作。

引用自:https://unix.stackexchange.com/questions/696447