OS: Fedora 29
Recently, I have been trying to setup smartd. I have the daemon sending local emails but I would like to have a more "visible" method of HDD warnings. The "nicest" way of doing this would be to use notify-send. However, I am currently unable to get this to work.
My Procedure
So far, I have added this line into smartd.conf
Code:
DEVICESCAN -H -m nm@localhost -M test -M exec /etc/smartmontools/smartd_warning.d/notify
Then I created a script in /etc/smartmontools/smartd_warning.d called "notify". The notify script looks like this:
Code:
#!/bin/sh
IFS=$'\n'
for LINE in `w -hs`
do
USER=`echo $LINE | awk '{print $1}'`
USER_ID=`id -u $USER`
DISP_ID=`echo $LINE | awk '{print $8}'`
sudo -u $USER DISPLAY=$DISP_ID
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$USER_ID/bus notify-send "Possible HDD Error: $SMARTD_FAILTYPE" "SMART has reported the following error:\n\n$SMARTD_MESSAGE" --icon=dialog-error
done
I then restart the smartd daemon and check journalctl -u smartd. The log is as following.
Code:
Dec 15 20:17:51 nm.asys-it.com systemd[1]: Stopping Self Monitoring and Reporting Technology (SMART) Daemon...
Dec 15 20:17:51 nm.asys-it.com systemd[1]: Stopped Self Monitoring and Reporting Technology (SMART) Daemon.
Dec 15 20:17:51 nm.asys-it.com systemd[1]: Started Self Monitoring and Reporting Technology (SMART) Daemon.
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: smartd 6.6 2017-11-05 r4594 [x86_64-linux-4.19.6-300.fc29.x86_64] (local build)
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Opened configuration file /etc/smartmontools/smartd.conf
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Configuration file /etc/smartmontools/smartd.conf was parsed, found DEVICESCAN, scanning devices
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Device: /dev/sda, type changed from 'scsi' to 'sat'
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Device: /dev/sda [SAT], opened
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Device: /dev/sda [SAT], ST2000LM015-2E8174, S/N:ZDZ3YZJN, WWN:5-000c50-0b2765797, FW:SDM1, 2.00 TB
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Device: /dev/sda [SAT], found in smartd database: Seagate Barracuda 2.5 5400
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Device: /dev/sda [SAT], is SMART capable. Adding to "monitor" list.
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Monitoring 1 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Executing test of /etc/smartmontools/smartd_warning.d/notify to nm@localhost ...
Dec 15 20:17:51 nm.asys-it.com smartd[15393]: Test of /etc/smartmontools/smartd_warning.d/notify to nm@localhost: successful
As you can see from the journal log, smartd seems to be working correctly, however, the notify-send message never arrives. I have tried directing to, and logging in, as root but experience the same problem.
Incidentally, If I run the "notify" script manually, then the notification message arrives as expected.
I have also tried using the following line in smartd.conf but this does not work either.
Code:
DEVICESCAN -H -m nm@localhost,@notify -M test
Does anybody have any idea why the notification message never arrives?
Many thanks
Amanda