| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| linux-energy-saver.tar.gz | 2011-06-11 | 2.8 kB | |
| README | 2011-06-11 | 3.2 kB | |
| Totals: 2 Items | 6.0 kB | 0 |
README: information about the Linux energy saver
---------
PTHOEM LINUX UTILS (c) 2008-2011 Peter Thoemmes
Weinbergstrasse 3a, D-54441 Ockfen/Germany
The Linux energy saver supports you if you like your Linux server machines to
be suspended automatically, so it can be awakened only by a WOL magic packet.
It consists of two shell scripts using the 'sar' tool. So 'sar' needs to be
installed before using these scripts. Under ubuntu that goes like this:
# apt-get install sysstat
The two Linux energy saver scripts are more handy to use if you copy them to
/usr/local/bin/:
# cp ./try-to-suspend.sh /usr/local/bin/
# chmod +x /usr/local/bin/try-to-suspend.sh
# cp ./suspender.sh /usr/local/bin/
# chmod +x /usr/local/bin/suspender.sh
The script 'try-to-suspend.sh' tries to put the machine asleep. When calling
'try-to-suspend.sh' with a parameter it tries for the given number of minutes
to get the machine suspended. For example
# try-to-suspend.sh 5
will try for 5 minutes to get the machine suspended. The script 'suspender.sh'
is trying once every 30 minutes to get the machine suspended. That means it
calls 'try-to-suspend.sh 5' every 30 minutes and so tries for 5 minutes to
make the machine sleeping. To automate this, simply put following line into
'/etc/rc.local' (using any text editor):
nohup suspender.sh >/dev/null
So your '/etc/rc.local' might look like this
#!/bin/sh -e
nohup suspender.sh >/dev/null
exit 0
This will take effect only after the next reboot. To get the suspender run
immediately type
# nohup suspender.sh >/dev/null
on the command line. Once suspended the machine can only be waked up a WOL
magic packet. There is free open source WOL software to send such a packet to
the machine's network adapter. For example you may get 'ethercat':
# wget https://downloads.sourceforge.net/project/ethercat/ethercat.tar.gz
Follow the instruction to install 'ethercat' and then use it like this from
any remote machine:
$ wol.sh <local-adapter-name> <remote-adapters-mac-addr>
So you have to decide which local adapter to use for sending, e.g. 'wlan0' or
'eth0', and you have to find out the remote server's MAC address. Both you can
easily find out by executing the command
$ ifconfig -a
...
wlan0 Link encap:Ethernet HWaddr bc:05:32:a1:cd:f4
...
on both the machines. Every entry shown starts with the adapater's name (e.g.
'wlan0') and is followed by a field 'Link encap:Ethernet HWaddr HWaddr ...'
telling the MAC address. So for example you may wake up your server like this:
$ wol.sh wlan0 80:43:21:2F:3A:65
or like this
$ wol.sh eth0 80:43:21:2F:3A:65
and you will see that your suspended machine wakes up again. You can easily
find out if your WOL magic packet really reaches the machine, by executing
'tcpdump' on your server and you will see the 102 bytes coming in as a UDP
packet like this:
# tcpdump -i eth0 -X -s 1500 port 9
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes
12:55:44.940490 IP ... > 255.255.255.255.discard: UDP, length 102
...
I wish you a lot of success with my scripts,
Peter