echo "This is Nagios plugin to check HDD health from S.M.A.R.T. by Smartmontools."
echo '
The S.M.A.R.T. attributes are specific properties (parameters) of various parts of a disk.
S.M.A.R.T. uses attributes to monitor the disk condition and to analyze its reliability.
Script check HDD from S.M.A.R.T with the following properties (if your HDD supports it):
** Spin Retry Count (src) **
Count of retry of spin start attempts. This attribute stores a total count of the spin start attempts to reach the fully operational speed (under the
condition that the first attempt was unsuccessful). A decrease of this attribute value is a sign of problems in the hard disk mechanical subsystem.
** Reallocated Sector Count (rsc) **
Count of reallocated sectors. When the hard drive finds a read/write/verification error, it marks this sector as "reallocated" and transfers data to a
special reserved area (spare area). This process is also known as remapping and "reallocated" sectors are called remaps. This is why, on a modern hard
disks, you can not see "bad blocks" while testing the surface - all bad blocks are hidden in reallocated sectors.
** Reallocated Event Count (rec) **
Count of remap operations (transferring data from a bad sector to a special reserved disk area - spare area). The raw value of this attribute shows the
total number of attempts to transfer data from reallocated sectors to a spare area. Unsuccessful attempts are counted as well as successful.
** Current Pending Sector (cps) **
Current count of unstable sectors (waiting for remapping). The raw value of this attribute indicates the total number of sectors waiting for remapping.
Later, when some of these sectors are read successfully, the value is decreased. If errors still occur when reading some sector, the hard drive will try
to restore the data, transfer it to the reserved disk area (spare area) and mark this sector as remapped. If this attribute value remains at zero, it
indicates that the quality of the corresponding surface area is low.
** Offline Uncorrectable (ou) **
Quantity of uncorrectable errors. The raw value of this attribute indicates the total number of uncorrectable errors when reading/writing a sector.
A rise in the value of this attribute indicates that there are evident defects of the disk surface and/or there are problems in the hard disk drive
mechanical subsystem.
** Total health test (pass) **
This is test provided by Smartmontools. If total disk state is "health", Smartmontools marked as "PASSED".
'
echo "Nagios states:"
echo
echo "OK - if all values are \"0\"."
echo "Warning - if one or both values \"Spin Retry Count\" and \"Reallocated Event Count\" is between the values 1 to 9."
echo "Critical - if some value is greater than \"0\" except \"Spin Retry Count (>=10)\" and \"Reallocated Event Count (>=10)\"."
echo -e "\nMaybe you don't have enabled S.M.A.R.T support in $SMT! Please type \"smartctl -s on $device\" that you have it turned on, or device does not support S.M.A.R.T function."