是否有任何工具可用于随时间存储 SMART 数据?

Ang*_*elo 7 hard-disk smart

我想随着时间的推移开始存储 SMART 数据,并根据磁盘 ID/序列号查看任何趋势。例如,可以让我每天从磁盘中获取一次智能信息并将其放入数据库中。Linux 中是否已经有用于此的工具,还是我必须自己推出?

Ste*_*itt 10

已经有工具可以做到这一点,通常作为更通用的监控工具的一部分。我觉得有用的是Munin,它有一个SMART 插件来跟踪可用属性:

显示 SMART 属性随时间变化的图表

Munin 可在许多发行版中使用。

smartmontools本身包含一个可以定期记录属性的工具smartd。您可能会发现这就是您所需要的。


Jer*_*den 7

“自己动手”很容易。smartctl -A drive-specifier通过 AWK 脚本每天(以 root 身份)运行,并输出到文件。

gnuplot 非常适合绘制此文件的图形。

对此略有扩展,例如:-

  1. 放置一个条目以在其中运行以下脚本 /etc/cron.daily
#!/bin/sh

# SMART DISK PROCESSING
# =====================
tmpfile=$(mktemp -q)
today=$(date -u +%d-%m-%Y)

smartctl -A /dev/disk/by-id/ata-Samsung_SSD_870_QVO_1TB_S5SVNG0NB22319L > $tmpfile

# Output log as a single line - note "Unknown_Attribute" is "POR_Recovery_Count" [unexpected shutdown]
echo -n $today ', ' >> /var/log/disk-monitor.d/sdb-errors.csv
awk 'NR>=8 && NR<=21 {print $1,",",$2,",",$10,",";}' $tmpfile | tr -d '\n' | sed 's/Unknown_Attribute/POR_Recovery_Count/;s/\,$/\n/' >> /var/log/disk-monitor.d/sdb-errors.csv

exit 0
Run Code Online (Sandbox Code Playgroud)

AWK "NR>=8 && NR<=21" 挑选出正确的行号,print 语句挑选出合适的列;所述tr移除新线; sed修复了 SMART 属性问题并添加了一个换行符。

因此,每天有一条记录以日期格式写入 CSV 日志文件,[属性 ID、属性名称、属性值]*N 格式。

07-06-2021 , 5 , Reallocated_Sector_Ct , 0 ,9 , Power_On_Hours , 2900 , ...

  1. 我选择根据需要绘制选定的值 [理想情况下为零的值]...我使用的脚本gnuplot script-name如下,
set title "SDA Errors which should be ZERO"
set xdata time
set timefmt "%d-%m-%Y"
set format x "%d/%m"
set datafile separator ","

set colorsequence default

set ytics 2 nomirror tc lt 2
set ylabel 'POR' tc lt 2
set yrange [0:30<*]  
set y2tics 1 nomirror tc lt 1
set y2label 'Errors' tc lt 1
set y2range [-1:10]

set key left top 

set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
plot "/var/log/disk-monitor.d/sda-errors.csv" using 1:4 title "Reallocated Sector Count" with lines axes x1y2, '' using 1:13 title "Wear Levelling Count" with lines  axes x1y2, '' using 1:16 title "Used Rsvd Blk Cnt Total" with lines  axes x1y2, '' using 1:19 title "Program Fail Cnt Total" with lines  axes x1y2, '' using 1:22 title "Erase Fail Count Total" with lines  axes x1y2, '' using 1:25 title "Runtime Bad Block" with lines   axes x1y2, '' using 1:28 title "Reported Uncorrect" with lines  axes x1y2, '' using 1:34 title "Hardware ECC Recovered" with lines dt 3  axes x1y2, '' using 1:40 title "POR Recovery Count" with lines dt 1 linetype rgb "green" axes x1y1

pause -1 "Hit any key to continue"
Run Code Online (Sandbox Code Playgroud)

我相信有更好的脚本可用!