fiddler42 has asked for the wisdom of the Perl Monks concerning the following question:
I have put together a script that cycles through a list of linux hostnames. If I can first successfully ping a machine, I then check to see if my home directory is mounted on that machine.
I am running into a small problem, though: even though I can ping a system and get good statistics on the connection, sometimes a machine is, well, brain dead and can't do much of anything (read: it needs a swift reboot :-). I therefore need to improve the way in which I check to see if my home directory is mounted. Here is the routine:-
foreach $Host (@MasterMachineIndex) { &ping; # my subroutine to ping system...works fine $Cmd = "rsh $Host uptime"; $Status = `$Cmd`; $CheckHome = ("rsh $Host \"cd $Home\""); $HomeStatus = `$CheckHome 2>&1`; # This captures STDERR and STD +OUT outputs that may or may not manifest... if ($HomeStatus =~ /No such/) { # May need to add more keyw +ords here. Not sure all OSs echo same nomenclature... print ("$Home directory not mounted on $Host! Skipping...\n") +; } else { $CPUScan = "rsh $Host \"CPUScan.pl >> ./foo\""; $CHECK = `$CPUScan`; print ("$Host:\t$Status"); } }
The crux of the problem is the second and third lines ("rsh $Host uptime"): sometimes after a successful ping, this rsh operation just doesn't complete and the foreach just grinds to a halt. I have been trying to add in alarm functionality, but I am failing so miserably I am not even going to post my pathetic code.
Any suggestions? I just want to try to rsh into the system, and if nothing happens within, say, 5 seconds, just move on the next host in the @MasterMachineIndex. If I eliminate known problem workstations from my list, the code above rips along just fine.
I would greatly appreciate any suggestions!
Reagrds,
fiddler42
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to get alarm to work...
by liverpole (Monsignor) on Apr 15, 2007 at 21:39 UTC | |
|
Re: Trying to get alarm to work...
by betterworld (Curate) on Apr 15, 2007 at 21:45 UTC | |
|
Re: Trying to get alarm to work...
by swares (Monk) on Apr 16, 2007 at 05:58 UTC | |
|
Re: Trying to get alarm to work...
by fiddler42 (Beadle) on Apr 16, 2007 at 14:58 UTC |