Scripts to report SMART, ZPool and UPS status, HDD/CPU T°, HDD identification and backup the config

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
Code:
[root@poweredge] /# ls -l /var/tmp
total 48
drwxrwxrwt   6 root  wheel   480 Sep  3 22:14 ./
drwxr-xr-x  29 root  wheel  1160 Aug 15 18:21 ../
drwxr-xr-x   2 root  wheel    40 Aug 21 03:00 .PBI.89686/
-rw-r--r--   1 root  wheel     6 Aug 29 04:15 .repl-result
-rw-rw-r--   1 root  wheel  1277 Sep  3 22:13 alert
-rw-r--r--   1 root  wheel    64 Sep  3 03:05 dmisha.txt
drwx------   2 www   wheel     0 Aug 15 18:21 firmware/
-rw-r--r--   1 root  wheel    33 Aug 15 18:21 freenas_config.md5
-rw-r--r--   1 root  wheel  1666 Aug 15 18:21 ixdiagnose_boot.log
drwxr-xr-x   6 www   www     160 Aug 16 03:00 nginx/
-rw-r--r--   1 root  wheel   939 Aug 20 20:26 pbi-repo.rpo
-rw-r--r--   1 root  wheel   899 Aug 15 18:21 rc.conf.freenas
-rw-------   1 root  wheel   168 Sep  2 20:49 sessionidREDACTED
drwxrwxrwt   2 root  wheel     0 Mar  1  2015 vi.recover/

Thanks for the testing.
Thanks for all the scripts!
Have you checked that the tar can be downloaded from the mail and contains the 2 checksum files and the db file?
Tous bon.
 
Joined
Jan 9, 2015
Messages
430
Code:
[root@poweredge] /# alias ls
ls -GFa

Apparently it's the -F flag.

I didn't create the alias, not sure why it's there.
Yup. I was just looking at the man page. I learn something new everyday . Thanks Robert.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
So there's a permission denied but the file is still deleted... either I'm really tired or there's something really weird going on. You have the error every time you execute the script?

Perfect, I'll put the script in the first post tomorrow ;)
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Can you try to :
  1. comment the line 17 (email sending) and execute the script
  2. comment the lines 16 and 17 (tar creation and email sending) and execute the script
  3. comment the line 20 (sha256 deletion) and execute the script and post the output of a ls -l /var/tmp

What update of FreeNAS are you using?
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
I must apologize. In copying and pasting the script, the line that begins cd "/tmp/" inadvertently got split into two, right before the ./config_backup.sha256 parameter. This led to the error, since that wasn't a valid command. I joined that line back together and now all is well.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, no problem. I prefer that it's a stupid error than a weird mystic error :)
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Thanks! =] Great write up :)

I'm having a minor issue with the config backup script when it comes to the email point. I get an email stating it created the tar, but instead of a tar attachment I get a bunch of gobbledygook in text, which I assume is the output of the tar in text form :confused: lol

Here's the first few lines of the email:
Code:
begin 644 FreeNAS_Config_2015-09-10_19-56-35.tar

M+B]&<F5E3D%37T-O;F9I9U\R,#$U+3`Y+3$P7S$Y+34V+3,U+F1B````````

M````````````````````````````````````````````````````````````

M`````````````#`P,#8T,"``,#`P,#`P(``P,#`P,#`@`#`P,#`Q,C(V,#`P

M(#$R-3<T-#(S,S`S(#`Q-C0S,@`@,```````````````````````````````

M````````````````````````````````````````````````````````````

M``````````````````````````````````````````!U<W1A<@`P,')O;W0`

M````````````````````````````````````=VAE96P`````````````````

M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````

M````````````````````````````````````````````````````````````

M````````````````````````````````````````````````````````````

M````````````````````````````````````````````````````````````

M``````````````````````!344QI=&4@9F]R;6%T(#,`!``!`0!`("````Z3

M```!2P```4H````'```)+`````0```````````````$`````````````````

M````````````````````````````#I,`+>8&!0,N`#T"G@D```$L`_L#]@/Q

M`^P#YP/B`]T#V`/3`TL#OP.Z`[4#L`.K`Z$#G`-^`X@#@P-Y`U8#:@-E`V`#

M6P,R`ST#$`,I`R0#'P,:`Q4#"@,$`OX"^`+L`N`"S@+(`\T"P@-%`U`"O`/'

M`K8#-P+F`K`"J@+:`M0#<P*D`IX"\@.6`Y`"F`*2````````````````````

M````````````````````````````````````````````````````````````

M````````````````````````````````````````````````````````````


EDIT
I just realized I forgot to post a few other details:
  • It does create all files correctly, and no error log is being generated
  • It appears to just be failing to attach the .tar file, and instead, is sending the text output of the .tar file itself, hence the gobbledegook

 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Argh, that's what I feared when I released the script for testing some time ago but as it worked with gmail and another mail client I assumed it was ok for the most used clients.

What mail client do you use?

The problem is that we can't install packages on the system (well, in theory we can but it's a very very bad idea...) so I'm limited to what's already installed by default. There isn't that many solutions to send a file attached to an email in the CLI and there's basically only one I can use here, and it's not a very good one (as you could see), I can't even put text in the body of the email because of this method (in the beginning I wanted to put the checksums directly in the mail and just attach the .db without using tar). The "begin 644" is some sort of magic string to tell the client to interpret the body of the email as an attached file and it seems it's not supported on every mail client.

So, enough technical talking, I'm afraid the only solution is to use a different mail client. What I'm sure for now is that gmail works and the client used by @Robert Trevellyan works too (BTW can you tell us what client do you use Robert?)
 
Last edited:

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
I was using gmail as the email address (albeit I use gmail's alias feature to organize emails from my NAS, i.e. append the + sign to the address, "your.email+Freenas@gmail.com" is still routed to "your.email@gmail.com"), however Outlook 2013 as the client, which appears to be the issue as the attachment shows up fine on gmail.com =]

Thanks for catching that... I would have realized eventually, but it would have taken me days lol
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, thanks for the info ;)

And sorry again for this problem but I can't do much (but I'll put a warning in the first post once I know what is the client used by Robert).
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Oh no, no problem at all. I love the script and using gmail to download the config is just as convenient if it was being downloaded within Outlook. You wrote a great script, no complaints here :)
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ah... well, so, can someone with another client than gmail checks that it works ok? (this time I've put bold, no excuses :P :D)
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
outlook.com/live.com/hotmail.com doesn't work... however this could be due to Microsoft's EAS (Exchange Active Sync) Server. I'll give pop3 a try tomorrow, but since gmail is smtp, I'd bet money other smtp email services should work.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Many thanks for the tests ;)
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
No problem at all :) least I could do :D
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I've modified the temperatures script to be more user friendly ;)

@zoomzoom Have you tested the pop3 protocol?
 

shnurov

Explorer
Joined
Jul 22, 2015
Messages
74
I finally got those to work! Huge thanks for those - they are a life saver.

The CPU/HDD temp output works great, I'm having some errors with the e-mail the SMART report one.

Here's the error I got & then the output it gives me - I have 6 drives. I get the full report for the detailed SMART status, but the grid doesn't fill out ada1 to ada4 - ada6 and ada7 are not in use at the moment, but will be in a few days.

Any ideas?

Code:
[root@freenas] /scripts# ./smart_hdd.sh
awk: can't open file 81
 source line number 1
awk: can't open file 21
 source line number 1
awk: can't open file 81
 source line number 1
awk: can't open file 21
 source line number 1


Code:
########## SMART status report summary for all drives ##########


+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+

|Device|Serial         |Temp|Power|Start|Spin |ReAlloc|Current|Offline |UDMA  |Seek  |High  |Command|Last|

|      |               |    |On   |Stop |Retry|Sectors|Pending|Uncorrec|CRC   |Errors|Fly   |Timeout|Test|

|      |               |    |Hours|Count|Count|       |Sectors|Sectors |Errors|      |Writes|Count  |Age |

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+

|ada0  |W1F4TVXX       | 35 | 9953| 1079|    0|      0|      0|       0|     0|     0|     0|      0| 415|

|ada5  |Z1F4Z3EB       | 34 | 1321|  539|    0|      0|      0|       0|     0|     0|     0|      0|  55|

|ada6  |               |  |     |     |     |       |       |        |      |   N/A|   N/A|    N/A|   0|

|ada7  |               |  |     |     |     |       |       |        |      |   N/A|   N/A|    N/A|   0|

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+




########## SMART status report for ada0 drive (Seagate Barracuda 7200.14: W1F4TVXX) ##########


SMART overall-health self-assessment test result: PASSED...
 
Top