You are not logged in.

#1 2025-02-19 00:49:01

LacrimasProfundere
Member
Registered: 2022-04-15
Posts: 6

[SOLVED]Getting S.M.A.R.T smartd Local Emails and Desktop Notification

Hello, I hope everyone is doing well.

Intention is to get a desktop notification popup on Plasma (Wayland) when a SMART error is detected, and an email into /var/spool/mail. I seem to have something wrong with my current configuration, having attempted to follow the wiki.

smartd.conf:

DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -m lacrimas@localhost -M exec /usr/local/bin/smartdnotify

/usr/local/bin/smartdnotify:

#!/bin/sh

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

# Desktop Notification
sudo -u lacrimas DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/lacrimas/bus notify-send "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning -u critical

I haven't set this service up before, I apologize if I'm missing something obvious - Please let me know if any more info would be helpful. If anyone has any ideas, I'd appreciate it - thank you!

Last edited by LacrimasProfundere (2025-02-22 17:41:52)

Offline

#2 2025-02-19 16:24:31

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,784

Re: [SOLVED]Getting S.M.A.R.T smartd Local Emails and Desktop Notification

https://wiki.archlinux.org/title/S.M.A. … management
Daemon is running?

Manual device scan works?
/usr/local/bin/smartdnotify is executable?
Manual execution of /usr/local/bin/smartdnotify works?


"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/lacrimas/bus" isn't canonical, try "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" or even better: import the environment from a relevant process, see https://gist.github.com/AladW/de1c5676d93d05a5a0e1 for a pattern

Offline

#3 2025-02-19 17:22:28

LacrimasProfundere
Member
Registered: 2022-04-15
Posts: 6

Re: [SOLVED]Getting S.M.A.R.T smartd Local Emails and Desktop Notification

seth wrote:

https://wiki.archlinux.org/title/S.M.A. … management
Daemon is running?

Manual device scan works?
/usr/local/bin/smartdnotify is executable?
Manual execution of /usr/local/bin/smartdnotify works?


"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/lacrimas/bus" isn't canonical, try "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" or even better: import the environment from a relevant process, see https://gist.github.com/AladW/de1c5676d93d05a5a0e1 for a pattern

I updated my syntax to reflect the /run/user/1000 you suggested and that seems to show improvement and work for the desktop notification - Thank you. I was also able to clear the "mail command not found" error by just installing s-nail and sendmail.

A little odd now (probably a syntax/config issue in smartd.conf) that the service shows as fail to start, but I still receive a desktop SMART status alert when it attempts to run. My smartd.conf line now reads:

DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -m lacrimas -M exec /usr/local/bin/smartdnotify

smartdnotify now reads:

#!/bin/sh

# Send Email
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" lacrimas

# Desktop Notification
sudo -u lacrimas DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning -u critical

"Unqualified host name unknown"

sudo systemctl status smartd.service 
× smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
     Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled; preset: disabled)
     Active: failed (Result: timeout) since Wed 2025-02-19 11:13:50 CST; 26s ago
   Duration: 25min 24.128s
 Invocation: 00d8ef53786845198f41f7a68da15c83
       Docs: man:smartd(8)
             man:smartd.conf(5)
    Process: 545036 ExecStart=/usr/bin/smartd -n $SMARTD_ARGS (code=killed, signal=TERM)
   Main PID: 545036 (code=killed, signal=TERM)
     Status: "Checking 10 devices ..."
   Mem peak: 8M
        CPU: 82ms

Feb 19 11:13:38 DesktopPC sudo[545402]:     root : PWD=/ ; USER=lacrimas ; ENV=DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus ; COMMAND>
Feb 19 11:13:38 DesktopPC sudo[545402]: pam_unix(sudo:session): session opened for user lacrimas(uid=1000) by (uid=0)
Feb 19 11:13:38 DesktopPC sudo[545402]: pam_unix(sudo:session): session closed for user lacrimas
Feb 19 11:13:38 DesktopPC smartd[545036]: Warning via /usr/local/bin/smartdnotify to lacrimas: successful
Feb 19 11:13:38 DesktopPC smartd[545036]: Device: /dev/sdc [SAT], 8 Offline uncorrectable sectors
Feb 19 11:13:38 DesktopPC smartd[545036]: Sending warning via /usr/local/bin/smartdnotify to lacrimas ...
Feb 19 11:13:38 DesktopPC sendmail[545448]: My unqualified host name (DesktopPC) unknown; sleeping for retry
Feb 19 11:13:50 DesktopPC systemd[1]: smartd.service: start operation timed out. Terminating.
Feb 19 11:13:50 DesktopPC systemd[1]: smartd.service: Failed with result 'timeout'.
Feb 19 11:13:50 DesktopPC systemd[1]: Failed to start Self Monitoring and Reporting Technology (SMART) Daemon.
exa -l /usr/local/bin/smartdnotify
.rwx--x--x 299 root 18 Feb 18:26 /usr/local/bin/smartdnotify

Showing improvement, just trying to figure out what's up with the mail or causing the daemon to crash now. Basically just trying to get a "you have mail" message when opening a terminal to alert me (in addition to the desktop notification that's already working).
Thank you very much.

Edit: I noticed my /etc/hosts file didn't have a reference to 127.0.0.1 so I added:

127.0.0.1    localhost.localdomain localhost DesktopPC
127.0.1.1    DesktopPC

I then noticed that the sendmail service was complaining about "cannot open /etc/mail/local-host-names", which didn't exist on my system so I copied my /etc/hosts file to that directory and renamed it, which seems to have cleared that error, but am now presented to another from sendmail:

sendmail.service - Sendmail Mail Transport Agent
     Loaded: loaded (/usr/lib/systemd/system/sendmail.service; disabled; preset: disabled)
     Active: active (running) since Wed 2025-02-19 13:14:47 CST; 3s ago
 Invocation: b78f48210efd4bd8af31b55011526e6b
    Process: 578623 ExecStartPre=/usr/bin/newaliases (code=exited, status=0/SUCCESS)
    Process: 578625 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
   Main PID: 578626 (sendmail)
      Tasks: 1 (limit: 38292)
     Memory: 2.9M (peak: 5.9M)
        CPU: 34ms
     CGroup: /system.slice/sendmail.service
             └─578626 "sendmail: accepting connections"

Feb 19 13:14:47 DesktopPC sm-mta[578663]: 51JJEl4M578655: SYSERR(root): Cannot exec /usr/bin/procmail: No such file or directory
Feb 19 13:14:47 DesktopPC sm-mta[578662]: 51JJEl4M578655: to=<lacrimas@localhost.localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30619, dsn=4.0.0, stat=Operating system error
Feb 19 13:14:47 DesktopPC sm-mta[578655]: 51JJEl4O578655: from=<root@localhost.localdomain>, size=398, class=0, nrcpts=1, msgid=<202502191713.51JHDcYw545179@DesktopPC>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 19 13:14:47 DesktopPC sm-mta[578665]: 51JJEl4O578655: Warning: program /usr/bin/procmail unsafe: No such file or directory
Feb 19 13:14:47 DesktopPC sm-mta[578665]: 51JJEl4O578655: SYSERR(root): Cannot exec /usr/bin/procmail: No such file or directory
Feb 19 13:14:47 DesktopPC sm-mta[578664]: 51JJEl4O578655: to=<lacrimas@localhost.localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30619, dsn=4.0.0, stat=Operating system error
Feb 19 13:14:47 DesktopPC sm-mta[578655]: 51JJEl4Q578655: from=<root@localhost.localdomain>, size=799, class=0, nrcpts=1, msgid=<202502191727.51JHREBg548626@DesktopPC>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 19 13:14:47 DesktopPC sm-mta[578667]: 51JJEl4Q578655: Warning: program /usr/bin/procmail unsafe: No such file or directory
Feb 19 13:14:47 DesktopPC sm-mta[578667]: 51JJEl4Q578655: SYSERR(root): Cannot exec /usr/bin/procmail: No such file or directory
Feb 19 13:14:47 DesktopPC sm-mta[578666]: 51JJEl4Q578655: to=<lacrimas@localhost.localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31020, dsn=4.0.0, stat=Operating system error

Have to step away for a bit but will keep playing around with this. Not sure what procmail is yet or why these resources seem to be missing from sendmail.

Last edited by LacrimasProfundere (2025-02-19 19:19:49)

Offline

#4 2025-02-19 23:42:25

LacrimasProfundere
Member
Registered: 2022-04-15
Posts: 6

Re: [SOLVED]Getting S.M.A.R.T smartd Local Emails and Desktop Notification

Simply installing procmail resolved the above issue. Restarted the sendmail service and then smartd, and alerts now seem to be sending properly.

Last question if someone can look over my .zshrc to see if I have it set correctly to check for unread mail ('autoload checkmail' on the fourth line), I'd like to get a notice/message when I open the console. Just not sure if I have the placement/order correct, when I restart the smartd service I get one message after it starts "You have new mail", but it's just that single message - If I close the terminal and reopen a new one I don't get a mail message in console.

HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
autoload checkmail
bindkey -e
#zstyle ':autocomplete:*' list-lines 0
#source /usr/share/zsh/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh

source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/lacrimas/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall
eval "$(starship init zsh)"
#alias ls='ls --color=auto'
alias ls='exa'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias update='yay -Syu && flatpak update'
alias clean='yay -Scc && yay -Sc && yay -Qtdq | yay -Rns -'
alias virt='virsh net-start default'
alias errs='sudo journalctl -b -p err|less'

export PF_INFO="ascii title os kernel de shell uptime pkgs memory"
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Also, is it redundant to have both the

DEVICESCAN -m lacrimas

line for mailing in my smartd.conf, as well as the

echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" lacrimas

? Would it be trying to send an email for each of those lines?

Last edited by LacrimasProfundere (2025-02-19 23:44:34)

Offline

#5 2025-02-20 13:29:47

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,784

Re: [SOLVED]Getting S.M.A.R.T smartd Local Emails and Desktop Notification

You don't need a full blown MTA for local mails, esp. from anything that runs as root and can write files everywhere.
They're just text files in a special directory.
See eg https://unix.stackexchange.com/question … y-for-cron for ideas.

Then see /usr/share/zsh/functions/Misc/checkmail or https://github.com/zsh-users/zsh/blob/3 … ckmail#L24
It checks whether the mail file has been modified since it's last access - if at any point it gets opened for reading, this will no longer be true, but the test itself should™ not cause such.

is it redundant to have both

Most likely yes, depend on whether "-m" works in your setup (which is likely)

Offline

Board footer

Powered by FluxBB