Ardacer
Cadet
- Joined
- Jun 30, 2015
- Messages
- 8
So my NAS is a xeon 1230, 32Gb ecc, intel sever board, in a case with 11 vents (all controlled) and planned ZFS raidz2 pool of 10x3Tb + 1 Hotspare. For now just 4tb sitting inside. It's meant to be a backup machine (all very important stuff is backed up on one other server too), and storage for movies/music/games/general files. I won't be accessing it all so often, so when I WoL-it, I thinks its a good idea to have it power down itself after some time, as it will eat up 60-80W minimum (measured with Amp clamp) at idle (I think at least).
I found a nice code here : https://forums.freenas.org/index.php?threads/helper-script-for-automatic-shutdown-on-zfs-idle.12885/
But it didn't work. So I took some time and upgraded it, added some explanaitons, removed some stuff (I don't think I broke anything, it works fine, but if you have a Zpool names like "0" or some insane names, it might break the script. It could also be modified to do a lot of other stuff too.)
So basically what it does is it monitors your pools for active scrubs and writes/reads. If none of the above are found, it'll turn itself off. Ta-da. Works on 9.3. On my server. You never know..
One thing I'm confused about though, I see a lot of small writes on my non boot pool, are those logs? In that case I'm not sure this script makes a lot of sense if you don't put your logs elsewhere, as they will constantly write on your pool (you could set the script to look for reads only, but imagine the server shutting down in a middle of something backing up on it.. not good). Also the boot pool has hourly writes or so if you're including that, it makes no sense to have the interval longer then 1 hour or so. Anyway, the code is down there, and it can be modified, so .. hope it's worth something to someone.
Also, hi all, I'm Benedict from Croatia, first post.
I'm actually a physician, ophthalmologist (just started a week ago, finished studies a year ago!).
Also on doctoral studies in the national central nervous system research center.
I also have around 40 PC-s that passed through my hands (currently 10 active I believe, 2 linux servers and one freenas), not including all the smartphones tablets etc, and also I have a small private electronics lab where I build PCB-s and stuff... I also looove music and am an audiophile, and have HD650's, q701's, O2Odac, custom made speakers and amps, and looking forward to get HD800's.
Why am I a MD?
You tell me...
edit: for simplicity's sake, you could just make a lot of if then lines instead of one big if then chain. just remembered.
I found a nice code here : https://forums.freenas.org/index.php?threads/helper-script-for-automatic-shutdown-on-zfs-idle.12885/
But it didn't work. So I took some time and upgraded it, added some explanaitons, removed some stuff (I don't think I broke anything, it works fine, but if you have a Zpool names like "0" or some insane names, it might break the script. It could also be modified to do a lot of other stuff too.)
So basically what it does is it monitors your pools for active scrubs and writes/reads. If none of the above are found, it'll turn itself off. Ta-da. Works on 9.3. On my server. You never know..
One thing I'm confused about though, I see a lot of small writes on my non boot pool, are those logs? In that case I'm not sure this script makes a lot of sense if you don't put your logs elsewhere, as they will constantly write on your pool (you could set the script to look for reads only, but imagine the server shutting down in a middle of something backing up on it.. not good). Also the boot pool has hourly writes or so if you're including that, it makes no sense to have the interval longer then 1 hour or so. Anyway, the code is down there, and it can be modified, so .. hope it's worth something to someone.
Code:
#!/bin/bash #set the time interval in (seconds methinks) which the pools are tested for activity interval=240 #list your ZFS pools pool1=freenas-boot pool2=ZFS noscrubs=0 inactive=0 while [ true ]; do #optionaly replace pool2 with the pool you need to monitor, and copy and modify for other pools if needed, add string2 test2 etc. string1=$( zpool iostat $pool2 $interval 2 | tail +5 ) test1=$( echo "$string1" | egrep -c "0 *0 *0 *0" ) #do a basic if then if then if then ... for as many pools as you need, simmilar to the if then pattern in the scrub section below. if [ $test1 = "1" ]; then inactive=1 else inactive=0 fi #copy and modify the lines in this segment to check all pools for scrubs sctest1=$( echo $(zpool status $pool1 ) | egrep -c "scrub in progress" ) sctest2=$( echo $(zpool status $pool2 ) | egrep -c "scrub in progress" ) #do a basic if then else if then else chain here for all the scrub tests. you're smart, you'll figure it out. if [ $sctest1 = "0" ]; then if [ $sctest2 = "0" ]; then noscrubs=1 else noscrubs=0 fi else noscrubs=0 fi if [ $noscrubs = "1" ]; then if [ $inactive = "1" ]; then shutdown -p now fi fi done
Also, hi all, I'm Benedict from Croatia, first post.
I'm actually a physician, ophthalmologist (just started a week ago, finished studies a year ago!).
Also on doctoral studies in the national central nervous system research center.
I also have around 40 PC-s that passed through my hands (currently 10 active I believe, 2 linux servers and one freenas), not including all the smartphones tablets etc, and also I have a small private electronics lab where I build PCB-s and stuff... I also looove music and am an audiophile, and have HD650's, q701's, O2Odac, custom made speakers and amps, and looking forward to get HD800's.
Why am I a MD?
You tell me...
edit: for simplicity's sake, you could just make a lot of if then lines instead of one big if then chain. just remembered.