Subject: | Too many open files |
Date: | Tue, 8 Nov 2016 19:37:29 +0000 (UTC) |
To: | "bug-Control-CLI [...] rt.cpan.org" <bug-Control-CLI [...] rt.cpan.org> |
From: | Jon Wolfert <quakehunter5225 [...] yahoo.com> |
In running a script which connects to about 1200 network devices, it got to ~650, and then had the below error when it went to create the next session. I checked how many Input/Output/Dump files had been written in the director so far and it was just shy of ~2,000 . I believe the number of open files is a limit of the OS, but as each of the SSH sessions is closed, I would expect the file handles to be closed as well. Below is the code
"problem creating ./XXXX - Test-Input.txt: Too many open files at D:/Strawberry/perl/site/lib/Control/CLI.pm line 869"
Below is the code I'm using, 'conn' is a method I use that just attempts a Telnet session, if that fails it attempts an SSH connection, but the variable $conn is now the Control::CLI object and I am able to throw all commands at it without issue. The object is not stored in any way outside of this 'for' loop, but is there a chance the file handlers are not being closed upon 'disconnect'? Thank you as always for any insight in to this!
for my $ip_address (@ip_list) {
#Attempt to connect to device
if(conn(\$conn, $ip_address, $username, $login_pass, $enable_pass)) {
print "Connection successful to $ip_address.\n"
} else { next; }
#Check if device is already in device list
if(!exists $devices{$ip_address}) {
...
} else { print "Error: Device($ip_address) should not exist already\n"; }
#Close SSH/Telnet session
$conn->disconnect;
}
J. Wolfert