Frank's Random Wanderings

FreeNAS Weekly Status Email

Older versions of FreeNAS would email periodic status reports, however the newer 9.x versions no longer do this. FreeNAS now only sends emails when something strange or bad happens. It makes sense – lots of “everything’s fine” emails tends to numb you and you end up deleting every email from the FreeNAS system, including potentially the interesting ones.

Nonetheless, a weekly email can be nice. Specifically I’d like a weekly email containing the SMART information for the harddisks, so I can see their temperatures, whether any are starting to reallocate sectors (which is an early failure warning), etc. A weekly email with that kind of information would be pretty useful.

This thread on the FreeNAS forums provides a lot of information how to do it, and it’s pretty simple to setup. But some of the information in there is a bit outdated, plus they suggest placing your script in a location that gets overwritten when you update FreeNAS. So here we’ll do things a little more simply. Here’s my script:

You can see the script is calling smartctl twice, once for each of the two disks in the system. The script also calls “zpool status” and “zpool get all” to obtain the health and status of the specified data pool. “/var/cover” is simply a temporary file used to store all the data – at the end of the script it’s passed to sendmail to email everything out.

To use the script you only need change two things: your email address, and the name of your storage pool. Beyond that you can of course edit it to your heart’s delight.

Save your script in your storage pool, ie in your shared folder. The full directory path will probably start with /mnt. For example:
/mnt/share/something/somethingelse/emailstatusreport.sh
There are a couple of advantages to this. One is your zpool doesn’t get overwritten when you update FreeNAS so it’s as easy as always to do updates and you won’t lose your script. The other is by putting it in your zpool your script is naturally backed-up as part of your backups (you do do backups right??).

Then setup a cron job (easy to do through the FreeNAS user interface) and specify something like this to call your script (remember to select the cron user as ‘root’):

That’s it! Enjoy your status emails.

6 thoughts on “FreeNAS Weekly Status Email

  1. frank Post author

    That’s strange – I have no idea. I don’t see anything like that. Is it a language setting – is your system set to English or some other language?

  2. Varun

    I am receiving garbage characters in my email. However, if I cat the file in system, then it is shown properly. Can you help me in this regard ?

  3. frank Post author

    If you received the status email then obviously your script is now working. Chances are the “not found” email you’re concerned about was generated when you were still setting things up and not everything was working yet. I would wait and see if it happens again.

  4. Hengky

    Hi Frank,
    I’ve tried the script, it works. But, i received 2 email, the one as expected. The other one contain like this:

    Subject:
    Cron PATH=”/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin” /bin/sh /mnt/backupstore1/IT/emailstatusreport.sh > /dev/null

    Body message:
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found
    /mnt/backupstore1/IT/emailstatusreport.sh:
    : not found

    For your info, I put the script on /mnt/backupstore1/IT/emailstatusreport.sh
    Do you have any idea what’s wrong? Thanks.

  5. frank Post author

    I suggest you try the script – it does give that information at the end. You’ll see disk total capacity, used, free, among other things.

  6. Hengky

    Hi Frank, thanks for the guide.
    Anyway, could you guide me how to create a report that look like daily email from freenas version 8.2 where include disk status (I mean size, used, avail capacity).

    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *