views:

288

answers:

4

I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on?

My programming language is Perl and the target host is RHEL5.

Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded?

[In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and when is the OS is supposed to have booted completely for a network related operation such as executing a network command there. What if the system is on DHCP how would a remote system then search for this machine [i guess it is possible via mac address. but if i am wrong ].

If I have missed out any info please feel free to ask me. If you have any suggestions to make the task easier please surface them :)

thanx imkin

+11  A: 

Well, I'd say the system is booted when it can perform the request you've made of it. That is, the sshd daemon is running. That's booted sufficiently for your purposes (I assume - substitute for whatever daemon you really need).

So, I'd send the power-on signal, and check back every 15-30 seconds to see if I could connect. If I've failed to connect within whatever is a reasonable time for that machine (2 minutes or 5 minutes or whatever), then I'd send an alert to the IT support team. Well, I'd send it to myself first, and only once I've investigated a few failures or so and found them to all be legitimate would I start sending it directly to IT.

DHCP is kind of a different question. You'd have to start learning about broadcasting, or having a daemon on that machine "call home" during boot to register its current IP address. And it would have to "call home" every time a DHCP renewal changed its IP address. This is decidedly more convoluted. Try to avoid DHCP on such server machines if at all possible.

Tanktalus
Why would DHCP change the IP address? DHCP just means that the computer asks the network for an address - it doesn't mean that the address changes. What fixes the address is the router or whatever replies to the query. All one has to do is to tell the router to give a fixed IP to the machine.
DHCP merely *can* change IP addresses. Nothing says it *must*. One must deal with that in some way - which is either configuring the DHCP server specially, or dealing with the IP change.
Tanktalus
It is generally not a good idea to use the IP address directly.
Brad Gilbert
+7  A: 

I think checking for sshd sounds like a good approach.

As for the DHCP problem: if the other computer is on the same subnet you can look it up by MAC address using Net::ARP.

Leon Timmermans
+3  A: 

How about adding a script to the remote machine which gets run on startup to have it tell you when it is ready.

Simon
+9  A: 

On the rebooting machine you can install a script in your crontab with the special @reboot assertion (see man 5 crontab). That script could send a notification of some kind to the other machine, notifying it that it's up now.

moritz
I like this idea of the system phoning home. Make it the last thing in the boot sequence (or at least after the services you care about) and you know the system can respond to your subsequent requests.
tvanfosson