script to get hard disk health in fedora/ubuntu

First, put this in a script.

#!/bin/bash

#Change as appropriate
HDD=sda

export sub="SmartCtl data for HDD"
echo 'To: <Your Email>
Sub: [Cron] $sub
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline

<html><pre>'


echo '<style>

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}
</style>
'

echo '<h2>Errors on HDD:</h2>'
echo '<hr>'
sudo smartctl -l error  /dev/$HDD
echo '<h2>Health of HDD:</h2>'
echo '<hr>'
sudo smartctl -H  /dev/$HDD

echo '<h2>Detailed info</h2>'
echo '<hr>'
sudo smartctl -a -d ata /dev/$HDD

echo '<h2>Journalctl output for smartd</h2>'
echo '<hr>'

if [[ -f /etc/fedora-release ]]
then
journalctl -x --show-cursor -u smartd --since=yesterday
else
#This is for Ubuntu.. still using dmesg

dmesg -T -l err,crit,alert,emerg

fi


echo '<h2>All Details</h2>'
echo '<hr>'

sudo smartctl --xall /dev/$HDD


echo "Thanks for using Amit Agarwal's script"
echo '</pre></html>'

and then put this in cron:

30 15 * * 5 <script name> |/usr/sbin/sendmail -t

You need to have mail configured to receive the mails.

geary mail – gnome mail client

A new mail client is coming in town.

Gnome is working on new mail client called geary. Currently only supports imap accounts.

Description:

              Geary is a new email reader for GNOME designed to let you read your
email quickly and effortlessly. Its interface is based on
conversations, so you can easily read an entire discussion without
having to click from message to message. Geary is still in early
development and has limited features today, but we’re planning to add
drag-and-drop attachments, lightning-fast searching, multiple account
support and much more. Eventually we’d like Geary to have an
extensible plugin architecture so that developers will be able to add
all kinds of nifty features in a modular way.

So, do keep a watch on the client. The looks of the client are very nice and I liked the interface too much. Waiting for them to support more type of accounts and also support configuration of authentication types.

 

fetchmail to get the mails from your imap account

Now, that you have set the RPi to send emails, lets do the next best thing. Setup fetchmail so that we can setup a cron job to run and get us the emails on Raspberry Pi. What can we do with these emails, lots 🙂 (I hope you already have a Raspberry Pi, if not then head over to  element14.)

For now, first install fetchmail:

sudo apt-get install fetchmail

and if you are one of the guys who wants easy configuration then :

sudo apt-get install fetchmailconf

If you are using fetchmailconf, then just fire up “fetchmailconf”. You will get a GUI, where you can configure the setting. If not, then you can create a file “~/.fetchmailrc” which should look something like this:

poll 
protocol IMAP
user "" with password "" mda ""
folder 'INBOX'
fetchlimit 1
# do not delete the mails on server.
keep
# do not re-write the headers for the mail, get saner headers for the script to process.
no rewrite
# use ssl
ssl

 

Enhanced by Zemanta