Zabbix技术分享——使用Zabbix监控硬盘S.M.A.R.T.信息

硬盘S.M.A.R.T.信息的主要用途是帮助用户和系统管理员监测硬盘的健康状态和性能,例如温度、振动、读写错误率、坏道数量等,同时对预测故障、数据恢复、性能监测具有重要作用。

S.M.A.R.T.是"Self-Monitoring, Analysis, and Reporting Technology"的缩写,它是一种硬盘自我监测、分析和报告技术。硬盘S.M.A.R.T.信息的主要用途是帮助用户和系统管理员监测硬盘的健康状态和性能,例如温度、振动、读写错误率、坏道数量等,同时对预测故障、数据恢复、性能监测具有重要作用。

因此,监控硬盘S.M.A.R.T.信息对运维有着非常重要的意义,本文将分享两种Zabbix监控硬盘S.M.A.R.T.信息的方法


1.方案一:使用Zabbix官方方案

Zabbix官网地址:https://www.zabbix.com/cn/integrations/smart

操作步骤:

1.安装Zabbix Agent 2,Windows可以直接下载使用,Linux需要通过参数-enable-agent2编译安装。

2.安装Smartmontools,版本要求7.1+。

3.Windows平台zabbix_agentd.conf需要增加配置,定义smartctl的路径。

Plugins.Smart.Path="C:\Program Files\smartmontools\bin\smartctl.exe"

4.从上面的官方链接下载模板并导入。


2.方案二:使用第三方方案

地址:https://github.com/nikimaxim/zbx-smartmonitor

2.1 Windows系统

1.下载安装Smartmontools,要求版本7.1+,下载地址:https://builds.smartmontools.org/

2.检查PowerShell版本,要求版本5.1+,打开PowerShell并执行该命令可查版本信息:Get-Host|Select-Object Version

3.下载硬盘发现脚本smartctl-storage-discovery.ps1,保存到C:\

4.在zabbix_agentd.conf添加自定义监控项

UserParameter=storage.discovery[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\smartctl-storage-discovery.ps1"

UserParameter=storage.get[*],powershell -NoProfile -ExecutionPolicy Bypass -Command "if (\"$1\") {& 'C:\Program Files\smartmontools\bin\smartctl.exe' -i -H -A -l error -l background $1}"

UserParameter=smartctl.version,powershell -NoProfile -ExecutionPolicy Bypass -Command "((& 'C:\Program Files\smartmontools\bin\smartctl.exe' --version | Where-Object {$_ -match '^smartctl\s\d'}) -ireplace 'smartctl\s' -ireplace '\s\[.+$').Trim()"

5.下载监控模板Template smartmonitor.xml并导入

2.2 Linux系统

1.下载安装Smartmontools,要求版本7.1+,下载地址:https://builds.smartmontools.org/

2.下载硬盘发现脚本smartctl-storage-discovery.sh,保存到/usr/local/sbin/

3.在zabbix_agentd.conf添加自定义监控项

UserParameter=storage.discovery[*],sudo /usr/local/sbin/smartctl-storage-discovery.sh

UserParameter=storage.get[*],if [ -n "$1" ]; then sudo /usr/sbin/smartctl -i -H -A -l error -l background $1; fi

UserParameter=smartctl.version,/usr/sbin/smartctl --version | grep -Eo "^smartctl\s[0-9\.[:space:]\r-]+" | sed -e 's/^smartctl.//'

4. 如果Zabbix Agent不是以root身份运行,则需要visudo添加以下内容

Defaults:zabbix !requiretty

zabbix ALL=(root) NOPASSWD: /usr/sbin/smartctl

zabbix ALL=(root) NOPASSWD: /usr/local/sbin/smartctl-storage-discovery.sh

5.下载监控模板Template smartmonitor.xml并导入


3.相关问题

Zabbix Server升级到6.0 LTS后,Linux客户端无法获取S.M.A.R.T.信息,Agent日志提示:

"storage.get["/dev/sda -dsat"]" is not supported: Incorrect update interval.”

解决方案:

检查第三方模板,把自动发现规则里面监控项storage.get["{#STORAGE.CMD}"]的“自定义时间间隔”删除。

 

以上就是这一期的Zabbix技术分享。

大家好,我是乐乐,关注我,学习更多Zabbix使用小技巧,如在Zabbix使用过程中碰到问题,还可以到乐维社区进行留言提问。

YPBsXpwj64dd80e7a3af7.png

0 条评论

请先 登录 后评论
乐维君
乐维君

345 篇文章

作家榜 »

  1. 乐维君 345 文章
  2. YOHOHO 14 文章
  3. 机灵小和尚 13 文章
  4. 我是一只小菜鸡 12 文章
  5. 细雨闲花 11 文章
  6. 御前侍卫张五哥 9 文章
  7. 。。。 8 文章
  8. 小黄人 8 文章