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);
print HTML "<a href=\"${hostname}.${var}.html\"><img src=\"${hostname}.${var}.png\" width=\"${width}\" height=\"${height}\" border=\"0\"></a><br>\n";
open (HTML2, ">${outdir}/${hostname}.${var}.html.new");
- print HTML2 '<html><head><meta http-equiv="refresh" content="60"/><meta http-equiv="cache-control" content="no-cache"/><meta http-equiv="pragma" content="no-cache"/><meta http_equiv="expires" content="Sat, 26 Jul 1997 05:00:00 GMT"/><title>' . $vars->{$var}->{'name'} . '</title></head>';
+ print HTML2 '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="refresh" content="60"/><meta http-equiv="cache-control" content="no-cache"/><meta http-equiv="pragma" content="no-cache"/><meta http_equiv="expires" content="Sat, 26 Jul 1997 05:00:00 GMT"/><title>' . $vars->{$var}->{'name'} . '</title></head>';
print HTML2 '<body bgcolor="#ffffff">';
push @graphdef, "VDEF:min=${var},MINIMUM";
}
}
- print HTML2 "<img src=\"${hostname}.${var}.long.png\" width=\"${width}\" height=\"${height}\"><br>";
+ print HTML2 "<img src=\"${hostname}.${var}.long.png\" width=\"${width}\" height=\"${height}\"><br>\n";
$mtime=(stat("${outdir}/${hostname}.${var}.week.png.work"))[9];
($averages, $width, $height) =
}
}
- print HTML2 "<img src=\"${hostname}.${var}.week.png\" width=\"${width}\" height=\"${height}\"><br>";
+ print HTML2 "<img src=\"${hostname}.${var}.week.png\" width=\"${width}\" height=\"${height}\"><br>\n";
$mtime=(stat("${outdir}/${hostname}.${var}.year.png.work"))[9];
($averages, $width, $height) =
}
}
- print HTML2 "<img src=\"${hostname}.${var}.year.png\" width=\"${width}\" height=\"${height}\"><br>";
+ print HTML2 "<img src=\"${hostname}.${var}.year.png\" width=\"${width}\" height=\"${height}\"><br>\n";
print HTML2 "</body></html>\n";
close(HTML2);