Commit 26d16c6a authored by Franco Fichtner's avatar Franco Fichtner

inc: rewrote legacy_interface_stats()

Has the benefit of delivering a numer of additional statistics.
parent 81fb4259
......@@ -148,3 +148,25 @@ function legacy_vlan_tag($ifs, $member, $tag)
log_error('The command `' . $cmd . '\' failed to execute');
}
}
function legacy_interface_stats($ifs)
{
$cmd = '/usr/local/sbin/ifinfo ' . escapeshellarg($ifs);
$stats = array();
exec($cmd . ' 2>&1', $out, $ret);
if ($ret) {
log_error('The command `' . $cmd . '\' failed to execute');
return $stats;
}
/* first one is header */
array_shift($out);
foreach ($out as $line) {
$stat = explode(':', $line);
$stats[trim($stat[0])] = trim($stat[1]);
}
return $stats;
}
......@@ -961,21 +961,21 @@ function get_interface_info($ifdescr)
$chkif = $ifinfo['if'];
$ifinfotmp = pfSense_get_interface_addresses($chkif);
$ifinfo['status'] = $ifinfotmp['status'];
if (empty($ifinfo['status']))
$ifinfo['status'] = "down";
if (empty($ifinfo['status'])) {
$ifinfo['status'] = 'down';
}
$ifinfo['macaddr'] = $ifinfotmp['macaddr'];
$ifinfo['ipaddr'] = $ifinfotmp['ipaddr'];
$ifinfo['subnet'] = $ifinfotmp['subnet'];
$ifinfo['linklocal'] = get_interface_linklocal($ifdescr);
$ifinfo['ipaddrv6'] = get_interface_ipv6($ifdescr);
$ifinfo['subnetv6'] = get_interface_subnetv6($ifdescr);
if (isset($ifinfotmp['link0']))
$link0 = "down";
$ifinfotmp = pfSense_get_interface_stats($chkif);
// $ifinfo['inpkts'] = $ifinfotmp['inpkts'];
// $ifinfo['outpkts'] = $ifinfotmp['outpkts'];
$ifinfo['inerrs'] = $ifinfotmp['inerrs'];
$ifinfo['outerrs'] = $ifinfotmp['outerrs'];
if (isset($ifinfotmp['link0'])) {
$link0 = 'down';
}
$ifinfotmp = legacy_interface_stats($chkif);
$ifinfo['inerrs'] = $ifinfotmp['input errors'];
$ifinfo['outerrs'] = $ifinfotmp['output errors'];
$ifinfo['collisions'] = $ifinfotmp['collisions'];
/* Use pfctl for non wrapping 64 bit counters */
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2004-2006 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
......@@ -82,12 +83,6 @@ $width=200; //SVG internal width : do not modify
$fetch_link = "ifstats.php?if=" . htmlspecialchars($ifnum);
/* check for custom theme colors */
if(file_exists("/usr/local/www/themes/{$g['theme']}/graph.php")) {
$themetxt = file_get_contents("/usr/local/www/themes/{$g['theme']}/graph.php");
eval($themetxt);
}
/********* Graph DATA **************/
print('<?xml version="1.0" ?>' . "\n");?>
<svg width="100%" height="100%" viewBox="0 0 <?=$width?> <?=$height?>" preserveAspectRatio="none" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="init(evt)">
......
......@@ -37,7 +37,7 @@ if (!$realif) {
$realif = $if; // Need for IPSec case interface.
}
$ifinfo = pfSense_get_interface_stats($realif);
$ifinfo = legacy_interface_stats($realif);
$temp = gettimeofday();
$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
......@@ -48,4 +48,4 @@ header("Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", FALSE );
header("Pragma: no-cache"); // HTTP/1.0
echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
echo "$timing|" . $ifinfo['bytes received'] . "|" . $ifinfo['bytes transmitted'] . "\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment