大网数据广告活动
服务器运维问答

How to get hard disk status from RAID with SmartCTL for monitoring purposes?

· 52CE 我爱测

I have a FreeBSD with a RAID running 3 Hard Disks. I was given the challenge to monitor its RAID - If a hard disk fails or it presents some problem i need to know. So, the first thing i am doing right now is trying to understand …

问题原文

原帖链接 · Raul Chiarella · CC BY-SA 4.0

I have a FreeBSD with a RAID running 3 Hard Disks. I was given the challenge to monitor its RAID - If a hard disk fails or it presents some problem i need to know.

So, the first thing i am doing right now is trying to understand how SmartCTL works... The commands i used so far are:

smartctl --scan -j - To scan my devices and generated a JSON Structured list.
smartctl -i /dev/device_name - To list informations about a single device
smartctl -a /dev/your-device - More information like errors and etc (I think i can use this in some way to grep only errors sections...)

Is there any other parameters of SmartCTL that checks if the disks are writable, alive, and have their health status OK?

The main purpose of this understanding is to use mainly SmartCTL to generate data that will be used in a template of pfSense RAID Monitoring with Low Level Discovery for Zabbix Monitoring Software...

Any help is appreciate it.

已采纳解答

原帖链接 · Roman Spiak · CC BY-SA 4.0

ok so to answer - there's no smartctl --isDiskOK /dev/sda approach you can take as far as I know.

Closest smartctl can take you to this is the report of reallocated sector count. I'm not going to explain in detail but essentially when disks starts to fail the hard to read/write sectors will be relocated to a spare sector. If there's more reallocations happening it means drive is closer to be completely dead.

  1. Zabbix can leverage the following user parameter:
$ sudo cat /etc/zabbix/zabbix_agent2.d/userparameter_hdd.reallocated.sectors.conf
# get current HDD reallocated sectors count && needs sudoers
UserParameter=hdd.reallocated.sectors[*],sudo smartctl -a /dev/$1|grep Reallocated_Sector_Ct|awk '{print $$10}'
  1. create the zabbix template with following item:

  2. allow user zabbix to execute smartctl via sudoers:

$ sudo grep zabbix /etc/sudoers.d/*
/etc/sudoers.d/zabbix:zabbix  ALL=NOPASSWD:/usr/sbin/hddtemp, /usr/sbin/smartctl, /usr/bin/fping
  1. assign template to monitored host + restart zabbix_agent to load config - your item should populate with reallocated sector count

  2. Profit.. :)

anyways the zabbix template is available on my GitHub too https://github.com/RipperSK/zabbix-user-params/blob/master/hdd.reallocated.sectors/userparameter_hdd.reallocated.sectors.conf

enjoy.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-04-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。