Hi All,
I have an web app that creates simple graphs. In one of the scripts I need
to sort the data returned from the DB query numerically. I have a sub for
this sort. I converted the script shown below from a regular cron job to
embperl so I know that the perl works.
The problem with the script below is that [ $ sub sortnum () $] prints on
the screen and the image never gets created.
The docs on
http://perl.apache.org/embperl/pod/doc/doc13/HTML/Embperl.-page-5-.htm
indicate that I have done it right.
I have another script that is very similar to this without the sorting and
it works just fine.
What did I get wrong in this script.
I am using embperl 1.36 on apache 1.3x
Thanks.
W
[- use GD::Graph::bars; -]
[- use Socket; -]
[- use CGI qw/:standard *table/; -]
[- $LanChoice = $fdat{LanChoice}; -]
[- chomp $LanChoice; -]
[- $HostChoice = $fdat{HostChoice} -]
[- chomp $HostChoice; -]
[- $Event = $fdat{Event} -]
[- chomp $Event; -]
[- $ShowMe = $fdat{ShowMe} -]
[- chomp $ShowMe; -]
[$ if $Event eq "Inbnd" $]
[- $TableName = "Inbnd" -]
[$ elsif $Event eq "Outbnd" $]
[- $TableName = "Outbnd" -]
[$ endif $]
[- $req = shift; -]
[- undef @x; -]
[- undef @y; -]
[- $sth = $req->{DBHandle}->prepare(qq{ select count(SRC_IP) as
Event_Count, DST_Port from
`${HostChoice}_${TableName}Wk$req->{weeknum}_$req->{year}` where Lan =
'External' and Event like 'Inbnd%' and Protocol != 'ICMP' group by
`${HostChoice}_${TableName}Wk$req->{weeknum}_$req->{year}`.DST_Port }); -]
[- $sth -> execute; -]
[$ while ( $hash_ref = $sth->fetchrow_hashref) $]
[- $events = $hash_ref->{Event_Count}; -]
[- $ports = $hash_ref->{DST_Port}; -]
[- push(@x, "$ports"); -]
[- push(@y, "$events"); -]
[$ endwhile $]
[ $ sub sortnum () $]
[- $a <=> $b; -]
[$ endsub $]
[- @sortX = sort sortnum @x; -]
[- @sortY = sort sortnum @y; -]
[- $y_max = int(($sortY[$#sortY] + 50)); -]
[- $y_tick = int(($sortY[$#sortY] / 10)); -]
[- $y_skip = int(($y_tick / 4 )); -]
[# make and save graph #]
[- $graph = GD::Graph::bars->new(850,400); -]
[- $x_ref = [EMAIL PROTECTED]; -]
[- $y_ref = [EMAIL PROTECTED]; -]
[- @data = ( $x_ref, $y_ref); -]
[- $graph->set(
x_label=>'Port Number',
y_label=>'Count',
x_labels_vertical=>"1",
title=>"Total Events per Port $req->{TimeNow}",
y_max_value=>"$y_max",
y_tick_number=>"$y_tick",
y_label_skip=>"$y_skip" ); -]
[- $format = $graph->export_format; -]
[- open(IMG,">/usr/local/apache/htdocs/FW/img/EventDST.png"); -]
[- binmode IMG; -]
[- $pic = $graph->plot([EMAIL PROTECTED]); -]
[- print IMG $pic->png; -]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]