diff options
-rwxr-xr-x | clients/smanagrun.pl | 5 | ||||
-rwxr-xr-x | include/nms.pm | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/clients/smanagrun.pl b/clients/smanagrun.pl index 0e2302e..9df4b96 100755 --- a/clients/smanagrun.pl +++ b/clients/smanagrun.pl @@ -104,7 +104,7 @@ while (1) { $error = $sgetallpoll->execute($switch->{sysname}); if (!$error) { print "Could not execute sgetallpoll\n".$dbh->errstr(); - $conn->close; + switch_disconnect($ssh); next; } while (my $row = $sgetallpoll->fetchrow_hashref()) { @@ -142,8 +142,7 @@ while (1) { my $result = join("\n", @data); $sresult->execute($result, $row->{id}); } - $conn->close(); - waitpid($ssh->{pid}, 0); + switch_disconnect($ssh); $sunlock->execute($switch->{sysname}); }; if ($@) { diff --git a/include/nms.pm b/include/nms.pm index e6f4d6c..c61cec7 100755 --- a/include/nms.pm +++ b/include/nms.pm @@ -148,9 +148,13 @@ sub switch_timeout { return ('Set timeout to ' . $timeout); } -sub switch_disconnect { - my ($conn) = @_; - $conn->close; +sub switch_disconnect($) { + my ($struct) = @_; + my $conn = $struct->{telnet}; + $conn->close(); + if ($struct->{pid}) { + waitpid($struct->{pid}, 0); + } } sub snmp_open_session { |