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

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I wrote a short script to email me this information each night ...

kern.ostype: FreeBSD
kern.osrelease: 11.1-STABLE
kern.osrevision: 199506
kern.version: FreeBSD 11.1-STABLE #2 r321665+366f54a78b2(freenas/11.1-stable): Wed Mar 21 23:04:13 UTC 2018

This info is pulled from sysctl -a by various grep commands. I would like to add the latest update version (U4) but I can't seem to find that in the sysctl dump. Is this information available somewhere?
I wonder why you did that?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Please keep this thread (it's already long enough like that...) for discussions on the scripts in the OP, make a new thread if you have questions about your own scripts, thanks ;)
 

rangopango

Contributor
Joined
Feb 21, 2018
Messages
151
I've never used *BSD, how do I get access to the home directory? "cd /home" doesn't work because there is no such directory
d314e49757.jpg


should I just create "home" in the root (not in the directory that's called root", but in "/")?
 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
That's a new one... I never had that and I can't find an answer with a fast search. I'd wait for an answer from someone who know better (let's ping some members who can have the answer :) @jgreco @Ericloewe @DrKK @joeschmuck @Jailer @...)
 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Yes, but here there isn't the /home directory to begin with.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Yes, but here there isn't the /home directory to begin with.
Why would there be? FreeNAS doesn't use /home. Root's home directory is in /root/, as in most *nix systems. Any other user's home directory will be wherever you choose to put it under /mnt/somepool/.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
So I'd have to go to /root/ and create a directory for the scripts?

782ba0eab6.jpg
I created a directory under /root called /scripts but you can put it anywhere on the system that you like. Just understand that you need to give the path to the script when you run it from cron. I maintain a copy of all the scripts in my /scripts folder in another folder on my pool. the /root/scripts folder is on the boot media.

The default "home" directory is /usr for other users besides root, but you don't need to use that at all.
 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Why would there be? FreeNAS doesn't use /home. Root's home directory is in /root/, as in most *nix systems. Any other user's home directory will be wherever you choose to put it under /mnt/somepool/.

Ah ok.

Back in the day I put my scripts in /root/scripts/ so didn't saw /home/ wasn't here.

So I'd have to go to /root/ and create a directory for the scripts?

782ba0eab6.jpg

Yes, that's what I'd done in the past but then I changed my mind to put them in a dataset 'scripts' in my pool (mainly to have the snapshots advantages) so now they are in /mnt/my_pool/scripts/ ;)
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
So I'd have to go to /root/ and create a directory for the scripts?

782ba0eab6.jpg
I locate all my scripts under "/mnt/pool/scripts" and now it's in a safe place, not that other places are not safe. I don't personally like embedding my custom files any deeper than I need to. When you create the directory as a user (I use root) from the shell then it does not show up as a dataset in the FreeNAS GUI and I really like it this way.
 
Last edited:

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
I'm not sure if this would be recommended, and if it's not, would someone please explain why
  • Couldn't the scripts' directory simply be added to PATH, at which point one could simply invoke <script-name>.sh
 
Last edited:

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Couldn't the scripts' directory simply be added to PATH
I suppose it depends on, where would you edit the path?
Most of the files that might be edited by hand in a regular BSD installation to make a configuration change are recreated during the boot of the FreeNAS appliance based on the settings that are in the config.db which means, any setting change you want to survive a reboot would need to be done in the GUI so that it is added to the config.db
 
Joined
Jan 4, 2014
Messages
1,644
@melp Woohoo! New version of your awesome script released at https://github.com/edgarsuit/FreeNAS-Report. I've been looking forward to the official script fix for issues that surfaced after the upgrade to 11.1. Love the addition of the scrub duration column. I'm getting a weird display issue with the ZPool Status Report Summary though. The upper right corner appears to be lopped off. Check out the image below. Anyone else seeing this?
screenshot.89.jpg
 
Last edited:

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
Since @melp / edgarsuit updated the script, and I unfortunately had some (too much) time in front of my FreeNAS box due to an annoying disk issue I spent some of that time merging my old hacks with the new 1.3 version and added a little extra and put it here https://github.com/fohlsso2/FreeNAS-Report ,

Most of the changes is to make the script better parse all different variants of scan status, and give some info if a scrub or resilver is in progress.
(usual disclaimer here, it works on my box :) )
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
I suppose it depends on, where would you edit the path? Most of the files that might be edited by hand... are recreated during the boot of the FreeNAS appliance based on the settings that are in the config.db which means, any setting change you want to survive a reboot would need to be done in the GUI so that it is added to the config.db
~/.cshrc will always survive a reboot and will only be changed upon a update to FreeNAS (it's moved to ~/.cshrc~), at which point one would simple need to: rm ~/.cshrc && cp ~/.cshrc~ ~/.cshrc
  • Using the user specified ~/.cshrc, path would be set via the option: set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin)
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
You missed the point
~/.cshrc will always survive a reboot and will only be changed upon a update to FreeNAS (it's moved to ~/.cshrc~), at which point one would simple need to: rm ~/.cshrc && cp ~/.cshrc~ ~/.cshrc
  • Using the user specified ~/.cshrc, path would be set via the option: set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin)

Sent from my SAMSUNG-SGH-I537 using Tapatalk
 
Top