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 2010-10-27 18:42:24

bound4h
Member
Registered: 2010-04-12
Posts: 209

Setting up Smartmon

I read here (http://dns323.kood.org/howto:smartd_email) that you can setup smartd to run a scan (smartctl -a) and email the results to you with these two scripts.  The scripts are:

#!/ffp/bin/bash
# /ffp/sbin/smartd_mail.sh

SMARTMESSAGE=/ffp/tmp/msg
FROMADDR=email@domain.org

if [ ! -n "${SMART_DEVICETYPE+x}" ]; then
    SMART_DEVICETYPE=marvell
fi

# Save the email message (STDIN) to a file:
cat > $SMARTMESSAGE

# Append the output of smartctl -a to the message:
/ffp/sbin/smartctl -a -d $SMART_DEVICETYPE $SMARTD_DEVICE >> $SMARTMESSAGE

# Now email the message to the user at address ADD:
/ffp/bin/mailx -s "$SMARTD_SUBJECT" -r $FROMADDR $SMARTD_ADDRESS < $SMARTMESSAGE

and this one is the smartd.conf file:

# Comment out DEVICESCAN
#DEVICESCAN

/dev/sda -d marvell -m myEmail@domain.org -M exec /ffp/sbin/smartd_mail.sh -M test
/dev/sdb -d marvell -m myEmail@domain.org -M exec /ffp/sbin/smartd_mail.sh -M test

I can run from the command line 'smartctl -d marvell -a /dev/sda' and get a full output just fine.

My question is, in the first script, it calls $SMARTD_DEVICE and $SMARTD_ADDRESS but these two variables are not set anywhere?  Am I missing something? Do I need to add:

$SMARTD_DEVICE=/dev/sda
$SMARTD_ADDRESS=myemail@mydomain.com

?

Hopefully someone is familiar with smartmon!  Thanks

Last edited by bound4h (2010-10-27 18:43:16)

Offline

 

#2 2010-10-27 22:11:01

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

Re: Setting up Smartmon

No, the smartd daemon would set those before it calls your script.  You are giving it those values in the smartd.conf file.

I don't run smartd as a daemon, so I don't have any further insights, other than what I would get by reading the online documentation for smartd.  For example, those env vars are explained here: http://smartmontools.sourceforge.net/man8/smartd.8.html


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

Offline

 

#3 2010-10-28 04:05:32

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Setting up Smartmon

I too do not run the daemon, I just run a dump once a day as a cron job then logrotate that on a daily basis on a USB stick and keep a weeks worth so I can view it now and then to see if there are any issues I should be worried about, or, be able to view it in case a drive crashed.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#4 2010-10-28 04:37:49

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Setting up Smartmon

Well, damn.  I guess using the ctl would be easier, and set it up as a cronjob as you guys did.  I just basically want somehow to run the tests periodically and if either A) it fails a selftest, or B) certain attributes fall below a certain threshold I want it to notify me.  If you have them loading to a USB dongle, and then your drive fails.  You really don't have too much notice to salvage the data.  Which defeats the purposes of SMART.  Right? 

Do you have a suggestion for how I could somehow let it 'sleep' and run the tests daily/weekly/etc but NOTIFY me if something matches a pattern (FAIL, etc)?

Open for anything at this point, I'm not proficient in scripting so I have to depend on pre-written scripts (which I can understand, but beyond that I'm lost when it comes to creating them smile).

Thanks

Last edited by bound4h (2010-10-28 04:38:22)

Offline

 

#5 2010-10-28 16:12:56

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Setting up Smartmon

I, too, was interested in a periodic (daily) SMART test, using cron instead of smartd.
I wanted to write a script the emails the results of such a test, but had some trouble setting up the email part. I did search the forum for posts about it but couldn't make it work. It seemed doable, but I could figure it out: too many "moving parts" and a lack of understanding on my part of what's the role of each; Somewhat disjoint user suggestions.
I didn't look at the email thing wholeheartedly, thought, since I had already setup an rsync snapshot backup.

Since then I forgot about it. If anyone can spare the time and elaborate on how-to-email-from-ash-script. I'll gladly pick up that "missing piece" of the puzzle and set-up a SMART/cron job - one which I'll obviously share.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#6 2010-10-28 18:41:27

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

Re: Setting up Smartmon

Yeah, getting the "script from email" part is a pain.  If you are running ffp, you should be able to install mailx and then just need to configure it.   But I don't know for sure, as I am not using ffp.  I am using mutt from the stock firmware, but that took some effort to config.

I need to do more work with SMART, and may think about the daemon again.  But for now, I have the following in my crontab, which always emails me the report periodically:

/opt/sbin/smartctl -d marvell --all /dev/sda | /usr/bin/mutt -s "Drive A" me@mail.com

The return value of smartctl can be used to conditionally send the email if something was found to be wrong.  So, changing the above to:

/opt/sbin/smartctl -d marvell -H /dev/sda > /tmp/report || /usr/bin/mutt -s "Drive A" me@mail.com < /tmp/report

will only send the mail when the return value is non-zero, which happens when there is bad news to report.

You can "test" the emailing part by changing the || to && to cause the mail part of it to run unconditionally.

I just made this mod to my crontab and it seems to work.  I'll probably have crontab send me an unconditional report once a week, and then also run the conditional report hourly or so.

Last edited by karlrado (2010-10-28 18:47:29)


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

Offline

 

#7 2010-10-28 18:46:19

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Setting up Smartmon

Too bad I don't have optware.  I'm happy with ffp though, so I guess no reason to change.

Yea, I installed mailx but I'm not getting the emails.  I don't even know how to begin troubleshooting it.  Any logs?

If anyone knows about mailx via smartmon, would love to hear.

Thanks,

Offline

 

#8 2010-10-28 18:51:36

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

Re: Setting up Smartmon

Sorry, I had corrected my post - mutt is in /usr/bin and so is part of the original system.  I think I had to install some other MTA (Mail Transfer Agent) to work with mutt - but I do not remember the details.

It really is not a matter of getting mailx to work with smartctl.  It is more of just getting mailx to work from a script or command line.  Once you have that working, then you can use it to send smartctl output.

Maybe start a new thread about mailx, specifically.


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