S.M.A.R.T. information is collected by the built-in systems of modern HDDs. A summary can often be seen in a BIOS setup menu.
You can also see it with smartctl that is installed with the package smartmontools
See There are examples near the end of the manual. For example
sudo apt-get install smartmontools
sudo smartctl -a /dev/sdb
sudo smartctl -t long /dev/hdc
Begin an extended self-test of drive /dev/hdc. You can issue this command on a running system.
The results can be seen in the self-test log visible with the ´-l selftest´ option after it has