root/trunk/web/data/datamatrix.php @ 141

Revision 141, 4.5 KB (checked in by andreu, 12 years ago)

Matrix in bytes in datamining section

RevLine 
[122]1<?php
2
3include ('get_param.php');
4
5print "<div id=\"contenu\">\n";
6
7print "<p> In this data mining section, you will find the matrix of traffic between the POP number defined in the following configuration files: </p>\n";
8print "<li>$subnet_list_file</li>\n";
9print "<li>$ROUTERS_FILE</li>\n";
10
11$CONFfinputSUB = fopen($subnet_list_file,'r');
12$IDR_hash = NULL;
13while (!feof ($CONFfinputSUB)) {
14  $CONFline = fgets($CONFfinputSUB, 512);
15  $CONFline_split = split("\t",$CONFline);
16  $CONFline_split2 = split("-",$CONFline_split[0]);
17  $IDR_hash[$CONFline_split2[1]] = 1;
18 }
19fclose($CONFfinputSUB);
20$IDR_hash[55] = 1;
21
22$CONFfinputRTR = fopen($router_list_file,'r');
23while (!feof ($CONFfinputRTR)) {
24  $CONFline = fgets($CONFfinputRTR, 512);
25  $CONFline_split = split(" ",$CONFline);
26  $CONFrouter_name[$CONFline_split[0]] =  $CONFline_split[1];
27 }
28fclose($CONFfinputRTR);
29
30print "<p> List of POPs included in the matrix: </p>";
31foreach ($IDR_hash as $keyIDR => $valueIDR) {
32  if ($keyIDR) {
33    $tmp = $CONFrouter_name[$keyIDR];
34    print "<li> $keyIDR ($tmp) </li>\n";
35  }
36}
37
38print "<p> The matrix: <br>";
39print "Debit (in Mb/s) in the last 5 minutes. </p>\n";
40$MATRIX_TABLE_INBUILT = "";
41$MATRIX_TABLE_INBUILT.= "<table class=\"fields\">\n";
42$MATRIX_TABLE_INBUILT.= "<tr> <th> </th>\n";
43foreach ($IDR_hash as $keyIDR => $valueIDR) {
44  if ($keyIDR) {
[123]45    $MATRIX_TABLE_INBUILT.= " <th>_$keyIDR _</th>\n";
[122]46  }
47}
48$MATRIX_TABLE_INBUILT.= "</tr>\n";
49
50$IDR_hash2 = $IDR_hash;
51foreach ($IDR_hash as $keyIDR => $valueIDR) {
52  if ($keyIDR) {
[123]53    $MATRIX_TABLE_INBUILT.= " <tr>  <th>_$keyIDR _</th> ";
[122]54    foreach ($IDR_hash2 as $keyIDR2 => $valueIDR2) {
55      ## get rrd file value
56      if ($keyIDR2) {
[123]57      $rrdfilename = $rrdmatrixpath.$CONF_MATRIX_RRD_LOCATION.$keyIDR."_".$keyIDR2.".rrd";
58      $res = `rrdtool fetch $rrdfilename -s -600 AVERAGE | grep -v nan | grep ":" `;
59      $ressplit = split(" ", $res);
60      ## FIXME *10
61      $bytes = number_format($ressplit[2]*10*8/300/1000000,0," "," ");
62      $MATRIX_TABLE_INBUILT.= " <td> ";
63    if ($keyIDR2 == $keyIDR) {
64      $MATRIX_TABLE_INBUILT.= " - ";
65    } else {
66      $MATRIX_TABLE_INBUILT.= "  <div id=\"tipbox\"> \n";
67      $MATRIX_TABLE_INBUILT.= "<a href=\"\"> $bytes </a>\n";
68      $MATRIX_TABLE_INBUILT.= "<div>\n";
69      $tmp2 = $CONFrouter_name[$keyIDR];
70      $tmp3 = $CONFrouter_name[$keyIDR2];
71      $MATRIX_TABLE_INBUILT.= " $tmp2 -> $tmp3 ";
72      $MATRIX_TABLE_INBUILT.= "</div>\n";
73      $MATRIX_TABLE_INBUILT.= "</div>\n";
74    }
75      $MATRIX_TABLE_INBUILT.= "</td> ";
[122]76      }
77    }
78    $MATRIX_TABLE_INBUILT.= " </tr> \n";
79  }
80}
81$MATRIX_TABLE_INBUILT.= "</table>\n";
82
83print "$MATRIX_TABLE_INBUILT";
84
[141]85
86print "<p> The matrix in quantity of bytes: <br>";
87print "Quantity (in TeraBytes) since last 31 days. </p>\n";
88$MATRIX_TABLE_INBUILT = "";
89$MATRIX_TABLE_INBUILT.= "<table class=\"fields\">\n";
90$MATRIX_TABLE_INBUILT.= "<tr> <th> </th>\n";
91foreach ($IDR_hash as $keyIDR => $valueIDR) {
92  if ($keyIDR) {
93    $MATRIX_TABLE_INBUILT.= " <th>_$keyIDR _</th>\n";
94  }
95}
96$MATRIX_TABLE_INBUILT.= "</tr>\n";
97
98$IDR_hash2 = $IDR_hash;
99foreach ($IDR_hash as $keyIDR => $valueIDR) {
100  if ($keyIDR) {
101    $MATRIX_TABLE_INBUILT.= " <tr>  <th>_$keyIDR _</th> ";
102    foreach ($IDR_hash2 as $keyIDR2 => $valueIDR2) {
103      ## get rrd file value
104      if ($keyIDR2) {
105                $rrdfilename = $rrdmatrixpath.$CONF_MATRIX_RRD_LOCATION.$keyIDR."_".$keyIDR2.".rrd";
106
107##              $res = `rrdtool fetch $rrdfilename -s -600 AVERAGE | grep -v nan | grep ":" `;
108##              $ressplit = split(" ", $res);
109              ## FIXME *10
110##                $bytes = number_format($ressplit[2]*10*8/300/1000000,0," "," ");
111
112                $samp = 10;
113                $myres = `rrdtool graph img_monitoring/toto.png -s -31D -A DEF:BytesG=$rrdfilename:Bytes:AVERAGE CDEF:input10=BytesG,8,*,5,/,60,/,$samp,* CDEF:BytesSec=BytesG,300,/,$samp,* VDEF:TOTIN=BytesSec,TOTAL AREA:input10\#8FA3AD:"b" PRINT:TOTIN:";%1lg" | grep ";" `;
114                $ressplit=split(";",$myres);
115                $bytes=number_format($ressplit[1]/1000000000000,0," "," ");
116
117      $MATRIX_TABLE_INBUILT.= " <td> ";
118    if ($keyIDR2 == $keyIDR) {
119      $MATRIX_TABLE_INBUILT.= " - ";
120    } else {
121      $MATRIX_TABLE_INBUILT.= "  <div id=\"tipbox\"> \n";
122      $MATRIX_TABLE_INBUILT.= "<a href=\"\"> $bytes </a>\n";
123      $MATRIX_TABLE_INBUILT.= "<div>\n";
124      $tmp2 = $CONFrouter_name[$keyIDR];
125      $tmp3 = $CONFrouter_name[$keyIDR2];
126      $MATRIX_TABLE_INBUILT.= " $tmp2 -> $tmp3 ";
127      $MATRIX_TABLE_INBUILT.= "</div>\n";
128      $MATRIX_TABLE_INBUILT.= "</div>\n";
129    }
130      $MATRIX_TABLE_INBUILT.= "</td> ";
131      }
132    }
133    $MATRIX_TABLE_INBUILT.= " </tr> \n";
134  }
135}
136$MATRIX_TABLE_INBUILT.= "</table>\n";
137
138print "$MATRIX_TABLE_INBUILT";
139
[122]140print "</div>\n";
141
[141]142?>
Note: See TracBrowser for help on using the browser.