Audible warning when HDD goes bad

Kernels & Hardware, configuring network, installing services

Audible warning when HDD goes bad

Postby djevlen » 2020-03-24 11:19

Hi

How to configure hdd monitoring so when hdd is about to fail or S.M.A.R.T. is logging errors, the motherboard onboard speaker will give audible warnings ?

OS : Debian 10 buster
Mobo : Supermicro X7SPE-HF

All other similar questions are how to send email ...
Im not interested in emails...Server is at home and so am i... Audible warning will draw my attention must faster.

Any help would be greatly appreciated.
Thanx
djevlen
 
Posts: 16
Joined: 2013-02-06 20:08

Re: Audible warning when HDD goes bad

Postby pylkko » 2020-03-24 12:23

I don't think that there is a ready-made solution for this, but I may be wrong. However, you could in theory use beep

https://manpages.debian.org/buster/beep/beep.1.en.html

for example, in a script which polls the SMART data. This means that you would need to decide an interval at which to check the data (once a day? Once every hour?) and then check that a value is not exceeded (which ever value you are interested) and then have that script make the sound.

However, you must realize that hard drives many times fail without warning or that the indicator of detrimental change is not a necessarily a number, but how quickly the number changes. SO in this kind of case you would need a more sophisticated decision marker than a simple cutoff (like keep a history of some sort)

Also, this kind of thing might already be programmed into the firmware/UEFI/BIOS, so check that.
User avatar
pylkko
 
Posts: 1793
Joined: 2014-11-06 19:02

Re: Audible warning when HDD goes bad

Postby djevlen » 2020-03-26 12:54

hi

i know it should be something like this DEVICESCAN [...other...options...] -m <nomailer> -M exec /path/to/your/script

The problem is that i have no idea how to make scripts....

installed beep, but it only wants to run as root....

Strange no one else asked for this feature before.....

Hope some one will sooner or later see this thread and post a simple how to do...
djevlen
 
Posts: 16
Joined: 2013-02-06 20:08

Re: Audible warning when HDD goes bad

Postby pylkko » 2020-03-28 21:04

What are you saying? When you say "i know it should be something like this", in that sentence what is "it"? How do you know this? and why should something be something? Do you have previous experience with a software of this type.

If you do not have this option in your firmware, and you do not want to specify what you want to monitor (why do you not answer at least this, there is no way anyone can come here and reply to you unless you do). Then one thing you could do is run smartctl, which return as 0 if all is ok:

https://linux.die.net/man/8/smartctl

So, then your script would be something like do "beep" if smartctl returns something else than zero.
How often would you like to do this beep? For ever? or a short beep every certain minute/second?
User avatar
pylkko
 
Posts: 1793
Joined: 2014-11-06 19:02

Re: Audible warning when HDD goes bad

Postby djevlen » 2020-03-29 14:53

the optimal script would beep when smartctl throws an error. I would use H option in smartctl because that way its not spinning up the disk...full scan of course spins them up..my discs support 0x0003 feature...so the data is saved before they spin down.

something like this:
smartctl -H -d ata /dev/sda
smartctl -H -d ata /dev/sdb
smartctl -H -d ata /dev/sdc

and if error occurs the sound should be something like this : beep -r 99999 -l 150 -f 700 -D 1000

and the perfect version would be if it fails on sda then only 1 beep , if on sdb then 2 short beeps, if on sdc then 3 short beeps
djevlen
 
Posts: 16
Joined: 2013-02-06 20:08

Re: Audible warning when HDD goes bad

Postby pylkko » 2020-04-03 06:04

In a bash shell you can get the exit code of a command with $?

so if you do the command smartctl, /dev/sda and you get the exit code bit mask described in the man of smartctl, you can then use this to do the beep

This is described in detail in this guide:
https://www.cyberciti.biz/faq/bash-get- ... f-command/

once the script runs, then make a sytemd service to autolaunch it.

if you need more help, ask.
User avatar
pylkko
 
Posts: 1793
Joined: 2014-11-06 19:02

Re: Audible warning when HDD goes bad

Postby djevlen » 2020-04-04 11:51

how can i test it when i have no broken disc and no errors at all ?
djevlen
 
Posts: 16
Joined: 2013-02-06 20:08

Re: Audible warning when HDD goes bad

Postby pylkko » 2020-04-04 17:28

You make a pseudobroken disk, I guess. For example, smartcrl will return zero when you don't have permission. Or you make a script that beeps with grave error and just prints something when not.
User avatar
pylkko
 
Posts: 1793
Joined: 2014-11-06 19:02


Return to System configuration

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable