If you want
smartd to call your script, see the option
-w PATH, --warnexec=PATH
Run the executable PATH instead of the default script when smartd needs to send warning messages. PATH must point to an executable binary file or script. The default script is
The script is normally used to send an email. It is called with these environment variables:
is set to the argument of -M exec, if present or else to 'mail' (examples: /usr/local/bin/mail, mail).
is set to the device path (example: /dev/sda).
is set to the device type specified by '-d' directive or 'auto' if none.
is set to the device description. It starts with SMARTD_DEVICE and may be followed by an optional controller identification (example: /dev/sda [SAT]). The string may contain a space and is NOT quoted.
is set to device identify information. It includes most of the info printed by smartctl -i but uses a brief single line format. This device info is also logged when smartd starts up. The string contains space characters and is NOT quoted.
gives the reason for the warning or message email. The possible values that it takes and their meanings are:
EmailTest: this is an email test message.
Health: the SMART health status indicates imminent failure.
Usage: a usage Attribute has failed.
SelfTest: the number of self-test failures has increased.
ErrorCount: the number of errors in the ATA error log has increased.
CurrentPendingSector: one of more disk sectors could not be read and are marked to be reallocated (replaced with spare sectors).
OfflineUncorrectableSector: during off-line testing, or self-testing, one or more disk sectors could not be read.
Temperature: Temperature reached critical limit (see -W directive).
FailedHealthCheck: the SMART health status command failed.
FailedReadSmartData: the command to read SMART Attribute data failed.
FailedReadSmartErrorLog: the command to read the SMART error log failed.
FailedReadSmartSelfTestLog: the command to read the SMART self-test log failed.
FailedOpenDevice: the open() command to the device failed.
is determined by the address argument ADD of the '-m' Directive. If ADD is , then SMARTD_ADDRESS is not set. Otherwise, it is set to the comma-separated-list of email addresses given by the argument ADD, with the commas replaced by spaces (example:email@example.com root). If more than one email address is given, then this string will contain space characters and is NOT quoted, so to use it in a shell script you may want to enclose it in double quotes.
is set to the one sentence summary warning email message string from smartd. This message string contains space characters and is NOT quoted. So to use $SMARTD_MESSAGE in a shell script you should probably enclose it in double quotes.
is set to the contents of the entire email warning message string from smartd. This message string contains space and return characters and is NOT quoted. So to use $SMARTD_FULLMESSAGE in a shell script you should probably enclose it in double quotes.
is a text string giving the time and date at which the first problem of this type was reported. This text string contains space characters and no newlines, and is NOT quoted. For example:
Sun Feb 9 14:58:19 2003 CST
is an integer, which is the unix epoch (number of seconds since Jan 1, 1970) for SMARTD_TFIRST.
is an integer specifying the number of previous messages sent. It is set to '0' for the first message.
is an integer specifying the number of days until the next message will be sent. It it set to empty on '-M once' and set to '1' on '-M daily'.
For more details see
man smartd and