Skip to main content

Zabbix v6 SMART HDD Check

TST, Hong Kong

S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology; often written as SMART) is a monitoring system included in computer hard disk drives (HDDs), solid-state drives (SSDs), and eMMC drives

Install Smartmontools

The smartmontools package comes with two utilities, smartctl which you can use to check your hard drives on the command line, and smartd, a daemon that checks your hard disks at a specified interval and logs warnings/errors to the syslog and can also send warnings and errors to a specified email address (usually the admin of the system).

apt install smartmontools
smartctl -v

smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-11-amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

Using Smartctl

Find partition:

df -h

Filesystem Size Used Avail Use% Mounted on
udev 3.8G 0 3.8G 0% /dev
tmpfs 777M 996K 776M 1% /run
/dev/sda1 75G 43G 30G 59% /
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda15 121M 130K 120M 1% /boot/efi

In the case of my test server below we have a virtual machine - that, obviously, does not have access to the underlying HDD hardware /dev/sda1:

smartctl -a /dev/sda1

=== START OF INFORMATION SECTION ===
Vendor: QEMU
Product: QEMU HARDDISK
Revision: 2.5+
Compliance: SPC-3
User Capacity: 81,923,145,728 bytes [81.9 GB]
Logical block size: 512 bytes
LU is thin provisioned, LBPRZ=0
Device type: disk
Local Time is: Sun Jan 30 05:14:03 2022 CET
SMART support is: Unavailable - device lacks SMART capability.

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature: 0 C
Drive Trip Temperature: 0 C

When you see that the SMART support is: disabled run the following command to enable it:

smartctl -s on -a /dev/sda1

Add SMART Zabbix Plugin

The template for monitoring S.M.A.R.T. attributes of physical disk that works without any external scripts. It collects metrics by Zabbix agent 2 version 5.0 and later with Smartmontools version 7.1 and later. Disk discovery LLD rule finds all HDD, SSD, NVMe disks with S.M.A.R.T. enabled. Attribute discovery LLD rule finds all Vendor Specific Attributes for each disk.

SMART Zabbix Plugin

Bugfixing

Searching for smart in Latest Data only showed the running SMART Tools service:

SMART Zabbix Plugin

Checking the agent status showed me that the Agent was unable to execute the SMART Tools command because it lacked sudo rights:

service zabbix-agent2 status
...
Mar 07 10:59:16 my-server sudo[260607]: pam_unix(sudo:auth): conversation failed
Mar 07 10:59:16 my-server sudo[260607]: pam_unix(sudo:auth): auth could not identify password for [zabbix]

Add the zabbix agent to Sudoers:

/etc/sudoers

# Zabbix user SMART control
zabbix ALL=(ALL) NOPASSWD:/usr/sbin/smartctl

But I still did not see anything... until the next morning:

SMART Zabbix Plugin

It seems that the discovery service only returns values sporadically - even though it is set to run once every hour:

SMART Zabbix Plugin

I am not yet sure why this is the case. But I lowered the interval to 20min for now - let's see...