use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Socket; use Net::SNMP; use GD::Graph::lines; #function to print out a graph to screen using gd::graph sub print_graph#prints the graph to screen { my $q = new CGI; my ($xarray,$values,$xlabel,$ylabel,$title) = shift(@_); my @data = ($xarray,$values); my $graph = new GD::Graph::lines(500,350); $graph->set ( x_label => $xlabel, y_label => $ylabel, title => $title, x_label_skip => 'auto', y_label_skip => 'auto', line_width => 1, y_tick_number => 8, x_labels_vertical => 1, x_label_position => 1/2, transparent => 0, ); my $gd_image = $graph->plot(\@data); print $q->header(-type => "image/png"); binmode STDOUT; print $gd_image->png; } my $graphxlabel = "Time"; my $graphylabel = "No. Of Packets Recieved"; my $graphtitle = "No. Of Packets Recieved On Interface"; #function call print_graph(\@x_axis_array,\@values_array,\$graphxlabel,\$graphylabel,\$graphtitle);