2

I'm trying to get smartd working; it is determined that messages will be sent via email via 'mail' which I've never used. But I recall that a few years ago I had smartd sending it's warnings directly to the screen via a popup text box. I'm trying to figure out how to do that again. The info for the 'screen' command baffles me. tmux likewise. Or I suppose it could be a notification. When I have a few weeks to study it, I'll get 'mail' working but for now I'd prefer a popup message anyway.

==================================================

In 'smartd.conf':

DEVICESCAN -a -m <nomailer> -M exec notify -M test

... Ok, added full path, much better:

DEVICESCAN -a -m <nomailer> -M exec /bin/notify -M test

... 'notify' runs fine from CLI, is an executable script:

/bin/notify-send "$(systemctl status smartd)"

... but although:

 systemctl restart smartd; systemctl status smartd

... reports no errors, I get no 'test' result.

BTW, so far no results at all using those variables you mentioned.

...

$ smartd ... shows two notifications, one for each of my two disks! So why does 'systemctl restart smartd' show nothing?

Ray Andrews
  • 2,125
  • 4
  • 20
  • 37

2 Answers2

3

You will need notify-send and a special mailer:

First, make a script like:

#!/bin/sh
/usr/bin/notify-send "$SMARTD_DEVICESTRING" "$SMARTD_MESSAGE"

Second, add this to a smartd.conf to your drive test descriptions:

-m <nomailer> -M exec /path/script

The <nomailer> is a special address, which tells smartd to completely rely on the script passed as -M exec. smartd would put all the info about a problem into set of env variables and run the script (no parameters, no stdin). If the script does some printout, its stdout will go to syslog.

For additional reading: man 5 smartd.conf

White Owl
  • 4,511
  • 1
  • 4
  • 15
1

Here's what I was doing wrong, starting from White Owl's answer:

The script 'notify':

#!/bin/zsh
/usr/bin/notify-send "$SMARTD_DEVICESTRING" "$SMARTD_MESSAGE"

... works fine. But it must be 'chmod +x' to make it executable. The active line in '/etc/smartd.conf':

DEVICESCAN -a -m <nomailer> -M exec /aWorking/Zsh/System/notify -M test

... I had assumed 'notify' would be found if on the system path, but no, you have to give an exact literal path to it. And here's the thing that cost me the most time:

$ systemctl restart smartd

... DOESN'T activate the script (for some reason), you hafta:

$ smartd

... and then it fires up as expected. One message per disk.

All good.

Ray Andrews
  • 2,125
  • 4
  • 20
  • 37