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

Dice

Wizard
Joined
Dec 11, 2015
Messages
1,410
Latest available version as of today.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, this means that in 9.10 the location of the config file has probably changed. If you can find where it is (I'm still on 9.3) then I can do a 9.10 version of the script.
 

Dice

Wizard
Joined
Dec 11, 2015
Messages
1,410
I can, if provided with instructions on how to proceed.
/noobsauce
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
One solution is to search for all files ending with ".db" with the command find. Something like this: find / -name "*.db" but it'll take a long time and I don't know if the file still ends with ".db".

Another solution would be to read the GUI sources to see which file it goes to when you click on save config.
 

Dice

Wizard
Joined
Dec 11, 2015
Messages
1,410
Here's some output for you :)
Code:
[root@] /# find / -name "*.db"
/data/freenas-v1.db
/data/factory-v1.db
/usr/share/misc/termcap.db
/usr/share/misc/vgrindefs.db
/usr/share/i18n/esdb/esdb.dir.db
/usr/share/i18n/esdb/esdb.alias.db
/usr/share/i18n/csmapper/mapper.dir.db
/usr/local/share/collectd/types.db
/usr/local/lib/gcc48/gcj-4.8.5-14/classmap.db
/usr/local/lib/python2.7/test/185test.db
/conf/base/etc/spwd.db
/conf/base/etc/local/sasldb2.db
/conf/base/etc/pwd.db
/conf/base/etc/login.conf.db
/etc/pwd.db
/etc/spwd.db
/etc/login.conf.db
/etc/local/sasldb2.db
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
So it's still here, same as before. Well, I guess it's how the file is checked that changed then. I'll see ASAP to remove the check for the 9.10 version for now ;)
 

Dice

Wizard
Joined
Dec 11, 2015
Messages
1,410
I figured it out!
- It worked from commandline, generating the proper output. But not from running it as a cronjob while attempting to executing it as normal user, not as root.
Works just fine :)
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ah, yes, almost all the scripts needs to be runned as root to work correctly ;)
 

royalty

Cadet
Joined
Jun 22, 2016
Messages
2
Hello Bidule0hm,

first of all thank you for your script. Since I'm a beginner with the script thing I have trouble to get this work.

I have freenas v 9.10 stable release. the script fails with an orror at line 37 telling me "Syntax error: word unexpected"

the exact email I get gives me this:
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: : not found
/mnt/RED3x4/scripts/zpool_report.sh: 37: Syntax error: word unexpected

do you have a hint for me on whats wrong?

I tried to provide the pool names directly or via alternate solution you mentioned.
and the results are the same when I run the script directly via console or per cron.

thanks and best regards
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Can you post the output of cat -e your_script.sh between code tags please?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
The $ is added by the -e flag on cat and the ^M is typical off the \r that's added by some editors on Windows and OSX (and UNIX systems uses only \n for newline).

Well, problem solved ;)
 

lazybones

Dabbler
Joined
Jan 16, 2016
Messages
45
Hey there, thank you for these awesome scripts.

However when I today had reinstalled freenas and inserted the smart report script I get this output. Anything i am doing wrong?

http://pastebin.com/Xy0Rz8YB

OK so i managed to get it working but here is the output of the mail, very worrying if you ask me:
|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 |

Please say you have an answer on why this is happeniong, I am running the script as root in ssh when testing it.
 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Looks like a very bad copy-paste.

Can you post the output of cat -e your_script.sh in between code tags or on pastebin please?
 

Johannez

Explorer
Joined
Jan 25, 2016
Messages
59
Bidule0hm if i use your Zpool report script as a cron job the script stops working when there is a cancelled scrub.
Today i cancelled a scrub and wanted to verify by email the scrub cancelled but the script would not complete and send me the email.

When i manually started the scrub again the script did complete and gave the scrub in progress status.

I tried making another cron job but this did not help.

I just tried this a couple of times by starting and cancelling the scrub but each time i get the same results.
Is there a way to fix this and still receive the email with the scrub results?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
It's possible, I never tested the script on a cancelled nor on a in progress scrub. It's not the cron job or whatever, it's the parser in the script.

Can you post the outputs of zpool list -H -o health your_pool and zpool status your_pool between code tags please for the cases who pose problem?
 

Johannez

Explorer
Joined
Jan 25, 2016
Messages
59
Code:
[root@freenas ~]# zpool list -H -o health Volume3x1TB                                                                               
ONLINE                                                                                                                             
[root@freenas ~]# zpool status Volume3x1TB                                                                                         
  pool: Volume3x1TB                                                                                                                 
state: ONLINE                                                                                                                     
  scan: scrub canceled on Mon Aug 15 09:14:10 2016                                                                                 
config:                                                                                                                             
                                                                                                                                   
        NAME                                            STATE     READ WRITE CKSUM                                                 
        Volume3x1TB                                     ONLINE       0     0     0                                                 
          raidz1-0                                      ONLINE       0     0     0                                                 
            gptid/d5e4defa-58c3-11e5-ab41-d05099785801  ONLINE       0     0     0                                                 
            gptid/62a232fb-58c7-11e5-ab41-d05099785801  ONLINE       0     0     0                                                 
            gptid/5c1a7412-58ca-11e5-ab41-d05099785801  ONLINE       0     0     0     

*note: the naming of the pool is wrong (still need to fix this), i changed the drives in the volume but i guess that does not matter, just a FYI.

Today i gotten a email when the cron job started on the given time, i did not gotten a email when i did "run now".
However the email has an error:
Code:
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]
/root/scripts/zpool.sh: arithmetic expression: expecting primary: "((1471267020 - ) + 43200) / 86400"


Hope this helps.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, I see, he can't extract the number so it breaks the syntax, pretty much what I was thinking was wrong. I'll fix that asap, thanks ;)
 

nojohnny101

Wizard
Joined
Dec 3, 2015
Messages
1,477
love the scripts and I have started to implement them (thanks for your work!).

I am having a slight problem with the CPU and HDD ones. I am getting CPU temps correctly but not HDD. I have confirmed in the GUI that my drives have names ada0, ada1, ada2, ada3

but the scripts comes back with nothing for the temps. I made sure I was using the SATA version as the drives are connected directly to the motherboard (see in sig, backup machine).

here is your script I'm running:
temps%20script.png


here is the output without HDD temps:
no%20HDD%20temps.png


any ideas?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Thanks ;)

Ok, something is definitely wrong, can you post the output of smartctl -i /dev/ada0 and smartctl -A /dev/ada0 please?
 
Top