[or-cvs] r15011: (ticket:98) Adding average bandwidth bar to graphs (in torstatus/trunk: cgi-bin/perlgraph web)

kasimir at seul.org kasimir at seul.org
Sat Jun 7 17:02:23 UTC 2008


Author: kasimir
Date: 2008-06-07 13:02:22 -0400 (Sat, 07 Jun 2008)
New Revision: 15011

Modified:
   torstatus/trunk/cgi-bin/perlgraph/plot.pl
   torstatus/trunk/web/router_detail.php
Log:
(ticket:98) Adding average bandwidth bar to graphs

Modified: torstatus/trunk/cgi-bin/perlgraph/plot.pl
===================================================================
--- torstatus/trunk/cgi-bin/perlgraph/plot.pl	2008-06-07 09:27:43 UTC (rev 15010)
+++ torstatus/trunk/cgi-bin/perlgraph/plot.pl	2008-06-07 17:02:22 UTC (rev 15011)
@@ -128,6 +128,7 @@
 	$x_label = "Time";
 	$y_label = "Bytes/Sec";
 	$x_labels_vertical = 1;
+	$bandwidth_line = $session->get('ObservedBandwidth');
 	if ($plot_type eq "rtw")
 	{
 		$data_session = "WriteHistory_DATA_ARRAY_SERIALIZED";
@@ -145,7 +146,7 @@
 	$width = '480';
 	$height = '400';
 	$show_values = 0;
-	$type = ["area"];
+	$type = ["area", "lines"];
 }
 
 # Retrieve and format the variables from the PHP session
@@ -160,6 +161,7 @@
 	push @data, $data_h{$v};
 }
 my @label;
+my @bwlines;
 if ($plot_type ne "rtw" && $plot_type ne "rtr")
 {
 	my %label_h = %{unserialize($label_s)};
@@ -184,9 +186,14 @@
 	for (my $i = 0; $i < scalar(@data); $i++)
 	{
 		$data[$i] = $data[$i]/$inc;
+		push @bwlines, $bandwidth_line;
 	}
 }
 my @plot = [[@label],[@data]];
+if ($plot_type eq "rtw" || $plot_type eq "rtr")
+{
+	@plot = [[@label],[@data],[@bwlines]];
+}
 
 my $graph = GD::Graph::mixed->new($width, $height);
 
@@ -215,6 +222,11 @@
     y_long_ticks	=> $y_long_ticks,
     types	=> $type,
 ) or warn $graph->error;
+if ($plot_type eq "rtw" || $plot_type eq "rtr")
+{
+	$graph->set( dclrs	=> ['blue','black']);
+}
+
 my $image = $graph->plot(@plot) or warn $graph->error;
 
 print "Content-type: image/png\n\n";

Modified: torstatus/trunk/web/router_detail.php
===================================================================
--- torstatus/trunk/web/router_detail.php	2008-06-07 09:27:43 UTC (rev 15010)
+++ torstatus/trunk/web/router_detail.php	2008-06-07 17:02:22 UTC (rev 15011)
@@ -171,6 +171,17 @@
 	$_SESSION['ReadHistory_LAST'] = $record['ReadHistoryLAST'];
 }
 
+// Save the bandwidth value
+if (!isset($_SESSION['ObservedBandwidth']))
+{
+	$_SESSION['ObservedBandwidth'] = $Bandwidth_OBSERVED;
+}
+else
+{
+	unset($_SESSION['ObservedBandwidth']);
+	$_SESSION['ObservedBandwidth'] = $Bandwidth_OBSERVED;
+}
+
 // Handle no descriptor available situation
 if ($Name == null)
 {



More information about the tor-commits mailing list