http://qs321.pair.com?node_id=1121620

dpprabhuindia has asked for the wisdom of the Perl Monks concerning the following question:

I am new to perl, I am facing issue with perl script which does job to get data from command 'rrdtool fetch' to html output with graphs. Now it gives error as Uninitialized value, but same perl script os working on other host which has old perl version. This working perl version on RHEL5 machine

perl -v This is perl, v5.8.8 built for i386-linux-thread-multi
and This perl version on RHEL6 which is not working

#!/usr/bin/perl if ($ENV{'REQUEST_METHOD'} eq "POST") read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } elsif ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; } else { exit 1; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/^//g; $list{$name} = $value; } $url = "/aisin/cgi-bin/chkts.pl"; $end = time(); $begin = $end - ($list{period} ? $list{period} : 3456000); $dir = "/home/nagios/var/rrd/ts/$list{sid}"; $lin = $list{top}; opendir(DIR, $dir) || die("can't open directory $dir"); @files = grep(/.+\.rrd$/, readdir(DIR)); closedir(DIR); foreach $f (@files) { next if ( ($list{exceptundo} eq 'on' && $f =~ /UNDO/) || $f =~ /^dbd +ata/ ); next if ( ($list{excepttemp} eq 'on' && $f =~ /TEMP/) || $f =~ /^dbd +ata/ ); open(RRD, "rrdtool fetch $dir/$f AVERAGE -s $begin -e $end|") || next +; @f = (); $i = 0; while (<RRD>) { next if ((!/:/) || /nan +nan +nan/); @f = split; next if ($f[3] == 0); if ($i < 1) { $lsiz1 = $f[1]; $rfre1 = $f[2]; $rsiz1 = $f[3]; } else { $lsiz2 = $f[1]; $rfre2 = $f[2]; $rsiz2 = $f[3]; } $i++; } close(RRD); $count = @f; next if ($count == 0); $b = $f; $b =~ s/(.*)\.rrd/\1/; #printf "%s %.0f %.0f %.0f %.0f %.0f %.0f<br/>\n", $b, $lsiz1, $rfre1 +, $rsiz1, $lsiz2, $rfre2, $rsiz2; $amount{$b} = $lsiz2 - $lsiz1; $ratio{$b} = $amount{$b} / $rsiz2; } print "Content-type: text/html\n\n"; print "<html>\n"; print "<body>\n"; print "<center>\n"; print "<p>\n"; print "<H3>\n"; if ($list{period} <= 86400) { printf "last %d hours growth\n", $list{period} / 3600; } else { printf "last %d days growth\n", $list{period} / 86400; } print "</H3>\n"; print "<table border=1>\n"; printf "<tr><th>top %d amount<th>Mega<th>%%<th>top %d utilization<th>M +ega<th>%%\n", $lin, $lin; $i = 0; foreach $k (sort {$amount{$b}<=>$amount{$a}} (grep {$amount{$_}==$amou +nt{$_}} (keys %amount))) { #foreach $k (sort {$amount{$b}<=>$amount{$a}} (keys %amount)) { $k1[$i] = $k; $a1[$i] = $amount{$k}; $r1[$i] = $ratio{$k}; #printf "<tr><td>%s<td>%.2f\n", $k, $amount{$k} / 1024 / 1024 ; last if (++$i == $lin); } $i = 0; foreach $k (sort {$ratio{$b}<=>$ratio{$a}} (grep {$ratio{$_}==$ratio{$ +_}} (keys %ratio))) { #foreach $k (sort {$ratio{$b}<=>$ratio{$a}} (keys %ratio)) { $k2[$i] = $k; $a2[$i] = $amount{$k}; $r2[$i] = $ratio{$k}; #printf "<tr><td>%s<td>%.2f\n",$k, $ratio{$k} * 100; last if (++$i == $lin); } for ($i = 0; $i < $lin; $i++) { printf "<tr>\n"; printf "<td><a href=%s?sid=%s&period=%d&ts=%s>%s</a>", $url,$list{sid},$list{period},$k1[$i],$k1[$i]; printf "<td align=right>%.2f<td align=right>%.2f", $a1[$i] / 1024 / 1024, $r1[$i] * 100; printf "<td><a href=%s?sid=%s&period=%d&ts=%s>%s</a>", $url,$list{sid},$list{period},$k2[$i],$k2[$i]; printf "<td align=right>%.2f<td align=right>%.2f\n", $a2[$i] / 1024 / 1024, $r2[$i] * 100; } print "</table>\n"; print "</center>\n"; print "</body>\n"; print "</html>\n";

pls help me to fix this issue with latest perl version machine. Thanks in advance for your help. dpprabhuindia