Koozali.org: home of the SME Server

Auto shut down / Wake On Lan

bjarni

Auto shut down / Wake On Lan
« on: July 26, 2005, 01:48:58 PM »
Hi
I got a SME Server 6.0.1 running at home 24 hours a day. I would like to save some power by shutting it down when it not is used.

It would be nice if I had a service, which could shut down the server automatically if no local computer had been connected for some time (ex. 15 minutes). Does anyone know if anything like this does exist?

Futhermore I would like all local computers to try to make a Wake-On-LAN on the Server if it is not running. How do I do this?

/bjarni

Offline Knuddi

  • *
  • 540
  • +0/-0
    • http://www.scanmailx.com
Auto shut down / Wake On Lan
« Reply #1 on: July 26, 2005, 09:28:37 PM »
Bjarni,

I am not sure that it can be all that automatic BUT you can use WOL with SME. First test your NIC to see whether it supports it by issuing

# ethtool eth0 (or eth1) if you run in gateway mode

You should somewhere see:
        Supports Wake-on: pumbg
        Wake-on: d

To enable Magic packet wake-up:

# ethtool -s eth0 wol g

Determine the MAC address of the NIC from "ifconfig" You can now safely shutdown with:

# shutdown -f now

This SME server can be woken up with (from another UNIX box):

ether-wake xx:xx:xx:xx:xx with xx: being the MAC address of eth0 in my example.

I use this for my project server that I only use when a new build of something goes out.

Rgds,
Jesper

bjarni

Auto shut down / Wake On Lan
« Reply #2 on: July 27, 2005, 11:26:00 AM »
Jesper,

Thanks for your reply regarding WOL. That wil be very usefull.

It must also be posible to make a job (ex. CRON), that every 15 minutes checks if any local computers are conected to the server.

Are any information about active-LAN-connections available on the server (log-files etc.)?

It would also be OK to check from a 'hardcoded' list of MAC-addresses if any of them are 'active', and - if not - make a shutdown.

/bjarni

Offline Knuddi

  • *
  • 540
  • +0/-0
    • http://www.scanmailx.com
Auto shut down / Wake On Lan
« Reply #3 on: July 27, 2005, 02:31:32 PM »
I guess you can use the /var/lib/dhcp/dhcpd.leases file as a guide to which stations to check for all stations getting IP address via DHCP. You could simply ping them and decide action if no-one answers.

BTW: The shutdown should be with the -h rather than -f options.

Rgds,
Jesper

Michiel

Auto shut down / Wake On Lan
« Reply #4 on: August 08, 2005, 03:15:29 PM »
Quote from: "Knuddi"
You could simply ping them and decide action if no-one answers.


This might be a problem with net appliances on the same subnet that are allways on (printer server, router, modem) or firewalled clients that do not answer to simple pings (most personal firewalls allow you to switch off ping replies).

Yet an other way might be to install nmap and do a full subnet scan. You will have to experiment a bit to find out which type of scan you need to find all the machines on your lan. nmap will then create a list of all the IP addresses it found. Comparing this with the list of IP addresses that always need to be up allows you tell if the server can be shut down.

I would be interested in your experiences once you get it working

regards,
Michiel