Hello,
some time ago i found this Script (Sorry, don't know anymore who made it) for turning off FreeNAS if all PCs in this IP Range are offline.
Now i thought about modding this Script, so that it won't turn off Freenas, but put the Harddrives into sleep. This way you can set fixed times when the Harddrives are supposed to sleep. In my Case that would be at night and though the Working Day. Also they won't sleep if there's a PC running and are back to use in Seconds.
Using the normal x-min to sleep timer won't work in my case, cause I'm using an Fan Script that uses smartctl all 3 minutes, which resets the sleep timer. Also it will go to sleep to many times.
I'm quite new to this Stuff, so I wanted to ask wether there's a way to call all Harddrives?
The Point in this Script would be "echo "Kein PC online - Shutdown" ; shutdown -p now ;;". If i now replace "shutdown -p now" with "camcontrol standby /dev/adaX" it should work the same way, but put the Disk into Standby.
But this way you can only put 1 Harddrive into Standby. Something like /dev/ada[0-7] won't work, but is there some command like this to call all harddrives at once?
Would be great if someone could help me here.
some time ago i found this Script (Sorry, don't know anymore who made it) for turning off FreeNAS if all PCs in this IP Range are offline.
Code:
#!/bin/bash
HOST1=192.168.2.33 #IP des ersten PC
HOST2=192.168.2.35 #IP des zweiten PC
ip_range=192.168.2. #Netzadresse des eigenen Netzwerkes ohne den Hostanteil
ip=40 #checke Netz ab IP-Adresse 40
_exit () {
case $1 in
1) echo "Kein Shutdown - Mindestens einer der PCs ist eingeschaltet" ;;
2) echo "Kein PC online - Shutdown" ; shutdown -p now ;;
esac
exit $1;
}
# Checken ob PC's an sind
if [ `ping -c 1 -i 1 $HOST1 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST2 | grep -wc 100.0%` -eq 0 ] ;
then _exit 1; # abbrechen, ein PC läuft
# Wenn kein PC an ist, gehe zu Checken ob PC's im IP-Bereich an sind
else
# Checken ob PC's im IP-Bereich an sind
while [ $ip -le 45 ] #checke Netz bis Hostanteil 45
do
ping -c 1 -i 1 $ip_range$ip #ping mit der zusammengesetzten IP-Adresse aus den o.a. Variablen "ip" und "i"
if [ `ping -c 1 -i 1 $ip_range$ip | grep -wc 100.0%` -eq 0 ] #sobald einer der Hosts auf den ping antwortet, nicht herunterfahren
then _exit 1 #beenden mit exit 1 (kein shutdown)
fi
ip=$(( $ip+1 )) #erhöhe Hostanteil immer um 1
done
_exit 2 # hat kein PC geantwortet, shutdown
fi
Now i thought about modding this Script, so that it won't turn off Freenas, but put the Harddrives into sleep. This way you can set fixed times when the Harddrives are supposed to sleep. In my Case that would be at night and though the Working Day. Also they won't sleep if there's a PC running and are back to use in Seconds.
Using the normal x-min to sleep timer won't work in my case, cause I'm using an Fan Script that uses smartctl all 3 minutes, which resets the sleep timer. Also it will go to sleep to many times.
I'm quite new to this Stuff, so I wanted to ask wether there's a way to call all Harddrives?
The Point in this Script would be "echo "Kein PC online - Shutdown" ; shutdown -p now ;;". If i now replace "shutdown -p now" with "camcontrol standby /dev/adaX" it should work the same way, but put the Disk into Standby.
But this way you can only put 1 Harddrive into Standby. Something like /dev/ada[0-7] won't work, but is there some command like this to call all harddrives at once?
Would be great if someone could help me here.