#431 sshcollector calls die() even if all the work is not done - stromsoe
This commit is contained in:
@@ -257,7 +257,11 @@ Depending on the target system, it can be queried using simple methods like
|
||||
or automated via Expect - this is mostly useful for non-Linux appliances which
|
||||
don't support command execution via ssh:
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
my $prompt = qr/#/;
|
||||
my ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt);
|
||||
|
||||
@@ -47,7 +47,11 @@ sub arpnip{
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -53,7 +53,11 @@ sub arpnip {
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -50,7 +50,11 @@ sub arpnip {
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -48,7 +48,11 @@ sub arpnip {
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -50,7 +50,11 @@ sub arpnip {
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -48,7 +48,11 @@ sub arpnip {
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
|
||||
@@ -39,7 +39,11 @@ sub arpnip{
|
||||
|
||||
debug "$hostlabel $$ arpnip()";
|
||||
|
||||
my ($pty, $pid) = $ssh->open2pty or die "unable to run remote command";
|
||||
my ($pty, $pid) = $ssh->open2pty;
|
||||
unless ($pty) {
|
||||
debug "unable to run remote command [$hostlabel] " . $ssh->error;
|
||||
return ();
|
||||
}
|
||||
my $expect = Expect->init($pty);
|
||||
my ($pos, $error, $match, $before, $after);
|
||||
my $prompt = qr/> \r?$/;
|
||||
|
||||
Reference in New Issue
Block a user