How To Configure Zabbix Agent To Monitor Disk Drives In Linux

By default, Zabbix Agent does not monitor HDD health nor it comes with a pre-built template. However there is some community shared templates and scripts through which we can pull disk drive information such as drive temperature, error counts, serial numbers, etc.

In this HOW-TO guide we are going to use a template named zbx-smartctl, which is downloadable through the following link:

https://github.com/v-zhuravlev/zbx-smartctl

Step 1

Download necessary files from the URL above. There are Zabbix templates for the different version, choose the appropriate one for your environment.

Step 2

Zabbix agent commands must be able to run without needing the root password. We can achieve this by adding the following permissions into /etc/sudoers:

zabbix ALL= (ALL) NOPASSWD: /usr/sbin/smartctl,/etc/zabbix/scripts/smartctl-disks-discovery.pl

Step 3

Add the following lines at the end of /etc/zabbix/zabbix_agentd.conf:

#############SMARTMONTOOLS
###DEPRECATED. USE for 2.x-3.2 templates
UserParameter=uHDD[*],sudo smartctl -A $1 | awk '$$0 ~ /$2/ { print $$10 }'
UserParameter=uHDD.value[*],sudo smartctl -A $1 | awk '$$0 ~ /$2/ { print $$4 }'
UserParameter=uHDD.raw_value[*],sudo smartctl -A $1 | awk '$$0 ~ /$2/ { print $$10 }'
UserParameter=uHDD.model.[*],sudo smartctl -i $1 | awk -F ': +' '$$0 ~ /Device Model/ { print $$2 }'
UserParameter=uHDD.sn.[*],sudo smartctl -i $1 | awk -F ': +' '$$0 ~ /Serial Number/ { print $$2 }'
UserParameter=uHDD.health.[*],sudo smartctl -H $1 | awk -F ': +' '$$0 ~ /test/ { print $$2 }'
UserParameter=uHDD.errorlog.[*],sudo smartctl -l error $1 |grep -i "ATA Error Count"| cut -f2 -d: |tr -d " " || true
#### 3.4
UserParameter=uHDD.A[*],sudo smartctl -A $1
UserParameter=uHDD.i[*],sudo smartctl -i $1
UserParameter=uHDD.health[*],sudo smartctl -H $1 || true
### Discovery
UserParameter=uHDD.discovery,sudo /etc/zabbix/scripts/smartctl-disks-discovery.pl

Step 4

Restart Zabbix agent using the following command:

$ systemctl restart zabbix_agent

Step 5

Import appropriate template into Zabbix server. Wait several minutes for the discovery script to find all the drives and start pulling data into Zabbix server.

Latest HOW-TOs