summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/ifstats.php
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2017-04-03 23:03:15 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2017-07-30 12:58:39 +0200
commitd3fd2bbe1861fc72318e7b1f5d26155bd0d4006b (patch)
tree7a97bbeadf003d753809b097087701e94950c269 /src/usr/local/www/ifstats.php
parent2f16265803cb925f0005f6fa3256cdb02751131c (diff)
downloadpfsense-d3fd2bbe1861fc72318e7b1f5d26155bd0d4006b.zip
pfsense-d3fd2bbe1861fc72318e7b1f5d26155bd0d4006b.tar.gz
traffic-graphs, optimize retrieval of data every x seconds to reduce spikes in the graphs and load on pfSense
also cleanup some old code.
Diffstat (limited to 'src/usr/local/www/ifstats.php')
-rw-r--r--src/usr/local/www/ifstats.php52
1 files changed, 6 insertions, 46 deletions
diff --git a/src/usr/local/www/ifstats.php b/src/usr/local/www/ifstats.php
index 671d5df..85d53af 100644
--- a/src/usr/local/www/ifstats.php
+++ b/src/usr/local/www/ifstats.php
@@ -29,25 +29,23 @@
$nocsrf = true;
require_once('auth_check.inc');
-require_once("interfaces.inc");
-
-//overload the use of this page until the conversion of both traffic graphs have been completed
if($_POST['if']) {
-
$ifs = $_POST['if'];
+ $realifs = $_POST['realif'];
$ifarray = explode("|", $ifs);
+ $realifarray = explode("|", $realifs);
$temp = gettimeofday();
$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
$obj = [];
$count = 0;
- foreach ($ifarray as $if) {
-
- $realif = get_real_interface($if);
-
+ $i = 0;
+ for ($i = 0; $i < count($ifarray); $i++) {
+ $if = $ifarray[$i];
+ $realif = $realifarray[$i];
if (!$realif) {
$realif = $if; // Need for IPsec case interface.
}
@@ -61,46 +59,8 @@ if($_POST['if']) {
$obj[$if][1]['key'] = $if . "out";
$obj[$if][1]['values'] = array($timing, $ifinfo['outbytes']);
-/*
- $obj[$count]['key'] = $if . "in";
- $obj[$count]['name'] = $if . " (in)";
- $obj[$count]['values'] = array($timing, $ifinfo['inbytes']);
-
- $count++;
-
- $obj[$count]['key'] = $if . "out";
- $obj[$count]['name'] = $if . " (out)";
- $obj[$count]['values'] = array($timing, $ifinfo['outbytes']);
-
- $count++;
-*/
}
header('Content-Type: application/json');
echo json_encode($obj,JSON_PRETTY_PRINT|JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_NUMERIC_CHECK);
-
-} else {
-
- $if = $_REQUEST['if'];
-
- $realif = get_real_interface($if);
-
- if (!$realif) {
- $realif = $if; // Need for IPsec case interface.
- }
-
- $ifinfo = pfSense_get_interface_stats($realif);
-
- $temp = gettimeofday();
- $timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
-
- header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
- header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
- header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP/1.1
- header("Pragma: no-cache"); // HTTP/1.0
-
- echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
-
}
-
-?>
OpenPOWER on IntegriCloud