Changeset 129 for www/statistic/index.php
- Timestamp:
- Jan 5, 2009, 7:31:45 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/statistic/index.php
r1 r129 1 <? 2 session_start(); 3 include_once('../style.php'); 4 //$refresh = 60; 5 ShowHeader('Èasové záznamy','Statistika'); 6 include_once('../is/db.php'); 7 DB_Init('localhost','root','','statistic'); 8 9 // Preload measure table 10 DB_Select('stat_measure', '*'); 11 while($Row = DB_Row()) $Measures[$Row['name']] = $Row; 12 13 $GrafTimeRanges = array( 14 'hour' => array( 15 'caption' => 'Hodina', 16 'seconds' => 60*60, 17 ), 18 'day' => array( 19 'caption' => 'Den', 20 'seconds' => 24*60*60, 21 ), 22 'week' => array( 23 'caption' => 'Týden', 24 'seconds' => 7*24*60*60, 25 ), 26 'month' => array( 27 'caption' => 'Mìsíc', 28 'seconds' => 30*24*60*60, 29 ), 30 'year' => array( 31 'caption' => 'Rok', 32 'seconds' => 12*30*24*60*60, 33 ), 34 'years' => array( 35 'caption' => 'Roky', 36 'seconds' => 3*12*30*24*60*60, 37 ), 38 ); 39 40 $Perioda = 'day'; 41 if(array_key_exists('period',$_SESSION)) $Perioda = $_SESSION['period']; 42 if(array_key_exists('period',$_GET)) $Perioda = $_GET['period']; 43 if(!array_key_exists($Perioda, $GrafTimeRanges)) $Perioda = 'day'; 44 $_SESSION['period'] = $Perioda; 45 46 $MeasureName = 'inet'; 47 if(array_key_exists('measure', $_SESSION)) $MeasureName = $_SESSION['measure']; 48 if(array_key_exists('measure', $_GET)) $MeasureName = $_GET['measure']; 49 if(!array_key_exists($MeasureName, $Measures)) $MeasureName = 'inet_down'; 50 $_SESSION['measure'] = $MeasureName; 51 52 // Show graf time range menu 53 echo('Èasový úsek: '); 54 foreach($GrafTimeRanges as $Index => $Item) 55 echo('<a href="?period='.$Index.'">'.$Item['caption'].'</a> '); 56 57 // Show graf type menu 58 echo('<br>Výbìr záznamu: '); 59 foreach($Measures as $Item) 60 echo('<a href="?measure='.$Item['name'].'">'.$Item['description'].'</a> '); 61 62 // Insert graf 63 echo('<br><br>'.$Measures[$MeasureName]['description'].' za poslední '.strtolower($GrafTimeRanges[$Perioda]['caption']).':<br>'); 64 echo('<img alt="Graf '.strtolower($Measures[$MeasureName]['description']).' za poslední '.strtolower($GrafTimeRanges[$Perioda]['caption']).'"'. 65 'src="graph.php?measure='.$Measures[$MeasureName]['name'].'&from='.(time() - $GrafTimeRanges[$Perioda]['seconds']).'&to='.time().'" width="750" height="214"><br>'); 66 67 echo('<span style="color: #ffb4b4">Maximálnì</span> '); 68 echo('<span style="color: #7878ff">Prùmìrnì</span>'); 69 echo('<br><br>'); 70 71 flush(); 72 // Online status check 73 if(($MeasureName == 'inet') or ($MeasureName == 'inet_down') or ($MeasureName == 'inet_up')) 74 { 75 echo('Stav: '); 76 $Output = array(); 77 $Online = 0; 78 exec('ping 195.47.235.3 -c 1 | grep received', $Output); 79 if(count($Output) == 1) 80 { 81 $Output = explode(" ",$Output[0]); 82 if($Output[3]=='1') $Online = 1; 83 } 84 // exec('ifconfig | grep ppp0',$Output); 85 //$Online = count($Output); 86 if($Online == 1) echo('<font style="color: green; font-weight: bold;">ONLINE</font>'); else echo('<font style="color: red; font-weight: bold;">OFFLINE</font>'); 87 88 echo('<br>'); 89 90 $EndTime = time(); 91 $StartTime = $EndTime - $GrafTimeRanges[$Perioda]['seconds']; 92 DB_Select('traffic', 'sum(inet_down),sum(inet_up)', 'time>FROM_UNIXTIME('.$StartTime.') AND time<FROM_UNIXTIME('.$EndTime.')'); 93 $Row = DB_Row(); 94 echo('Za úsek sta¾eno: '.Round($Row[0]*60/1024/1024).' MB Za úsek odesláno: '.Round($Row[1]*60/1024/1024).' MB<br>'); 95 96 // Total downloaded and uploaded 97 DB_Query('select sum(inet_down),sum(inet_up) from traffic'); 98 $Row = DB_Row(); 99 echo('Celkem sta¾eno: '.Round($Row[0]*60/1024/1024).' MB Celkem odesláno: '.Round($Row[1]*60/1024/1024).' MB<br><br>'); 100 echo('<a href="bandwidth.php">Tabulka zatí¾ení linky podle poèítaèù</a><br>'); 101 echo('<a href="http://rychlost.cz/statistika/ip/">Mìøení rychlost pøipojení k internetu (rychlost.cz)</a><br>'); 102 103 } 104 /* 105 echo('Zatí¾ení internetu za posledních den<br>'); 106 echo('<img align="center" src="graf2.php?count=1440&size=60" width="100%" height="198"><br><br>'); 107 */ 108 109 //echo('Zatí¾ení internetu za poslední mìsíc<br>'); 110 //echo('<img align="center" src="graf.php?krok=9000" width="901" height="198"><br><br>'); 111 112 // Výpis selhání 113 /* 114 echo('<strong>15 posledních zachycených selhání:</strong><br>'); 115 echo('<table border="1" cellspacing="0" cellpadding="1"><tr><th>Èas</th><th>Pokus</th></tr>'); 116 DB_Query('select * from failure order by time desc limit 0,15'); 117 while($Row = DB_Row()) 118 { 119 echo('<tr><td>'.$Row['time'].'</td><td>'.($Row['attempt']+1).'</td></tr>'); 120 } 121 echo('</table><i>Poznámka: vytoèeno na první(1), druhý(2), tøetí(3) pokus, jinak restart(4)</i>'); 122 123 // echo('informace jsou aktualizovány ka¾dou minutu. stránku je nutno obnovovat.'); 124 */ 125 ShowFooter(); 1 <?php 126 2 ?>
Note:
See TracChangeset
for help on using the changeset viewer.