Zabbix监控硬盘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.信息的方法

方案一:用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"

方案二:使用第三方方案

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

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 {KaTeX parse error: Undefined control sequence: \s at position 20: …atch '^smartctl\̲s̲\d'}) -ireplace…').Trim()”

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

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.//’

  1. 如果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并导入

相关问题

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使用过程中碰到问题,还可以到乐维社区进行留言提问。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值