use Net::SNMP;
use IO::Socket::INET;
+use IO::Select;
use RRDs;
use File::Copy;
use Data::Dumper;
return undef if (!$sock);
- chomp(my $value = <$sock>);
+ my $select = IO::Select->new($sock);
+
+ my $value = undef;
+
+ if ($select->can_read(1)) {
+ chomp($value) if (sysread($sock, $value, 4096) > 0);
+ }
close($sock);
return undef if (!$sock);
- while(<$sock>) {
- chomp;
- (my $key, my $value) = split(/${delimiter}/, $_);
- $value=~ s/\s//g;
- $values{$key} = $value;
+ my $select = IO::Select->new($sock);
+
+ while($select->can_read(1)) {
+ if (sysread($sock, my $buf, 16384) > 0) {
+ $buf=~s/\r//g;
+ foreach my $line (split(/\n/, $buf)) {
+ (my $key, my $value) = split(/${delimiter}/, $line);
+ $value=~ s/\s//g;
+ $values{$key} = $value;
+ }
+ } else {
+ last;
+ }
}
close($sock);