%PDF- %PDF-
Direktori : /var/www/rrdrouter/ |
Current File : //var/www/rrdrouter/index.php |
<?php $ifaces = array( "vlan1" => "LAN", "vlan2" => "WAN", "ath0" => "ATH0 wireless network", // "ath0.1" => "ATH0.1 wireless network", "ath1" => "ATH1 wireless network", "eth0" => "ETH0 local wired", "br0" => "local bridge", "tun1" => "OpenVPN" ); $header = isset($_GET['trend']) ? $_GET['trend'] : "summary"; $gt = array( "day" => "Daily Graph (5 minute averages)", "week" => "Weekly Graph (30 minute averages)", "month" => "Monthly Graph (2 hour averages)", "year" => "Yearly Graph (12 hour averages)", ); $data = json_decode(file_get_contents("/var/lib/rrd/routerstats.json")); //print_r($data); function fsize($size) { $jedn = array("bytes", "Kbytes", "Mbytes", "Gbytes", "Tbytes", "Pbytes"); //$size = filesize($name); $i = 0; while($size > 1023) { $size /= 1024; $i++; } return sprintf("%0.2f %s", $size, $jedn[$i]); } ?> <html> <head> <TITLE>127.0.0.1 network traffic :: <?php echo $header; ?></TITLE> <META HTTP-EQUIV="Refresh" CONTENT="300"> <META HTTP-EQUIV="Cache-Control" content="no-cache"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <!-- <link rel="stylesheet" href="https://cdn.varak.net/css/jquery-ui.css"> <link rel="stylesheet" href="https://cdn.varak.net/css/jquery.dataTables.css"> <link rel="stylesheet" href="https://cdn.varak.net/css/jquery.datatables.bootstrap.css"> --> <link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/themes/start/jquery-ui.css"> <link rel="stylesheet" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"> <style> body { font-family: Verdana, Tahoma, Arial, Helvetica; font-size: 9pt } .header { font-size: 16pt; font-weight: 900; } </style> <script src="https://cdn.varak.net/js/jquery.min.js"></script> <script src="https://cdn.varak.net/js/jquery-ui.min.js"></script> <script src="https://cdn.varak.net/js/jquery.dataTables.min.js"></script> <!-- <script src=""></script> <script src=""></script> <script src=""></script> <script src=""></script> --> <script type="text/javascript"> $(document).ready(function () { var dtopts = { "bPaginate": true, "bLengthChange": false, "bFilter": true, "bSort": true, "bInfo": true, "bAutoWidth": true, "pageLength": 25, /*"oLanguage": { "sLengthMenu": "Zobraz _MENU_ z�znamu na str�nku", "sZeroRecords": "Omlouv�me se, ale nic nebylo nalezeno", "sInfo": "Zobrazuji _START_ a� _END_ z _TOTAL_ z�znamu", "sInfoEmpty": "Zobrazuji 0 a� 0 z 0 z�znamu", "sInfoFiltered": "(Filtrov�no z _MAX_ celkov�ch z�znamu)" },*/ "aaSorting": [[ 4, "desc" ]]/*, "asSorting": [[ 4, "desc" ]] */ }; //$('#maintbl').dataTable(dtopts); <?php foreach($ifaces as $key => $val) { echo '$("#stats-' . str_replace(".", "-", $key) . '").dataTable(dtopts);' . "\n"; } ?> }); </script> </head> <body bgcolor="#ffffff" topMargin='5'> <span class='header'>127.0.0.1 network traffic :: <?php echo $header; ?></span> <br><br> <?php if(isset($_GET['trend'])) { foreach($gt as $key => $val) { ?> <?php echo $val; ?> <br> <img src='<?php echo $_GET['trend']."-".$key; ?>.png'> <br> <?php } } else { ?> Daily Graphs (5 minute averages)<br> <?php foreach($ifaces as $key => $val) { ?> <h2>Graph for <?php echo $val; ?></h2> <h4>Today's traffic: In: <?php echo fsize($data->{$key}->{date('Y-m-d')}->receive); ?>, Out: <?php echo fsize($data->{$key}->{date('Y-m-d')}->transmit); ?></h4> <a href='?trend=<?php echo $key; ?>'> <img src='<?php echo $key; ?>-day.png' border='1'> </a> <?php } } ?> <br> <hr> <br> <?php foreach($data as $iname => $ifc) { if(!isset($ifaces[$iname])) continue; ?><div style="max-width: 960px; margin: auto;"> <h2><?php echo $ifaces[$iname]; ?></h2> <table width="100%" border="1" id="stats-<?php echo str_replace(".", "-", $iname); ?>"> <thead> <tr> <th>Date</th> <th>Transmit</th> <th>Receive</th> </tr> <tr> <td><b>Total</b></td> <td><?php echo fsize($ifc->transmit); ?></td> <td><?php echo fsize($ifc->receive); ?></td> </tr> </thead> <tbody> <?php foreach($ifc as $key => $date) { if(!strstr($key, "2016-") && !strstr($key, "2017-") && !strstr($key, "2018-") && !strstr($key, "2019-") && !strstr($key, "2020-") && !strstr($key, "2021-") && !strstr($key, "2022-") && !strstr($key, "2023-") && !strstr($key, "2024-") && !strstr($key, "2025-")) continue; ?><tr> <td><b><?php echo $key; ?></b></td> <td data-order="<?php echo sprintf("%020d", $date->transmit); ?>"><?php echo fsize($date->transmit); ?></td> <td data-order="<?php echo sprintf("%020d", $date->receive); ?>"><?php echo fsize($date->receive); ?></td> </tr><?php }?> </tbody> </table></div> <?php } ?> <br> <hr> <br> <pre><?php echo file_get_contents("/tmp/routerifc.txt"); ?></pre> <a href='https://oss.oetiker.ch/rrdtool/'> <img src='https://oss.oetiker.ch/rrdtool/inc/rrdtool-logo-light.png' border='0'></a> </body> </html>