Bug 675778 - Usability proposal: Automatic notification to desktop user
Summary: Usability proposal: Automatic notification to desktop user
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: smartmontools
Version: 14
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Hlavinka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-07 18:01 UTC by Fdor
Modified: 2011-06-11 04:28 UTC (History)
5 users (show)

Fixed In Version: smartmontools-5.40-6.fc14
Clone Of:
Environment:
Last Closed: 2011-06-11 04:26:12 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Fdor 2011-02-07 18:01:20 UTC
I propose an usability improvement: Notify the user by default, in addition to sending an email to root.

It's true that fedora can be used in servers, so it's useful to send an email to root by default when a disk is starting to fail. But it's also true that fedora is used in desktops, where the user rarely logins as root to see the root mail, so it's also useful to notify the user by default.

Both things can be trivially done by adding some options to smartd.conf, and by creating a script file to process the actions to be done. This is the current default /etc/smartd.conf file installed by fedora:

DEVICESCAN -H -m root -n standby,10,q

And this is the new /etc/smartd.conf file to implement the proposal:

DEVICESCAN -H -m root -M exec /usr/lib/smartd_actions -n standby,10,q

So, to process the actions to be done when a disk begins to fail, the "/usr/lib/smartd_actions" file is launched. In order to send an email to root, and to notify the desktop user, the content of "/usr/lib/smartd_actions" can be:

--------------
#! /bin/sh

# Send mail
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"

# Notify desktop user
/usr/bin/notify-send -t 0 "WARNING: Your hard disk drive is failing!" "Description:
$SMARTD_MESSAGE"
--------------

To test the proposal, just add "-M test" option to the smartd.conf line, in this way:

DEVICESCAN -H -m root -M test -M exec /usr/lib/smartd_actions -n standby,10,q

and restart the smartd daemon ("/etc/init.d/smartd restart" command).

With the proposal, both server users and desktop users will be happy, with zero effort. I'm curretly running the proposal (well, I've commented out the root mail command at smartd_actions script), and it works fine. I needed many hours to understand how smartd works and its options, and to find a way to notify the user with the available smartd options. By including the proposal into fedora by default, users will need zero hours to have the thing working.

Thanks

Comment 1 Michal Hlavinka 2011-02-08 09:07:29 UTC
well... this is quite interesting idea, I'll look at it.

Comment 2 Fedora Update System 2011-02-17 16:46:32 UTC
smartmontools-5.40-6.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/smartmontools-5.40-6.fc15

Comment 3 Fedora Update System 2011-02-17 16:46:39 UTC
smartmontools-5.40-4.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/smartmontools-5.40-4.fc14

Comment 4 Fedora Update System 2011-02-17 22:25:20 UTC
smartmontools-5.40-6.fc15 has been pushed to the Fedora 15 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update smartmontools'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/smartmontools-5.40-6.fc15

Comment 5 Peter Hjalmarsson 2011-02-19 07:51:35 UTC
Will this not duplicate functionality found in gnome-disk-utility on the default GNOME-desktop? I remember getting messages in notification area from gdu when logging in with failing disks, but currently I have none easily connected to test with.

Comment 6 Michal Hlavinka 2011-02-21 09:18:53 UTC
the answer is "maybe", but gnome-disk-utility is not used in all desktop environments and also smartd is not installed and running by default, so I don't see any problem here.

Comment 7 Fedora Update System 2011-03-03 03:21:31 UTC
smartmontools-5.40-6.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2011-03-22 18:55:52 UTC
smartmontools-5.40-5.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Jason Farrell 2011-03-23 14:43:27 UTC
A small bug prevents this great usability enhancement from working. The notify script in the package is installed to "/usr/libexec/smartmontools/smartdnotify" but /etc/smartd.conf points at the non-existent "/usr/lib/smartd_actions" proposed script.

So, /etc/smartd.conf just needs a small fix to point at the actual script for this to work outofthebox.

Comment 10 Pavol Šimo 2011-03-23 15:51:52 UTC
I see 2 issues:

1. /usr/bin/notify-send requires DISPLAY and XAUTHORITY environment variables
and when started at system boot these are not available - so the notifications
are not displayed (when the service is restarted from within gnome-terminal, the variables are inherited from it)
2. /usr/libexec/smartmontools/smartdnotify script is not i18n friendly - so the
message (when it finally displays, after solving the 1. part) is only in
english language

Comment 11 Jason Farrell 2011-03-23 16:54:07 UTC
(In reply to comment #10)
> 1. /usr/bin/notify-send requires DISPLAY and XAUTHORITY environment variables

The first problem can at least be worked around by sleeping for a few minutes, giving enough time gdm to start and a user to log in, and then setting the needed env variables ourselves using a "hack", such as:

export DISPLAY=:0; export XAUTHORITY=$(ls -td /var/run/gdm/auth*gdm*|head -1)/database; /usr/bin/notify-send -u critical -t 0 'WARNING: Foo!'

Comment 12 Michal Hlavinka 2011-03-24 13:01:15 UTC
I knew its going to be complicated :) Maybe wall is better for this than notify-send?

Solution from comment #11 works only for gdm, does not work for kdm, so more code is needed (and it'll little bit be more ugly)

My present idea is:
1. smartdnotify is called
2. try to get XAUTHORITY and DISPLAY variables
3. if X session is not running, wait (two minutes?)
4. try again to get both variables
5. on success use notify-send
6. on failure use wall

any different ideas? comments?

Comment 13 Fdor 2011-03-27 14:40:12 UTC
That's true, notifications won't be shown because the smartd daemon is started before X, and "notify-send" requires the X session info ($DISPLAY and company) to work.

"wall" command doesn't require the X session info, and the notifications will be shown to desktop users too, so probably it's the way to go. Just use the following command at "/usr/libexec/smartmontools/smartdnotify" file:

--------------
# Notify desktop user
/usr/bin/wall -n "WARNING: Your hard drive is failing. Description: $SMARTD_MESSAGE"
--------------

That solves the X session info problem. I only see 3 minor problems:

1. We loose the spetific title at desktop notification ("wall" command only accepts a description).
2. The notification will also appear at text consoles (control+alt+Fx) and at gnome/kde consoles. (maybe an adventage instead of a problem?)
3. If the user is not logged in (gdm/kdm is shown), the notification is lost (it is not saved, to be shown when the user logs in). (it probably also happens with "notify-send")

The first two problems seems to be very minor to me. The third problem looks like a pending point in the linux notification system: When no users are logged in, notifications should be stored, in order to be shown when the users log in. Currently, those notifications are lost. I've searched at the internet, but I haven't found any command/way to do it.

I'll write a suggestion (to some notification component) to add the notification save/recover idea. In the mean time, I think the "wall" command is the way to go for smartd.

Thanks

Comment 14 Justin Guenther 2011-05-12 17:49:10 UTC
(In reply to comment #9)
> A small bug prevents this great usability enhancement from working. The notify
> script in the package is installed to "/usr/libexec/smartmontools/smartdnotify"
> but /etc/smartd.conf points at the non-existent "/usr/lib/smartd_actions"
> proposed script.
> 
> So, /etc/smartd.conf just needs a small fix to point at the actual script for
> this to work outofthebox.

Yeah, I just ran across this bug when I noticed that 1) my /etc/smartd.conf was wiped out when I updated this package at some point, and 2) the smartd_actions file mentioned above didn't exist, so I didn't get any notification at all.

Will this be fixed? I have updated my config but the only reason I noticed was when I had 10 pages of errors in my logwatch.

Comment 15 Michal Hlavinka 2011-05-16 13:42:05 UTC
smartd.conf is fixed

smartdnotify uses something like "wall" just without wall's ugly header

Comment 16 Fedora Update System 2011-05-16 14:13:51 UTC
smartmontools-5.40-6.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/smartmontools-5.40-6.fc14

Comment 17 Fedora Update System 2011-05-16 14:13:59 UTC
smartmontools-5.40-9.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/smartmontools-5.40-9.fc15

Comment 18 Fedora Update System 2011-05-17 01:06:18 UTC
Package smartmontools-5.40-6.fc14:
* should fix your issue,
* was pushed to the Fedora 14 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing smartmontools-5.40-6.fc14'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/smartmontools-5.40-6.fc14
then log in and leave karma (feedback).

Comment 19 Fedora Update System 2011-06-11 04:26:06 UTC
smartmontools-5.40-9.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Fedora Update System 2011-06-11 04:28:04 UTC
smartmontools-5.40-6.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.