DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-10-12 15:46:29

nurunet
Member
From: Germany
Registered: 2008-08-31
Posts: 44

Send smartd report via esmtp

Hi!

Has anyone accomplished to send smartd reports via esmtp? I read all the documentations and man pages, but that stuff is far too advanced for me. :-( All I want to do is to set up smartd to send me mail reports about special occurrences. While I think I can handle the smartd.conf syntax, esmtp seems out of reach.

This essentially is what I have in smartd.conf:

Code:

/dev/sda -d marvell -m tab3@example.com -M exec /ffp/bin/esmtp -M test
/dev/sdb -d marvell -m tab3@example.com -M exec /ffp/bin/esmtp -M test

When running smartd, this is what I get:

Executing test of /ffp/bin/esmtp to tab3@example.com ...
Test of /ffp/bin/esmtp to tab3@example.com produced unexpected output (112 bytes) to STDOUT/STDERR:
0 (null)
tab3@example.com: 0 (null)
procmail: Unknown user "smart error (emailtest) detected on host: nurunas"

Test of /ffp/bin/esmtp to tab3@example.com: failed (32-bit/8-bit exit status: 17920/70)
Executing test of /ffp/bin/esmtp to tab3@example.com ...
Test of /ffp/bin/esmtp to tab3@example.com produced unexpected output (112 bytes) to STDOUT/STDERR:
0 (null)
tab3@example.com: 0 (null)
procmail: Unknown user "smart error (emailtest) detected on host: nurunas"

Test of /ffp/bin/esmtp to tab3@example.com: failed (32-bit/8-bit exit status: 17920/70)

My esmtprc looks like this:

Code:

hostname = post.strato.de:25
username = "tab3@example.com"
password = "myPass"
force sender = "NAS Admin"

mda "/ffp/bin/procmail -d %T"

procmail in /etc looks like this:

Code:

# Please check if all the paths in PATH are reachable,
# remove the ones that are not.

PATH=$HOME/bin:/usr/bin:/bin:.
MAILDIR=/ffp/mail # You'd better make sure it exists
DEFAULT=$MAILDIR/mbox
LOGFILE=$MAILDIR/from
LOCKFILE=$HOME/.lockmail

I guess I'm doing a lot of things wrong here, as I don't really know what I am doing at all. Can anyone help me fix this mess? If I could finish smartd config, I'd be ready to use the CH3SNAS productively.

Greeting
Ben


Conceptronic CH3SNAS FW 1.03, ffp from USB key.

Offline

 

#2 2009-12-18 01:18:46

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Send smartd report via esmtp

I think what is happening is that smartd is sending

-s "Subject text" joe@x.com

to esmtp.  esmtp does not understand the -s option and is treating both "Subject text" and joe@x.com as recipients.  "Subject text" is an unknown user.

Turns out that the mail will still get sent, without a subject, to joe@x.com.  It does for me.

I'm not sure what the best way is to fix this.  Easiest would probably be to install a mail program that accepts the above syntax.


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#3 2009-12-18 09:29:25

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Send smartd report via esmtp

karlrado wrote:

Easiest would probably be to install a mail program that accepts the above syntax.

http://www.inreto.de/dns323/fun-plug/0. … html#mailx

Offline

 

#4 2009-12-19 05:47:01

diagpope
New member
Registered: 2009-12-19
Posts: 3

Re: Send smartd report via esmtp

Although this might not be what you desired: I am using a separate script with estmp to send the smartctl logs via cron:
crontab has:
--------------
3 */6 * * * /mnt/HD_a2/root/bin/email_smartctl.sh

Requires to set MAILTO variable eg. in ~/.profile and edit the <your hostname> and <your domain> and make the paths fit your needs

script is:
----------

!/bin/sh

. /mnt/HD_a2/root/.profile

body="$logdir/.body.$$"
header="$logdir/.header.$$"

subject=$*
#------------------------
if [[ 1=0 ]]; then
while [[ "$1" = "-*" ]]; do
echo "\$1 = $1 \$2 = $2"
case $1 in
   -subject ) echo "\$1 = $1 \$2 = $2"; subject=$2;;
  esac
shift;
if [[ "-$3" != "-" ]]; then
   shift;
fi
done
fi
#------------------------
subject=${subject:-"DNS-323 ($HOST) sending smartctl logs on schedule"}
echo "Subject: $subject" > $header
echo "From: <your hostname>@<your domain>" >> $header
echo "To: $MAILTO" >> $header
echo >> $header

cat $header > $body
cd /mnt/HD_a2/root/cronjobs
for s in sda sdb ; do
echo "=== START of $s ===" >> $body
cat smartctl.$s.log >> $body
echo -en "=== END of $s ===\n\n" >> $body
done
cat $body | esmtp -v $MAILTO
/bin/rm -f $body $header

~/.esmtprc is:
-----------------
identity root@<domain>
hostname = <mailserver>:25
username = "<user>"
password = "<password>"
default

Offline

 

#5 2009-12-22 03:36:56

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Send smartd report via esmtp

fonz wrote:

karlrado wrote:

Easiest would probably be to install a mail program that accepts the above syntax.

http://www.inreto.de/dns323/fun-plug/0. … html#mailx

I ended up using mutt, which was already present on the system.

I copy this .muttrc to /home/root on bootup.

Code:

set sendmail="/opt/sbin/sendmail"
set from="dlink"
set use_from=no
set assumed_charset="utf-8"
set move=no
set sendmail_wait=0
set copy=no

I had installed esmtp from the optarc packages and /opt/sbin/sendmail is just a symlink to esmtp.

Then, change the smartctl config file to use mutt:

Code:

-m <email addr> -M exec /usr/bin/mutt

DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB