Opened 3 years ago

Closed 3 years ago

#1572 closed defect (invalid)

smartmontools 7.2: mailer call in wrong way

Reported by: evgeniy Owned by:
Priority: minor Milestone:
Component: smartd Version:
Keywords: smartd.conf Cc:

Description

I have such configuration in /etc/smartd.conf:
/dev/nvme0n1 -a -d nvme -n sleep -m root -M daily -M exec /etc/smartd_warning.sh

/etc/smartd_warning.sh is default one except:
Except such lines right after "set -e":

echo "smartd_warning.sh start" | logger -t "smartd script"
echo "args: $@" | logger -t "smartd script"

And recently I saw this in log:
Feb 26 13:58:43 15inch logger[1045974]: smartd script: smartd_warning.sh start
Feb 26 13:58:43 15inch logger[1045976]: smartd script: args: -s SMART error (ErrorCount) detected on host: 15inch root
Feb 26 13:58:43 15inch smartd[861]: Warning via /etc/smartd_warning.sh to root produced unexpected output (809 bytes) to STDOUT/STDERR:
Feb 26 13:58:43 15inch smartd[861]: smartd 6.3 warning message script
Feb 26 13:58:43 15inch smartd[861]: Usage:
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_MAILER='Path to external script, empty for "mail"'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_ADDRESS='Space separated mail adresses, empty if none'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_MESSAGE='Error Message'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_FAILTYPE='Type of failure, "EMailTest" for tests'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_TFIRST='Date of first message sent, empty if none'
Feb 26 13:58:43 15inch smartd[861]: #export SMARTD_TFIRSTEPOCH='time_t format of above'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_PREVCNT='Number of previous messages, 0 if none'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_NEXTDAYS='Number of days until next message, empty if none'
Feb 26 13:58:43 15inch smartd[861]: export SMARTD_DEVICEINFO='Device identify information'
Feb 26 13:58:43 15inch smartd[861]: #export SMARTD_DEVICE='Device name'
Feb 26 13:58:43 15inch smartd[861]: #export SMARTD_DEVICESTRING='Annotated device name'
Feb 26 13:58:43 15inch smartd[861]: #export SMARTD_DEVICETYPE='Device type from -d directive, "auto" if none'
Feb 26 13:58:43 15inch smartd[861]: /etc/smartd_warning.sh [--dryrun]
Feb 26 13:58:43 15inch smartd[861]: Warning via /etc/smartd_warning.sh to root: failed (32-bit/8-bit exit status: 256/1)

So for some reason there is some additional argument "-s" was passed to smartd_warning.sh and also message was passed not via environment variable,
while manual page tells that message should be in SMARTD_MESSAGE

Change History (2)

in reply to:  description comment:1 by Christian Franke, 3 years ago

I have such configuration in /etc/smartd.conf:
/dev/nvme0n1 -a -d nvme -n sleep -m root -M daily -M exec /etc/smartd_warning.sh

This configuration is invalid and runs /etc/smartd_warning.sh recursively. Note that -M exec is usually not needed to send warning emails.

$ man smartd.conf
...
       -M TYPE
              ...
              exec  PATH - run the executable PATH instead of the default mail
              command, when smartd needs to send email. ...
              ...
              The  executable  is  run  by  the script /etc/smartd_warning.sh.
              This  script  formats  subject  and  full   message   based   on
              SMARTD_MESSAGE  and  other  environment variables set by smartd.
              The environment variables SMARTD_SUBJECT and  SMARTD_FULLMESSAGE
              are set by the script before running the executable.
...
       EXAMPLES OF SHELL SCRIPTS FOR '-M exec'
              ...
              Example 1: ...
              ...
              Example 2: ...
              ...
              Some example scripts  are  distributed  with  the  smartmontools
              package, in /usr/share/doc/smartmontools/examplescripts/.

The examples are also available at trunk/smartmontools/examplescripts.
See also -w PATH, --warnexec=PATH on smartd man page.

comment:2 by Christian Franke, 3 years ago

Component: allsmartd
Keywords: smartd.conf added
Resolution: invalid
Status: newclosed

-M exec /etc/smartd_warning.sh must not be used. See above for details.

Note: See TracTickets for help on using tickets.