Jump to content

Autosleep-Script


  • Please log in to reply
164 replies to this topic

#141
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
Its the remote one which sleeps, not the one i'm watching on. In other words: i have hack "homeserver" where my media is located. This hack use kws to autosleep. If other pc mac access the server to use the itunes share o run direct an avi from hd share it should stay on but it sleeps. If i make a timemachine backup on that hd share it works perfect.. After backup is done the server sleeps..

So if you just read from the server = serve goes into sleep
If you write to the server = server awake

Maybe now its clearer

Salu2

#142
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
kwsleep and RIP are monitoring in- and outgoing traffic (on LAN- and Firewire-Ports, not USB). You can try to open /Library/Scripts/KWS/Sleep.sh with a text editor and change

CPUload=30 # Treshold in % for CPU-Load (here 30 = 30% !!)
NetVal=50000 # Treshold for Network-Traffic in Byte/s

to - maybe -

CPUload=30 # Treshold in % for CPU-Load (here 30 = 30% !!)
NetVal=20000 # Treshold for Network-Traffic in Byte/s

so that the treshold for stopping sleep is lower ...

Regards
KWS

#143
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
I must apologize - KWSleep + KWSleepLion are monitoring only incoming traffic ... :wallbash: ... thanks to OsXsO for the note.
I updated KWSleep and KWSleepLion in first post ... run the full install to detect your network ...
Regards
KWS

#144
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
hey KWS

thx for the update....... but sorry to say that my machine 10.6.8 isn't sleeping with the updated sleep.sh.
i tried going up to 90000 but no effect...

replacing with old sleep.sh working as before

any suggestions??


edit: tried disable the wake op on lan access in system settings, energy saver ... without success

edit2: tried on my 10.7.2.. doesn't work

#145
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
Excuse me again, you must run the full install to attach your network-ports. Or you start Edit KWSleep and run Network Interfaces - Detect from the menu bar ...
i wrote this script some months ago ... :whistle:
Regards
KWS

#146
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
i did that, without joy :(

salu2

#147
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
So I am at my wits end - here the script stops if in- or outgoing traffic greater than 50 kbyte/s occurs.
Are you sure that the network-port with your outgoing traffic (shown in system settings - Network (standard is en0) is detected by the script...

Regards
KWS

#148
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
yes its recognized on en0 en1 and fw0.. but both systems i tried doesn't enter into sleep.. one 10.6.8 the other 10.7.2. the network interface are detected correctly.

salu2

#149
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
And is it in the script


for Interface in "en0" "en1" "fw0 "# Net

#150
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
this is how it looks like

# Network-Interfaces
for Interface in "en0" "en1" "fw0" # Net
do
IArray=( "${IArray[@]}" $Interface )
done

#151
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
Okay, copy this file

Attached File  Sleep.sh.zip   1.96KB   16 downloads

to your 10.6.8 /Library/Scripts/KWS/-directory and overwrite Sleep. If its not functioning my brain runs out of fuel ...

#152
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
mmmhhhhhhhhh still no go.... i played with NetVal=20000 # Treshold for Network-Traffic in Byte/s going up to 90000 no change at all..... so i tried just to unplug lan cable and ..... no network traffic but no sleep...

so as nobody of the other downloaders gave a feedback i assume it must be something with my two test systems!!.. well KWS you did not confirm that its working for you ;)

i have no script skills but i can make few more test if you like..

thx

salu2

#153
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
Heres a Testskript, download it and copy it to your desktop ...

Attached File  TestLAN.sh.zip   835bytes   8 downloads

Then open a terminal window, type
bash
and drag the TestLan-skript inside the window.

You will see something like
bash /Users/xxx/Desktop/TestLAN.sh

Hit enter ...
You should see

en0 TrafficOut 0
en1 TrafficOut 0
fw0 TrafficOut 0

Now try to copy some files from your server to a client ...

In the terminal window again hit enter and wait ...

Now you should see something like

en0 TrafficOut 0
en1 TrafficOut 18348
exit en1

if the outgoing traffic uses en1

You can copy the appearing lines and post them ...

#154
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
thats what i get


Server$ bash /Users/Server/Desktop/TestLAN.sh this one via remote desktop
en0 TrafficOut 528
en1 TrafficOut 0
fw0 TrafficOut 0
Server$ bash /Users/Server/Desktop/TestLAN.sh without remote desktop
en0 TrafficOut 0
en1 TrafficOut 0
fw0 TrafficOut 0
Server$ bash /Users/Server/Desktop/TestLAN.sh
en0 TrafficOut 78733242
exit en0

whats strange is even if i disable the ethernet port in bios there is definitely no traffic and it should sleep.. but it doesn't



#155
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
So it exited on TrafficOut of en0 - the script works, but your machine goes to sleep ...
this is a mystery to me ...

#156
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
even with lan unplugged.... always TrafficOut of en0 0 no sleep command!!

???

#157
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
... i added a update in first post ...

#158
OsXsO

OsXsO

    InsanelyMac Protégé

  • Members
  • PipPip
  • 84 posts
  • Location:Spain
Hola KWS

Happy new year..... it looks like it is working properly...... thx

salu2

#159
daxure

daxure

    InsanelyMac Protégé

  • Members
  • PipPip
  • 53 posts
Thanx :thumbsup_anim: to all for shearing your workarounds, after going through all post I`ve managed to bring to sleep my machine, one thing at the and which made my day was that I`ve moved from L/Pref/SystemConfiguration/ com.apple.PowerManagement.plist of SL10.6.8 to Leo 10.7.2 and its sleeps and wakes like in my old SL without any problem--- maybe this tipp helps somebody-

Here`s my plist


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ActivePowerProfiles</key>
<dict>
<key>AC Power</key>
<integer>-1</integer>
</dict>
<key>Custom Profile</key>
<dict>
<key>AC Power</key>
<dict>
<key>Automatic Restart On Power Loss</key>
<integer>0</integer>
<key>Disk Sleep Timer</key>
<integer>10</integer>
<key>Display Sleep Timer</key>
<integer>60</integer>
<key>Hibernate File</key>
<string>/var/vm/sleepimage</string>
<key>Hibernate Mode</key>
<integer>0</integer>
<key>Sleep On Power Button</key>
<integer>1</integer>
<key>System Sleep Timer</key>
<integer>0</integer>
<key>TTYSPreventSleep</key>
<integer>0</integer>
</dict>
</dict>
<key>LastSleepUUID</key>
<dict>
<key>Date</key>
<date>2012-01-16T20:14:57Z</date>

changes which I`ve made are:

Hibernat=0,
System Sleep timer=0,
TTYSPreventSleep=0

#160
rcork

rcork

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 167 posts
I was having a problem where my hack would go to sleep while i was streaming content to my AppleTV. It appears to happen once the content has been fully buffered on the AppleTV and the network traffic drops below the 50KB/s limit. Once that happened, the computer would go to sleep and the AppleTV would abruptly stop playing. In order to prevent this from happening, i edited the sleep.sh script and added the following code just before the end where it puts the system to sleep

# check if any appletvs are currently connected and prevent sleep if they are
ATV=`/usr/sbin/lsof -i | grep apple-tv`
if [ -n "$ATV" ]; then
logger -t KWSleep "AppleTV currently connected. Do Not Sleep"
exit
fi

In order for this to work correctly, i had to make sure my AppleTV was set to sleep after a period of inactivity (i have mine set to 15 minutes). Otherwise the AppleTV keeps the connection open regardless of whether it's playing something and the computer would never sleep.

UPDATE: I found something interesting today when i hooked up a new AppleTV to my home network. I have 3 ATV's connected via Wired connection. The new ATV i had to use wireless. I found that when the wireless ATV was streaming from iTunes, my hack still went to sleep. Upon digging, it looks like the wireless ATV does not resolve to the host name specified (ie. office-apple-tv) and only shows the IP address when you run lsof -i | grep iTunes. This appears to be a problem with my Linksys WRT610N router not supporting IPV6 over wifi. It does support IPV6 over LAN. Instead of trying to figure out the IP addresses of all the ATVs and hardcoding them in the script, i just used an Airport Express i had lying around to create a second wifi network that my ATV is connected to. As expected, the Airport Express (and i would assume an Airport Extreme) allows wireless clients to connect to my home network via IPV6 and the hostnames are resolved, allowing me to use "lsof -i | grep apple-tv" for determining when my ATV's are streaming content from my hack.

Edited by rcork, 27 March 2012 - 03:50 PM.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy