April 9, 201214 yr Within the last month or so my unRaid box has decided to start sleeping while I am accessing files from the cache drive. Below is my sleep script: #!/bin/bash # constants yes="yes" no="no" # [CONFIGURATION] # before going to sleep intrnlTimeoutTicks=5 # ticks after HDD spindown before checking for external activity extrnlTimeoutTicks=2 # ticks of no external activity before sleep; only after spindown+internal countdown # control of internal timeout checkHDDs=$yes # check if all HDDs are parked before counting down towards sleep noCountdownHours="03" #07 08 17 18 19 20 21" # only countdown towards sleep outside these hours # example: <noCountdownHours="07 08 19 20"> # always countdown: <noCountdownHours=""> # control of external timeout checkTCP=$no # check for TCP activity pingIPs="" # do not sleep if <$pingsIPs> are pingable # example: <pingIPs="192.168.1.4 192.168.1.5"> # no ping-check: <pingIPs=""> # after waking up from sleep doDhcpRenewal=$no # <$no> for servers w/static IP address forceGb=$no # might not be needed; probably always safe # [/CONFIGURATION] # implementation stuff ticklengthSecs=60 # probe hardware + count down every minute/60secs, aka a tick noTCP='0.00' # what constitutes absence of TCP activity flash=/dev/`ls -l /dev/disk/by-label| grep UNRAID | cut -d"/" -f3 | cut -c 1-3` # automatic id of flash drive check_hour() { echo $(date +%H) } check_HDD_activity() { if [ $checkHDDs = $yes ] then # probe the flash drive at your peril HDDs=$((for d in $(ls /dev/[hs]d? | grep -v "$flash"); do hdparm -C $d | grep active ; done) | wc -l) else HDDs=0 fi echo $HDDs } check_TCP_activity() { if [ "$checkTCP" = $yes ] then TCP=$(bwm-ng -o csv -c 1 -d 0 -T avg | grep eth0 | cut -d";" -f5) else TCP="$noTCP" fi echo "$TCP" } check_IP_status() { mp_online=$no # initialize to "no" until we learn otherwise # ping each of the media servers to determine if online for i in "$pingIPs" do # ping the media server; if it answers, it is online out=`ping -q -c 1 $i 2>/dev/null` rec_count=`echo "$out" | grep received | cut -d " " -f4` if [ "$rec_count" -eq 1 ] then mp_online=$yes # if one is online, we do not need to ping # any others, break out of the "for" loop. break; fi done echo $mp_online } pre_sleep_activity() { #/usr/local/sbin/mover #echo $(date) Mover Complete sleep 5 /bin/sync echo $(date) Sync Complete } post_sleep_activity() { #cp /var/log/pm-suspend.log /boot/suspendlogs/post_pm-suspend.log_`date +"%d_%m__%H_%M_%S"`.log # Force NIC to use gigabit networking if [ "$forceGb" = $yes ] then ethtool -s eth0 speed 1000 #ethtool -s eth0 autoneg on fi logger -i -tsleepscript -plocal0.info "Waking up from SLEEP" # Force a DHCP renewal (shouldn't be used for static-ip boxes) if [ "$doDhcpRenewal" = $yes ] then /sbin/dhcpcd -n fi echo DONE echo $(date) unRAID Server Online #Restart sickbeard sleep 60 echo Restarting SickBeard wget -q --delete-after http://192.168.0.100:8181/api/5399668685ed01a995082a97fd2b9eef/?cmd=sb.restart sleep 5 } # main echo $(date) Starting S3 script intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks while [ 1 ] do # do not countdown during certain hours hour=`check_hour` hourMatch=$(echo "$noCountdownHours" | grep "$hour" | wc -l) if [ $hourMatch -eq 0 ] then # count number of HDDs that are not parked HDDact=`check_HDD_activity` if [ "$HDDact" -eq 0 ] then # tick-tock for time since last spindown if [ $intrnlCountdown -gt 0 ] then intrnlCountdown=$[$intrnlCountdown-1] fi else # reset countdown, following HDD activity intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks fi if [ $intrnlCountdown -le 0 ] then # check for persistent external activity TCPact=`check_TCP_activity` IPping=`check_IP_status` if [ "$TCPact" = $noTCP -a "$IPping" = $no ] then if [ $extrnlCountdown -le 0 ] then # Do pre-sleep activities #sync pre_sleep_activity sleep 5 # Go to sleep echo $(date) Going to sleep NOW! echo $(date) unRAID Server Offline #sleep 5 #echo -n 3 > /proc/acpi/sleep echo -n mem >/sys/power/state # #new sleep command, take care of KB and monitor #/boot/custom/bin/s2ram -f -p -m # or -s # #Ytterligare ett annat commando # #For kernel 2.6 and newer #echo -n mem > /sys/power/state #PM-SUSPEND #pm-suspend # Do post-sleep activities post_sleep_activity sleep 5 intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks else # tick-tock for persistent external activity if [ $extrnlCountdown -gt 0 ] then extrnlCountdown=$[$extrnlCountdown-1] fi fi else # reset countdown, following external activity extrnlCountdown=$extrnlTimeoutTicks fi fi fi # Wait a tick sleep $ticklengthSecs done In the unRaid gui my drives are listed as: Parity: sda Disk 1: sde Disk 2: sdc Cache: sdd What should I look for in the log to give me a clue what is going on?
April 12, 201214 yr Author This happened again last night. Anyone have an idea what I can do? I thought the above sleep script is checking all drives for activity including the cache drive.
April 12, 201214 yr I also like to know how to keep my HP N40L with v5b14 to go from going to sleep. The drives spin down which is fine, but when the last time the box went into sleep mode, I had to kill the processes for sleep & chachdirs and manually shut down the server.
April 12, 201214 yr Author I'm not sure I follow your post. I actually want mine to go to sleep, just not when I am accessing one of the drives.
April 12, 201214 yr OK, we maybe on a different wave length then, I would like my drives to spin down but when the server goes to sleep using Media Browser as the front end it will not wake it up. So if you want your server to go to sleep then I am sorry I posted in the wrong thread. What would be the advantage to have your server go to sleep?
April 12, 201214 yr Author To save on power. There are at least 10-12 hours of the day or more where the server is not accessed. I don't need it running all the time. But when I am actually accessing it, I do not want it to go to sleep. unRAID by default should not go to sleep. You must have added a sleep script for that to happen. If you do not want yours going to sleep remove the sleep script. The HP N40L doesn't go to "sleep" anyhow under unRaid. It only supports sleep under Windows.
April 15, 201214 yr Did not enter a sleep script and when I did a manual shutdown starting with umount command the fuser showed that sleep process was not letting me stop the disc. This has happened a few times but have no idea why. I am not bothered by getting the server into sleep mode because when I am done I power them down and power them up when I plan to do some watching. Hope you get your issue solved.
April 15, 201214 yr What should I look for in the log to give me a clue what is going on? Probably all the information needed in reading the cache drive was in the linux disk buffer cache in memory, so it was not being physically accessed at all. With no physical access, it can go to sleep.
April 15, 201214 yr Author What should I look for in the log to give me a clue what is going on? Probably all the information needed in reading the cache drive was in the linux disk buffer cache in memory, so it was not being physically accessed at all. With no physical access, it can go to sleep. With 4GB of RAM, I was wondering if that was the case. Is there someway I can check it?
April 17, 201214 yr You could create a script that runs every minute with the following and output it to a file on your flash drive: for d in $(ls /dev/[hs]d? | grep -v "$flash"); do hdparm -C $d | grep active ; done) | wc -l I can't confirm this will work as I don't have access to my unRAID computer from work, but it's taken from your sleep script and appears to be the line checking to see if the drive is spun up or not. Then if it happens again, you'll know whether or not the drive was truly spun up. *EDIT* a better idea would probably to run the script from a ssh session (that doesn't automatically close its window if the connection is terminated).
April 17, 201214 yr Running the following from an ssh session works: flash=/dev/`ls -l /dev/disk/by-label| grep UNRAID | cut -d"/" -f3 | cut -c 1-3` # automatic id of flash drive while 1>2 do ((for d in $(ls /dev/[hs]d? | grep -v "$flash"); do hdparm -C $d | grep active ; done) | wc -l) sleep 60 done It'll run until you stop it or the server sleeps, checking the mount status of your drives every 60 seconds.
April 17, 201214 yr Author Wonderful. Thank you. I'll try it out tonight. I usually just use telnet to check on things. I'll look up how to do ssh later as well.
April 17, 201214 yr As long as when telnet terminates you can still see your terminal session (Windows will ususally drop you back at a command prompt without being able to see what happened), you should be fine. If you are using Windows, you can still use the telnet protocol, but use a client like Putty (it's free and available here): http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Putty's default behaviour is to leave the window open if the connection is remotely closed.
April 17, 201214 yr Author Thanks for the link. I had putty once a while back, but since had changed to a newer PC and did not get putty again. How do I send all those commands thru in a putty/telnet session? Just enter them one line at a time? Or make a script and execute it from the telent prompt?
April 17, 201214 yr Once you've logged in via putty/telnet just paste them, all at once should be fine, and hit enter.
April 17, 201214 yr Author hmmm. When I do that, I just see it respond with a 1, then a minute later another 1 and then a 2 and then a 3 then another 3. Is that what I should see in the output? I guess that is correct. It appears to be telling me how many drives are still spinning at the moment it checks.
Archived
This topic is now archived and is closed to further replies.