Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(233)

Delta Between Two Patch Sets: DB/API_REST/draw_graphs.php

Issue 335100043: DB with histogram
Left Patch Set: Fixing last bug Created 6 years, 3 months ago
Right Patch Set: DB Created 6 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « DB/API_REST/config.php ('k') | DB/API_REST/draw_link.php » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 <?php
2
3 ini_set('display_errors', 1);
4 include_once('config.php');
5 $time_post = $_POST['time'];
6 $file_name = 'graphs.log';
7 $file_link = 'figure_graphs.jpg';
8 //$link_capacity = 100000000; //Mb/s
9 $output = shell_exec('rm -rf log_graph/*.log ');
10 #$time_post='10000000';
11 $data=$bdd->query("SELECT src_switch, dst_switch, tx_bw, rx_bw, object_index FRO M topology, port_counters WHERE topology.src_switch = port_counters.switch_dpid AND port_counters.time > DATE_SUB(NOW(), INTERVAL ".$time_post." MINUTE) AND src _switch < dst_switch ORDER BY port_counters.object_index");
12 //print_r($data->errorInfo());
13 $histo_rx =[];
14 $histo_tx = [];
15 $counter = [];
16 $bandwidth = [];
17 $histo_sum=[];
18 //init table
19 while ($link = $data->fetch()) {
20 $time = $link['object_index'];
21 # $histo_rx[$time] = 0;
22 # $histo_tx[$time] = 0;
23 $counter [$time] = 0;
24 $bandwidth[$time] = 0;
25 $histo_sum[$time]=0;
26 }
27 $data2=$bdd->query("SELECT src_switch, dst_switch, tx_bw, rx_bw, object_index, b andwidth FROM topology, port_counters WHERE topology.src_switch = port_counters. switch_dpid AND port_counters.time > DATE_SUB(NOW(), INTERVAL ".$time_post." MIN UTE) AND src_switch < dst_switch ORDER BY port_counters.object_index");
28
29 while ($link2 = $data2->fetch()) {
30 # echo gettype($link2['rx_bw']);
31 ········
32 $time = $link2['object_index'];
33 # $histo_rx[$time] += intval($link2['rx_bw']);
34 # $histo_tx[$time] += intval($link2['tx_bw']);
35 $histo_sum[$time] = $histo_sum[$time]+ intval($link2['rx_bw']) + intval( $link2['tx_bw']);
36 $counter [$time] += 2;
37 $bandwidth[$time] = intval($link2['bandwidth']);
38 # echo "object: ". $time;
39 # echo " rx: ". $link2['rx_bw'] . " tx: ". $link2['tx_bw'] . " sum: " . $ histo_sum[$time] ."\n";
40
41 }
42 #print_r($histo_sum);
43 #echo "\n";
44 #print_r($counter);
45 #echo "\n";
46 #print_r($bandwidth);
47 ·
48 $column_header = "object_index". " " . "Average_received_bandwidth" . "\n";
49 file_put_contents('log_graph/'. $file_name, $column_header, FILE_APPEND );··············
50
51 foreach($histo_sum as $key => $value) {
52 ········
53 $link_utilization = $key . " " . strval($value / ($counter[$key]* $bandwidth[$ key]))."\n";
54 file_put_contents('log_graph/'. $file_name, $link_utilization, FILE_APPEND );··············
55
56 }
57 shell_exec("gnuplot utils/graphs.plt");
58 echo "<img src=\"img/".$file_link. "\">";
59
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b