Looking for better ideas how how to sleep/suspend my unraid box


Recommended Posts

Can I suggest you put the simple-features "tgz" package in the directory "/boot/extra" and reboot your system!?

 

There is no need to add an installation line in your 'go' file when the file is placed in this directory, unRAID will automatically install it.

 

I suspect something got mixed up....

Link to comment

Can I suggest you put the simple-features "tgz" package in the directory "/boot/extra" and reboot your system!?

 

There is no need to add an installation line in your 'go' file when the file is placed in this directory, unRAID will automatically install it.

 

I suspect something got mixed up....

I moved the package from /boot/packages folder into the /boot/Extra folder plus removed the ultra.cfg file. Additionaly I removed all simple-features related go script entries.

 

Then I rebooted the server but the result is the same as it was before. I think I'm not the only one with that issue looking at the reply #485 from here:http://lime-technology.com/forum/index.php?topic=12698.new;topicseen#new

 

Maybe we continue there as this is the better place to cover?

Link to comment

Can I suggest you put the simple-features "tgz" package in the directory "/boot/extra" and reboot your system!?

 

There is no need to add an installation line in your 'go' file when the file is placed in this directory, unRAID will automatically install it.

 

I suspect something got mixed up....

I moved the package from /boot/packages folder into the /boot/Extra folder plus removed the ultra.cfg file. Additionaly I removed all simple-features related go script entries.

 

Then I rebooted the server but the result is the same as it was before. I think I'm not the only one with that issue looking at the reply #485 from here:http://lime-technology.com/forum/index.php?topic=12698.new;topicseen#new

 

Maybe we continue there as this is the better place to cover?

Hold down shift and hit refresh in the browser a couple of times.

Link to comment
  • 2 weeks later...

The nature of my unRAID server is that it is (for the moment) strictly a media server.  I store photos, videos, movies and music on it that does not always need to be accessed.  I want to put my unRAID box to sleep automatically after the disks spin down and wake it again when it is needed.  I am running v5 beta 14.  The sleep script on the wiki page uses "echo 3> /proc/acpi/sleep" which does not put the server in an s3 sleep state with the latest kernels.  I have Simple Features installed and the "Sleep" button works perfectly.

 

Is there anyway to modify the sleep script to use whatever method Simple Features is using to sleep the server 5 minutes after disk spin down? 

 

This question seems to have been asked before, but, I do not see a definitive answer in this thread.  It is likely this has been answered and I just missed it.  If so, I apologize in advance for the reading comprehension fail.

 

After I get the sleep portion reliably working, I'll tackle the WOL.  Right now, I can successfully wake the server by pressing the blinking power button, by specific keyboard command or a specific time of day.  Eventually, the preferred method is WOL though a magic packet.

 

ethtools eht0 shows that "pumbg" is supported and wake is set to "g" so this indicates the NIC supports WOL, correct?

 

 

Link to comment

If you are looking for a SW to do wake the server you find one here -> http://www.depicus.com/wake-on-lan/wake-on-lan-cmd.aspx

 

//Peter

Thanks, I have downloaded wolcmd and modified it with the MAC address of my NIC and the appropriate IP and subnet mask addresses.  Even though the NIC supports WOL, it appears my BIOS may not; however, my concern at the moment has more to do with automating the server sleep function before I move on to waking it up.

 

Speeding_Ant's Simple Features Sleep button works great, but, I don't know the code behind it to try it in a script.

Link to comment

Can I suggest you put the simple-features "tgz" package in the directory "/boot/extra" and reboot your system!?

 

There is no need to add an installation line in your 'go' file when the file is placed in this directory, unRAID will automatically install it.

 

I suspect something got mixed up....

I moved the package from /boot/packages folder into the /boot/Extra folder plus removed the ultra.cfg file. Additionaly I removed all simple-features related go script entries.

 

Then I rebooted the server but the result is the same as it was before. I think I'm not the only one with that issue looking at the reply #485 from here:http://lime-technology.com/forum/index.php?topic=12698.new;topicseen#new

 

Maybe we continue there as this is the better place to cover?

 

Just posting to say I have the exact same issue... Although the sleep setting are being applied to my go script, it always defaults to disabled in the GUI, after hitting "Apply" or returning to the sleep menu.

Link to comment

I am running v5 beta 14.  The sleep script on the wiki page uses "echo 3> /proc/acpi/sleep" which does not put the server in an s3 sleep state with the latest kernels.  I have Simple Features installed and the "Sleep" button works perfectly.

 

On 5.0b14 use "echo -n mem >/sys/power/state" to sleep the server.

 

ethtools eht0 shows that "pumbg" is supported and wake is set to "g" so this indicates the NIC supports WOL, correct?

Yes.

 

 

 

Link to comment

Here is my s3.sh script, I'm using this on 5.0b14.  I modified the original with info from the SimpleFeatures Sleep.php file.

 

#!/bin/bash

drives="/dev/sdb /dev/sdc /dev/sdd /dev/sde"

timeout=5

count=5

while [ 1 ]

do

  hdparm -C $drives | grep -q active

  if [ $? -eq 1 ]

  then

    count=$[$count-1]

  else

    count=$timeout

  fi

  if [ $count -le 0 ]

  then

    # Do pre-sleep activities

    echo 'Inactive - Going to Sleep' | logger

    ethtool -s eth0 wol g

    sleep 5

    # Go to sleep

    echo 'Stopping Services' | logger

    /etc/rc.d/rc.samba stop

    /etc/rc.d/rc.nfsd stop

    /etc/rc.d/rc.atalk stop

    /etc/rc.d/rc.avahidaemon stop

    /etc/rc.d/rc.avahidnsconfd stop

    echo 'Syncing Filesystems' | logger

    /bin/sync

    /bin/config/beep-down

    echo 'Sleeping' | logger

    echo -n mem >/sys/power/state

    # Do post-sleep activities

    # ethtool -s eth0 speed 1000

    echo 'Wake Up' | logger

    /boot/config/been-up

    echo 'Starting Services' | logger

    /etc/rc.d/rc.samba start

    /etc/rc.d/rc.nfsd start

    /etc/rc.d/rc.atalk start

    /etc/rc.d/rc.avahidaemon start

    /etc/rc.d/rc.avahidnsconfd start

    ethtool -s eth0 wol g

    sleep 5

    count=$timeout

  fi

  # Wait a minute

  echo COUNT $count

  sleep 60

done

Link to comment
  • 3 weeks later...

Can anyone tell me what values noTCP is looking for in the following s3.sh file? I've tried values of 0, 1 and 100. No matter what I put there unRAID will never sleep if checkTCP is set to yes.

 

#!/bin/bash
# constants
yes="yes"
no="no"


# [CONFIGURATION]

# before going to sleep
intrnlTimeoutTicks=1	# ticks after HDD spindown before checking for external activity
extrnlTimeoutTicks=5	# 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="" #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=$yes		# check for TCP activity

pingIPs="192.168.0.4" # 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='100.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
}


# 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

Link to comment

Can anyone tell me what values noTCP is looking for in the following s3.sh file? I've tried values of 0, 1 and 100. No matter what I put there unRAID will never sleep if checkTCP is set to yes.

Value should be set to "0.00" and it represents no traffic (=0 bytes) being received anymore on the ethernet interface.

 

If you machine doesn't go into sleep state, there problably is something running in the background creating transmission traffic.

 

Link to comment

Ahh I thought that value was like a threshold amount. Something in the vein of anything less than this amount counts as no traffic.

No it is an absolute value, though the value is measured over the last x minutes (script uses 5 minutes). You can change the monitoring period, i.e. make it shorter though chances are then higher that a short silence may cause an unwanted sleep state.

Link to comment

So if that value is set to 10, would it need exactly 10 bytes of traffic over the last 5 minutes cause it to sleep? Sorry if this is a stupid question. I'm just trying to understand it better.

 

What is the Linux command to check what amount of bytes are currently being transmitted? I'd like to be able to turn different plugins off and check to see which may be transmitting data and how much.

Link to comment

So if that value is set to 10, would it need exactly 10 bytes of traffic over the last 5 minutes cause it to sleep? Sorry if this is a stupid question. I'm just trying to understand it better.

 

What is the Linux command to check what amount of bytes are currently being transmitted? I'd like to be able to turn different plugins off and check to see which may be transmitting data and how much.

Yes the number represents the number of bytes counted over the given period.

 

You should have installed the "bwm-ng" package, this is also used by the sleep script to monitor the TCP activity.

 

Type: bwm-ng on the command prompt to see real-time measurements.

Link to comment
...

You should have installed the "bwm-ng" package, this is also used by the sleep script to monitor the TCP activity.

 

Type: bwm-ng on the command prompt to see real-time measurements.

Ahh that might be the trick. I do not seem to have that installed. I'll have to go looking for that and how to install it.
Link to comment
  • 2 months later...

Well I finally got around to installing the bwm-ng package.

 

I have set my sleep script to a value of:

noTCP='500.00'			# what constitutes absence of TCP activity

Based on our earlier conversation, I take it this means 500.00 KB over x minutes, which I have set to 2:

	extrnlTimeoutTicks=2	# ticks of no external activity before sleep; only after spindown+internal countdown

 

So the drives spindown. Then over the next 2 minutes if it does not receive 500.00 KBs of traffic total the system should then enter sleep. Correct?

 

Right now it is not going to sleep. Maybe 500.00 is too low a value. While running bwm-ng I can see a trickle of constant activity (I have no clue what it is). Maybe over those 2 minutes that trickle adds up to more than 500.00.

Link to comment

Well, now I've tried it with a value of 2048000.00, figuring it is bytes and not KB. Yet that didn't work either. I'd really like to get this to work. Currently if I am playing a 30 minute show, enough of it gets cached in RAM, that the disks spin down and unRAID goes to sleep during the playback. If I can successfully get the network check working I can alleviate this issue.

Link to comment

You really should leave that value to "0.00". Changing it to "some" value means the monitor needs to see *exactly* that amount of bytes in the measured period to stop. This is very unlikely to happen.

 

The intend is to observe no tcp activity, the value 0 means nothing has been exchanged in that period.

 

Btw there is an updated version of the sleep package, it now also contains the bwm-ng program. See "SimpleFeatures".

 

Link to comment

If something in the background causes continues traffic exchange then there will be never a silence (no activity) period, and hence your system won't go to sleep.

 

In that case don't use the TCP inactivity condition or find out what is causing this continuous traffic and change its behaviour.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.