views:

448

answers:

6

I am using the Windows Update API to update a bunch of VM's. With Windows Update comes the inevitable reboots. Can anyone think of a way that I could tell from a remote server if the windows box has indeed finished its reboot? All ideas or thoughts would appreciated.

EDIT: Because the VM's are in Lab Manager and using a fenced configuration, WMI will not work, and although I thought about using the VM to send a signal when it was back up. There would have been no way to reliably know who to notify as the app waiting for the machine could be on any number of machines so it just didn't seem reasonable. However time is not essential (and even though I know this will bite me sometime when a Service Pack comes down) I have had good success with the PING and then wait 5 minutes so far, so I am going to use that for now. If I run into exceptions I will then try to implement the VM notfiying the world when it comes back up. Thanks to all.

+1  A: 

A more general version of this question is How do I know if a system has powered on?

Tanktalus
+5  A: 

Just wait for it to respond to a ping.

In light of your comments:

1 - Use this script

2 - If you get any errors with that script, follow these instructions.

JosephStyons
The machine starts being pingable about 5 minutes before you could actually log in or services are running again. But I did try it ;)
Alex
5 *minutes*? That seems extreme. Are you sure you are not catching the last few ping responses before the server goes down?
JosephStyons
Well you have to remember these are windows update, and I am trying it in the worst case. Which means vista and its dang 3 stage updating. I will try the script and see what's up.
Alex
I didn't know a machine would respond to pings before updates were finished. I'm glad the revised answer worked.
JosephStyons
+1  A: 

The reality is that you can't know when it is done booting. The boot process is pretty asynchronous and so whatever criteria you use to determine that it is done "booting" could happen before something else completes.

What I would recommend is determine what you actually want to know. What specifically is it you are waiting for? Find a way to determine whether this has taken place and forget worrying about "booting".

If you just need to know that the machine is back up but maybe hasn't completed all of the post-boot loading, put something in the startup sequence or a service that signals your code. When this signal takes place, take whatever action you need to.

Steve Rowe
I need to basically get the log in screen again. After the updates are done configuring.
Alex
+1  A: 

You could install a startup program or service on the machine to send an email or some type of network based posting everytime it restarts.

CookieOfFortune
I think I will try this next..
Alex
+1  A: 

Check for this event in the event log:

Event Type: Information
Event Source:   EventLog
Event Category: None
Event ID:   6005
Date:    7/27/2007
Time:    12:56:24 PM
User:    N/A
Computer:   IWSDEV
Description:
The Event log service was started.
Otávio Décio
Checking event log remotely can't happen without the RPC service. Better to just check remote service status of the "RpcSs" service. This would also eliminate the slim possibility of event log faults, like corrupted log.
spoulson
@spoulson - good idea, thanks
Otávio Décio
A: 

Windows is done rebooting only slightly before it'll need rebooting again :-)

If you're specifically looking to query the status of VMs then you should check out these links which deal with the API for Virtual Server 2005:

The IVMVirtualMachine Interface...

http://msdn.microsoft.com/en-us/library/aa368465(VS.85).aspx

... has a property called State...

IVMVirtualMachine::State Property

http://msdn.microsoft.com/en-us/library/aa368637(VS.85).aspx

... which will return a value from the VMVMState Enumeration...

http://msdn.microsoft.com/en-us/library/aa368922(VS.85).aspx

At a more general level, you should probably define how much of Windows you want up and running. Do you consider network stack ready to be "rebooted" or do you need IIS/SQL or some other application level service up?

I'd probably write an app that checks the "heart-beat" of your servers - that app could well be the same one that's invoking the Windows Update stuff. You'd then get yourself a nice "console" showing you the status of your servers. The heart-beat app could ping a server, hit a static html page, hit the remote event log, use WMI or whatever you define as enough to consider your server rebooted.

Martin Peck
I am on VMWare not VirtualServer, and during a reboot the time the actual machine is off is very small. Almost no chance of detecting it off, so it always responds on through vmware's API
Alex