diff --git a/conf/smart.conf b/conf/smart.conf new file mode 100644 index 0000000..29330cf --- /dev/null +++ b/conf/smart.conf @@ -0,0 +1,7 @@ +# Discover S.M.A.R.T. capable hard drives +# The only macro returned is {#SMARTDRIVE} and value is like /dev/sda +UserParameter=hardward.disk.smart.discovery,/usr/bin/sudo /var/lib/zabbix/bin/disco_smart_sudo + +# Takes two args: the drives to check, and the value to get +# eg: hardward.disk.smart[/dev/sda,Reallocated_Sector_Ct] +UserParameter=hardward.disk.smart[*],/usr/bin/sudo /var/lib/zabbix/bin/check_smart_sudo $1 $2 diff --git a/scripts/check_smart_sudo b/scripts/check_smart_sudo new file mode 100644 index 0000000..b368639 --- /dev/null +++ b/scripts/check_smart_sudo @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/sbin/smartctl -A $1 | grep $2 | tail -1| cut -c 88- | cut -f1 -d' ' diff --git a/scripts/disco_smart_sudo b/scripts/disco_smart_sudo new file mode 100644 index 0000000..47dcf17 --- /dev/null +++ b/scripts/disco_smart_sudo @@ -0,0 +1,12 @@ +#!/bin/bash + +echo -e "{\n\t\"data\":[\n\n" +for DISK in $(smartctl --scan-open | cut -d' ' -f1); do + smartctl -A $DISK >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo -e "\t{\n" + echo -e "\t\t\"{#SMARTDRIVE}\":\"$DISK\"" + echo -e "\t}" + fi +done +echo -e "\n\t]\n}\n"