root/trunk/web/perf/menulive.php @ 126

Revision 126, 4.0 KB (checked in by andreu, 12 years ago)

New PHP script used in crontab to generate graphics posted on the self-monitoring web site

Line 
1<?php
2
3print "        <div id=\"menuV\"> \n";
4print "         <ul class=\"n1\"> \n";
5print "          <li class=\"withsub\"><a href=\"index.php?section=perf\">Perf</a> \n";
6print "           <ul class=\"n2\"> \n";
7print "            <li><a href=\"index.php?section=perfcol\">Collector</a> </li> \n";
8print "            <li><a href=\"index.php?section=perfsys\">System</a> </li> \n";
9print "           </ul> \n";
10print "          </li> \n";
11print "          <li><a href=\"index.php?section=log\">Log</a></li> \n";
12print "          <li><a href=\"index.php?section=out\">Output</a></li> \n";
13print "          <li class=\"withsub\"><a href=\"index.php?section=tpl\">Templates</a>\n";
14print "           <ul class=\"n2\"> \n";
15/* ici recuperer les noms des routeurs dans fichier de conf et créer le menu en fonction */
16$finputRTR= fopen($ROUTERS_FILE,'r');
17$i=0;
18while (!feof ($finputRTR)) {
19  $line = fgets($finputRTR, 512);
20  $line_split = split(" ",$line);
21  if (sizeof($line_split) > 1) {
22    $RTR[$i] = $line_split[2];
23    $RTR_Name[$line_split[2]] = $line_split[1];
24    $RTRwoDot[$i] = str_replace(".","_",$line_split[2]);
25    $i++;
26  }
27 }
28fclose($finputRTR);
29$nb_rtr = $i;
30asort($RTR_Name,SORT_STRING);
31/* trois tableau : nb d'engine par routeurs, nb de template par Engine, nb de optional tpl par routeur */
32$i=0;
33$find = 0;
34$RouterEngineID = array();
35$finputTPL = fopen($TPL_DEF,'r');
36$TPLNumberTotal = 0;
37$OTPLNumberTotal = 0;
38while (!feof ($finputTPL)) {
39  $line = fgets($finputTPL, 512);
40  $line_split = split(" ",$line);
41  if ( $line_split[1] == "OpTId" ) {
42     $OTPLNumberTotal += 1;
43  }
44  if ( $line_split[1] == "TId" ) {
45    $TPLNumberTotal += 1;
46    $rtr_tmp = $line_split[0];
47    if ($RouterEngineID) {
48      foreach ($RouterEngineID as $k => $engines) {
49    if ($rtr_tmp == $k) {
50      foreach ($engines as $key => $value) {
51        if ( $value == $line_split[3]) {
52          $find = 1;
53        }
54      }
55    }
56      }
57    }
58    if ($find == 0) {
59      $RouterEngineNB[$rtr_tmp] += 1;
60      $indexE = $RouterEngineNB[$rtr_tmp];
61      $RouterEngineID[$rtr_tmp][$indexE] = $line_split[3];
62    }
63    $eng_tmp = $line_split[0]."_".$line_split[3];
64    $EngineTplNB[$eng_tmp] += 1;
65    $indexT = $EngineTplNB[$eng_tmp];
66    $sid = $line_split[3];
67    $RouterEngineTPID[$rtr_tmp][$sid][$indexT] = $line_split[2];
68    $tid = $line_split[2];
69    for ($it=0;$it<sizeof($line_split)-4;$it++) {
70      $RouterEngineTPDEF[$rtr_tmp][$sid][$tid][$it] = $line_split[$it+4];
71    }
72    $find = 0;
73  }
74 }
75fclose($finputTPL);
76
77/* onglets routeurs */
78foreach ($RTR_Name as $ipadd => $router_name) {
79  print "            <li class=\"withsub\"><a href=\"index.php?section=tpl&rtr=$RTRwoDot\">$router_name</a> \n";
80  print "             <ul class=\"n3\"> \n";
81  /*  print "$ipadd";  /* DEBUG */
82  $nb_engine = $RouterEngineNB[$ipadd];
83  for ($eng=1;$eng<=$nb_engine;$eng++){
84    $sourceID = $RouterEngineID[$ipadd][$eng];
85    print "              <li class=\"withsub\"><a href=\"index.php?section=tpl\">Engine ID $sourceID </a> \n";
86    print "               <ul class=\"n4\"> \n";
87    $mykey = $ipadd."_".$sourceID;
88    $TplNB $EngineTplNB[$mykey];
89    /*    print "tplNB $TplNB";  /* DEBUG */
90    for ($t=1;$t<=$TplNB;$t++) {
91      $tid2 = $RouterEngineTPID[$ipadd][$sourceID][$t];
92      $tkey = str_replace(".","_",$ipadd)."_".$sourceID."_".$tid2;
93      print "            <li><a href=\"index.php?section=tpl&tplkey=$tkey\">Tpl $tid2</a> </li> \n";
94      /*       for ($it=0;$it<sizeof($RouterEngineTPDEF[$ipadd][$sourceID][$tid2])-1;$it++) { /*   DEBUG */
95      /*    $tmp = $RouterEngineTPDEF[$ipadd][$sourceID][$tid2][$it]; /*  DEBUG */
96      /*    print " ($tmp) "; /*  DEBUG */
97      /*      } /* DEBUG */
98      /*      print " <br> "; /* DEBUG */
99    }
100    print "               </ul> \n";
101    print "              </li> \n";
102  }
103  print "             </ul> \n";
104  print "            </li> \n";
105}
106print "           </ul> \n";
107print "          </li> \n";
108print "          <li><a href=\"index.php?section=filters\">Filters</a></li> \n";
109print "         </ul> \n";
110print "        </div> \n";
111
112##$res = `cat $TPL_DEF | grep " TId " | wc -l | awk '{print $1}'`;
113
114?>
Note: See TracBrowser for help on using the browser.