Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <?php
- //gets the current traffic speed in kb/s
- $api_address = "http://127.0.0.1:3000/dumpTrafficData.html?language=xml&view=long";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $api_address);
- curl_setopt($ch, CURLOPT_PORT, "3000");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $curl = curl_exec($ch);
- curl_close($ch);
- $a = json_decode(json_encode((array) simplexml_load_string($curl)),1);
- $bps = $a['ntop-traffic-information']['device-information']['actualThpt'];
- $kbs = round($bps / 1024, 2);
- $percent = round(($kbs / 256) * 100);
- //build graphs
- $now = time();
- $before_10min = $now - 600;
- $before_60min = $now - 3600;
- $img_10 = "http://127.0.0.1:3000/plugins/rrdPlugin?action=arbreq&which=graph&arbfile=throughput&arbiface=eth0&arbip=&start=" . $before_10min . "&end=" . $now . "&counter=&title=Last+10+Minutes";
- $img_60 = "http://127.0.0.1:3000/plugins/rrdPlugin?action=arbreq&which=graph&arbfile=throughput&arbiface=eth0&arbip=&start=" . $before_60min . "&end=" . $now . "&counter=&title=Last+60+Minutes";
- //pings googles DNS server, checks to see if line quality is up
- $ping = shell_exec('ping -c 1 -w 1 8.8.8.8');
- $pre = explode("=", $ping);
- $ping_final = explode(" ms", $pre[3]);
- ?>
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <META HTTP-EQUIV=REFRESH CONTENT=60>
- <META HTTP-EQUIV=Pragma CONTENT=no-cache>
- <META HTTP-EQUIV=Cache-Control CONTENT=no-cache>
- <title>CompanyName - Network</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" type="text/css" href="asubtlebeige.css" />
- <style type="text/css">
- </style></head>
- <body>
- <div id="page">
- <div id="header">
- <div class="title">CompanyName - Network</div>
- <div class="subText">Status - Updated Every Minute</div>
- </div>
- <div id="bar">
- </div>
- <div id="pageContent">
- <div class="articleTitle">
- <?php
- if ($kbs == 0)
- {
- echo 'Currently the CompanyName network is using less than 10Kb/s</b>.<br \> That is under 2% of available bandwidth.';
- }
- else
- {
- echo 'Currently the CompanyName network is using <b>' . $kbs . 'Kb/s</b>.<br \> That is roughly <b>' . $percent . '</b>% of available bandwidth.';
- }
- if ($ping_final[0] == "")
- {
- echo "<br />NOTICE: Internet currently unreachable via CompanyName network.";
- }
- if ($kbs > 200 || $ping_final[0] > 100)
- {
- echo '<br />High outgoing network load is detected, expect slower speeds to the internet.';
- }
- ?>
- </div>
- </div>
- <div class="articleContent">
- <?php echo '<img class="displayed" src="' . $img_10 . '">'; ?><br \>
- <?php echo '<img class="displayed" src="' . $img_60 . '">'; ?><br \>
- </div>
- </div>
- </div>
- <div id="footer"><b>This page was last updated <?php echo shell_exec(date); ?></b><br />
- <?php
- echo "<br />";
- echo shell_exec(uptime);
- echo "<br />Full network stats available at http://127.0.0.1:3000/thptStats.html<br />";
- echo "Avg outgoing latency - " . $ping_final[0] . "ms";
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement