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

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
More cuteness on the forum \0/ we need that :D

More seriously, yep, -x is just awful. There's the -l scttemp if you just want the temp history.
 

Ruff.Hi

Patron
Joined
Apr 21, 2015
Messages
271
Really? I'll review my emails and see if I can see any temp change that is independent of a SMART run.

Checked my email history ... and ... yes the HDD temps do change. I have now added a section to the CPU / HDD temp script that writes that info to a file. At some point in the future, I will dig that file up and graph the results (just because I can).
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Nope, there's a test in the script and I tested it on a non-scrubbed pool (it's even in the example result).

The error says clearly that it can't convert 2015-Mar-30_19:25:25 with the %Y-%b-%e_%H:%M:%S format. Why? I don't know, everything seems right.

Can you post the output of cat -e zpool-report.sh please? (in between code tags or in a pastebin)

EDIT: It looks like one of my pools had a cancelled scrub, which through the $scrubdate for a loop and provided a date of - - which cause the date command to fail. Not sure of a fix, but at least I know why it happened.

For some reason, the date command is failing for me as well.

Code:
[root@freenas1] ~# ./zpool_report.sh
date: illegal option -- -
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
./zpool_report.sh: arithmetic expression: expecting primary: "((1434471904 - ) + 43200) / 86400"
[root@freenas1] ~# date -j -f '%Y-%b-%e_%H:%M:%S'
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
[root@freenas1] ~# 
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I didn't have the time to debug this for now so thanks for the data point ;)

It's not the same error however, but in both cases it seems it's just the date command which is a bit susceptible (but I knew that, it's just a mess).

I'll not add the checks for this because it'll need a too big if() and the error is pretty rare and not dangerous (and I'm very busy too). I can maybe add a check to put a default value to avoid the arithmetic expression error and let the script continue :)
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Could you search for "scrub repaired" as an indicator of a successful scrub?

And could I beg, pay or otherwise cajole you into integrating SAS into the SMART drive reporting script? :)

And since I'm begging, was there a script to create the Cron table?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
And could I beg, pay or otherwise cajole you into integrating SAS into the SMART drive reporting script? :)

I gave him the info several months ago so he could make SAS work. :P

Does it not work?
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
It's not the only thing that can bug the date command I think (sadly), I'll see that when I can ;)

Months? mmh maybe... let me check... a yeah, mid-april, ok... Let's just say I'm busy :P

But yeah, I up the priority for the SAS version of this script in my todo list because it's the last thing I need to do to complete this thread (for now... I always add things after I say everything is complete...) so it would be one thing done :)
 
Joined
Oct 2, 2014
Messages
925
Bidule0hm , i got very board and sat down for a good 45 min figuring out what scripts i wanted...until i realized i want all of them (aside from the SAS ones) lol....thank you for all your hard work, i wish this was reddit because you'd be rolling in the gold :P
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Thanks for your compliment ;)
 
Joined
Oct 2, 2014
Messages
925
Alright, stupid question of the day, are these scripts meant to be run daily,weekly,monthly? Or are they just for "as needed", if they're meant to be run on said day/week/month, where do you tell FreeNAS to run it? I see under start up/shutdown scripts there would be a place...but is there nowhere else?
 

Trapizomba

Dabbler
Joined
Mar 23, 2015
Messages
24
My temperature monitoring scripts runs every five minutes.

I made a simple one (without the e-mail notification) to run every time I logon by SSH...


Enviado do meu iPhone usando Tapatalk
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I run them after the scrubs and the SMART tests (see the Misc section in the first post) but you can run them as often as you want. Init/shutdown scripts are not a good idea, I recommend to use a CRON task to execute them.
 

Ruff.Hi

Patron
Joined
Apr 21, 2015
Messages
271
When I boot into my bios, I get CPU temp. I also get motherboard temp. Is there a script that can provide the motherboard temp?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
You probably can do that by using grep on the output of sysctl -a like I've done for the CPU temps. You first need to print the full output and search by hand what you want and then grep it ;)
 
Joined
Oct 2, 2014
Messages
925
Is there a way to make the scripts run say every week, or is there a script...to call the scripts i want and make it run every week or so? Like make the calling script run at startup and then it reruns itself every week?
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
Create a cron job to schedule the running of the script(s). If you want to run it at startup, use the Init Script (section 6.2 of the docs).

Is there a way to make the scripts run say every week, or is there a script...to call the scripts i want and make it run every week or so? Like make the calling script run at startup and then it reruns itself every week?
 

hugovsky

Guru
Joined
Dec 12, 2011
Messages
567
Don't know if someone noticed but, if using

Code:
drives=`sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) print $i }'`


You get also cdrom and usb drives:

Code:
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|Device|Serial         |Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek  |Total     |High  |Command|
|      |               |    |On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks     |Fly   |Timeout|
|      |               |    |Hours|Count|Count|       |Sectors|Sectors |      |          |Writes|Count  |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|da0   |               |  |     |     |     |       |       |        |   N/A|       N/A|   N/A|    N/A|
|ada0  |WD-WCC4N5PAA9J9| 36 |  577|    9|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada1  |WD-WMC4N0K7SYAC| 36 |  288|    5|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada2  |WD-WCC4N0VDAHZE| 34 |  932|   17|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada3  |WD-WCC4N0VDAPH6| 36 |  928|   11|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada4  |WD-WCC4N5VPU7EJ| 35 | 1266|   22|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada5  |WD-WCC4N0VDAS3T| 33 | 1263|   19|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|


Code:
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|Device|Serial         |Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek  |Total     |High  |Command|
|      |               |    |On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks     |Fly   |Timeout|
|      |               |    |Hours|Count|Count|       |Sectors|Sectors |      |          |Writes|Count  |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|cd0   |[No            |  |     |     |     |       |       |        |   N/A|       N/A|   N/A|    N/A|
|da0   |               |  |     |     |     |       |       |        |   N/A|       N/A|   N/A|    N/A|
|ada0  |WD-WMC1U5671723| 34 |24571| 2296|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada1  |WD-WMC1U5213900| 32 |24517| 2260|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+


Is there a way to only select hardrives?
 
Joined
Oct 2, 2014
Messages
925
Create a cron job to schedule the running of the script(s). If you want to run it at startup, use the Init Script (section 6.2 of the docs).
Annnnd that did it lol.....thanks man! I thought i looked there...must not of looked that hard or that closely lol
 
Top