LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-15-2018, 02:23 PM   #1
AmandaM
LQ Newbie
 
Registered: Dec 2018
Posts: 3

Rep: Reputation: Disabled
notify-send from smartd / Fedora 29


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
 
Old 12-18-2018, 07:49 AM   #2
AmandaM
LQ Newbie
 
Registered: Dec 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
I now have this working as indented. "notify-send" was being blocked by SELinux.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Send Results of Curl Command to Notify-Send? jakfish Linux - General 7 09-01-2016 08:55 AM
Could we have an rc.smartd script, to stop upgrades from disabling smartd please? xj25vm Slackware 6 03-23-2016 01:45 PM
Notifications don't show up (notify-send notify-osd) michal017 Linux - Desktop 0 05-06-2014 03:44 PM
log send, sendrec, recv and notify system calls xeon123 Other *NIX 1 02-04-2008 05:26 PM
Smartd Error Message generated by Smartd Daemon Proces rexjenny Red Hat 1 11-29-2006 07:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration