On Sunday March 19, 2006 13:25, Phillip Corchary wrote:
> New, clean 1.29 Net::SSH:Perl on CentOS box. Working on building tools to
> help manage 2000+ servers ... some servers might obviously be down at some
> arbitrary point in time. Current, when my test script tries to access a down
> server (either down hard, no ping, or sshd down), it just HANGS. Note I'm
> using a non-standard SSH port (required, local policy), but all hosts seem
> to work fine when up.
>
> Debug output looks like this:
...
> This takes about 5 minutes, which is obviously a problem ... All hosts are
> on 100/1000 ethernet and not more than 2-50ms away by ping. These are the
> SSH options I'm using ... I thought this would give a a 2sec timeout, but
> it's not working ...
>
> my %params = (
...
> options => [
> "ConnectTimeout=2",
> ]
> );
> Need Help! I am new to Perl, but I think I can write the proper response to
> the timeout -- just it's not even detecting the timeout!!! What am I doing
> wrong here????? :-)
Not all ssh configuration options are handled by Net::SSH::Perl (for a list of
those that are, see the source of Net::SSH::Perl::Config, e.g. using 'perldoc
-m Net::SSH::Perl::Config' or by looking at the file in the distribution or
install tree).
To handle a timeout, look at the eval and alarm builtins ("perldoc -f alarm"
"perldoc -f eval"); e.g.
eval {
local $SIG{ALRM} = sub { die "ALARM\n"; };
alarm 2; # send SIGALRM in ~2 seconds
# put connection code here
};
if ($@) {
die $@ unless $@ eq "ALARM\n";
# handle timeout
}
> Phil Corchary
> Denver, Colorado
> phillip =dot= corchary <at> gmail =dot= com
I'd also like to take this opportunity to tout Net::SSH2 (yet again) as the
wave of the future in all things SSHy. You may prefer it to Net::SSH::Perl.
--
Dave
Isa. 40:31
|