Tuesday, September 9, 2008

Surveyor PC Power Management 8 - Wake-On-Wan

Issue:
Wake computers in order to perform nightly backup of local pst mail files.

Quick:
Gather MAC address using ping and arp via day script, Use backup script and mc-wol.exe program to wake computers at night.

Visual/Learning:
Since currently Verdiem server can't take commands via script, I have to find a way to do add wake-up code to my backup script.

At the following link http://www.matcode.com/wol.htm I found a small program that works quite well (mc-wol.exe ) to wake the computers using wake-on-lan magic packets. This program requires me to pass it the Media Access Control Address (MAC Address) for the network card of the computer I want to wake.

I do not have a list of MAC addresses for all my computers and MAC information changes as computers and network cards are replaced. I can't pull the MAC from the computers at backup run-time because they will have all suspended. So I need a script to run in the day-time that can generate and maintain an updated history list ('MacHist.txt').

I created a script to do this and I have it run on a schedule during the day when machines are be used. I ping the machine to get the IP address and then "arp -a" brings up the ARP table so I can find the MAC Address associated with that IP.


The script is pretty long so I am not going to try and post it here (plus the formating gets all messed up when I do) but these are the basic steps:

-For each computer name in Active Directory
-Try to ping computer
--If it pings get the IP address from the ping return
--Check ARP table for the IP address and get MAC Address
---If the computer name is in MacHist.txt update the IP and MAC data in that record
---else add a new record to MacHist.txt
-Check all computers from AD listing
-Save the updated MacHist.txt file

The data in my MacHist.txt file looks like this:

ComputerName:IpAddress:MacAddress
ComputerName1:192.168.1.1:00-11-f3-2f-2b-a1
ComputerName2:192.168.1.2:00-15-f2-e5-18-23
ComputerName3... AND SO ON


I run this script from a computer on the same subnet as my workstations because the ARP table only shows data for machines on the local subnet.

Then my backup script reads the MacHist.txt file at night and wakes the workstations one at a time for backup (using the mc-wol.exe program). Then the script tries to ping the workstation using the IP address from the MacHist.txt file. If the script sees pings return from the computer it starts the backup process or else moves on to the next computer. When the backup is done, the computer network and disk activity stops, and the computer goes back to sleep. They go back to sleep because my night power profile is set to suspend after 15 minutes of idle time.

So all the machines sleep till it is their turn to backup, and sleep again when done.

Some questions have come up about how to allow for Windows updates which usually happen at 3 AM on Patch Tuesday (second Tuesday of the month). This can be fixed in Verdiem by scheduling an action to Wake all clients at 2:59 AM on Tuesday. If there are any updates the disk activity will keep the machines awake until the updates are done.

Surveyer PC Power Management 9

No comments: