📜 ⬆️ ⬇️

Zabbix: LLD monitoring of disks without UserParameter and agent scripts

In the previous article, I described low-level disk monitoring for Windows machines. I think that the article was quite successful. Therefore, it is time to actually destroy it. Below will be described a universal technique for Windows and Linux machines for which no scripts and UserParameters are needed at all.

The idea is simple: everything you need from a smartmontools Zabbix server will receive via external processing and zabbix_get, parse and transfer further to dependent elements (appeared in Zabbix 3.4). In this way, not only the number of calls to the monitored server is reduced, but its resources are not consumed, since the parsing happens on the Zabbix server side.

One limitation at the moment: monitoring disks only format / dev / sd *. The / dev / csmi *, * (Intel Matrix RAID) format is not supported due to the fact that zabbix_get considers a comma as the second argument. Correct me if I am wrong.
')
What is needed for implementation:


Agent configuration


The only thing that deserves attention here is the need to uncomment the line EnableRemoteCommands = 1 , otherwise the agent will not be able to accept commands.

Smartmontools


Installation is trivial and will not be considered, but for Linux there is one need: in order to run without sudo , you need to set the SUID bit on the smartctl file. For Ubuntu, this is sudo chmod u + s / usr / sbin / smartctl .

Script


Depending on your zabbix_server.conf configuration file, this script should be put in the appropriate directory on the Zabbix server. The default for Ubuntu is / usr / lib / zabbix / externalscripts . Do not forget to give execution permissions on the file - sudo chmod 775 /usr/lib/zabbix/excuralscripts/smartctl.sh .

smartctl.sh
#!/bin/bash
# 2017/12/07 AcidVenom v1.0
# HDD LLD Zabbix ( )
#
# : discovery
IFS=$'\n'
JSON="{\"data\":["
SEP=""
if [[ $2 = "discovery" ]]
then
get=`zabbix_get -s $1 -k system.run["smartctl --scan-open"] | grep "/dev/sd"`
for hdd in $get
do
DISKID=`echo $hdd | grep "/dev/sd" | sed "s/\/dev\///" | cut -c 1-3`
if [[ `zabbix_get -s $1 -k system.run["smartctl -i /dev/$DISKID"] | grep "SMART support is: Enabled"` != "" ]]
then
JSON=$JSON"$SEP{\"{#DISKID}\":\"$DISKID\"}"
SEP=", "
fi
done
JSON=$JSON"]}"
echo $JSON
#
# : info attr
else
if [[ $3 = "info" ]]
then
get=`zabbix_get -s $1 -k system.run["smartctl -x /dev/$2"]`
for out in $get
do
echo $out
done
elif [[ $3 = "attr" ]]
then
get=`zabbix_get -s $1 -k system.run["smartctl -A /dev/$2"]`
for out in $get
do
echo $out
done
fi
fi
view raw smartctl.sh hosted with ❤ by GitHub


Template


Template exported from version 3.4.4.
The template already contains the following elements: model, family, serial number, disk size, SMART status; as well as the SMART values ​​3, 5, 7, 9, 10, 190 (194), 196, 197, 198, 199. There are 3 triggers: two indicate high temperatures and another one about a bad SMART.

Hardware - HDD.xml
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.4</version>
<date>2017-12-27T05:26:57Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Hardware - HDD</template>
<name>Hardware - HDD</name>
<description> HDD c LLD.&#13;
&#13;
&#13;
:&#13;
smartctl.sh -&gt; /usr/lib/zabbix/externalscripts/&#13;
smartmontools</description>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name> </name>
</application>
</applications>
<items/>
<discovery_rules>
<discovery_rule>
<name> </name>
<type>10</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.sh[{HOST.CONN},discovery]</key>
<delay>1h</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>1d</lifetime>
<description> .</description>
<item_prototypes>
<item_prototype>
<name> {#DISKID} - </name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.capacity.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>User Capacity: .*\[(.*)\]
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.family.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>Model Family: (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - FW</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.fw.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>Firmware Version: (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.model.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>Device Model: (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - </name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.serial.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>Serial Number: (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMARTCTL Attr</name>
<type>10</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
<delay>10m</delay>
<history>1h</history>
<trends>0</trends>
<status>0</status>
<value_type>4</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMARTCTL Info</name>
<type>10</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
<delay>10m</delay>
<history>1h</history>
<trends>0</trends>
<status>0</status>
<value_type>4</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype/>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Spin-Up Time [3]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.3.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>3 Spin_Up_Time.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Reallocated Sector Count [5]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.5.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>5 Reallocated_Sector.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Seek Error Rate [7]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.7.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>7 Seek_Error_Rate.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Power-on Time Count [9]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.9.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>9 Power_On_Hours.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Spin-Up Retry Count [10]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.10.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>10 Spin_Retry_Count.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Temperature [190-194]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.190-194.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>°C</units>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>(190 Airflow_Temperature_Cel|194 Temperature_Celsius).* - *([0-9]+).*
\2</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Reallocated Event Count [196]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.196.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>196 Reallocated_Event_Count.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Current Pending Sector Count [197]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.197.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>197 Current_Pending_Sector.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - Uncorrectable Sector Count [198]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.198.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>198 Offline_Uncorrectable.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART - UltraDMA CRC Error Count [199]</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.199.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>199 UDMA_CRC_Error_Count.* - (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},attr]</key>
</master_item_prototype>
</item_prototype>
<item_prototype>
<name> {#DISKID} - SMART</name>
<type>18</type>
<snmp_community/>
<snmp_oid/>
<key>smartctl.smart.status.[{#DISKID}]</key>
<delay>0</delay>
<history>90d</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name> </name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing>
<step>
<type>5</type>
<params>SMART overall-health self-assessment test result: (.*)
\1</params>
</step>
</preprocessing>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype>
<key>smartctl.sh[{HOST.CONN},{#DISKID},info]</key>
</master_item_prototype>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Hardware - HDD:smartctl.smart.status.[{#DISKID}].regexp(^PASSED$)}=1</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>SMART {#DISKID} {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Hardware - HDD:smartctl.smart.190-194.[{#DISKID}].last()}&gt;50</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {#DISKID} {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Hardware - HDD:smartctl.smart.190-194.[{#DISKID}].last()}&gt;60</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name> {#DISKID} {HOST.NAME}</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
<host_prototypes/>
<jmx_endpoint/>
</discovery_rule>
</discovery_rules>
<httptests/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
</zabbix_export>


Learn more about how things work.
Below I will try to describe in detail what happens at each stage.
The first step: detecting available sd * drives using external smartctl.sh with {HOST.CONN} and discovery keys. In response, the server receives JSON with disks on which the SMART function is activated. Disks without SMART or not sd * are not output.

Stage two: getting for each of the disks found two items - Info and Attr. Info - information about the disk, Attr - attributes SMART. “Why not ask for smartctl -a / dev / sd *?” You ask. Such a conclusion is not complete for some discs, attributes are lost, and so on. I had to invent on the go.

The third stage: Info and Attr are broken down into dependent elements using preprocessing by regular expressions. This is the easiest part. Actually, you will only have to adjust the regular season for you.

Total


That's all. No need to keep in mind what and where to put, whether to disable the PS script execution policy, to track the same version of PS. And if necessary, all changes are made on Zabbix itself in the web interface.

In the end, I would just like to say thanks to Alexey alexvl and his team for the quality product, which never ceases to please new functionality. Especially for preprocessing. Living with her administrator will be much easier.

Source: https://habr.com/ru/post/344548/


All Articles