diff options
author | Phil Davis <phil@jankaritech.com> | 2017-04-29 21:02:37 +0545 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-05-03 09:26:22 -0300 |
commit | e639325a7c96a3a90c53a2dc58f64f0df574b197 (patch) | |
tree | 4c87e5e36df0b457f7279054ff8ebff432281ffb /src/usr/local/www/widgets | |
parent | 14c6cfa0ba499c695d7da58e22cb2215541bddea (diff) | |
download | pfsense-e639325a7c96a3a90c53a2dc58f64f0df574b197.zip pfsense-e639325a7c96a3a90c53a2dc58f64f0df574b197.tar.gz |
Fix interface down in interface statistics widget
If an interface is down, the widget would write the interface description in a column heading but then omit the stats items. So later columns (to the right) would have the headings and stats items out of line.
This also fixes the performance problem that get_interface_info($ifdescr) was being called for every row of stats data for every interface. i.e. it was called 7 times for each interface when 1 time is enough.
(cherry picked from commit d87a9a1c9720f2093b57979d1b0f1e69e38750af)
Diffstat (limited to 'src/usr/local/www/widgets')
-rw-r--r-- | src/usr/local/www/widgets/widgets/interface_statistics.widget.php | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php index 1c87c5f..0ea20bb 100644 --- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -88,9 +88,16 @@ if ($_REQUEST && $_REQUEST['ajax']) { print( "<th></th>"); foreach ($ifdescrs as $ifdescr => $ifname) { - if (!in_array($ifdescr, $skipinterfaces)) { - print( "<th>" . $ifname . "</th>"); - $interface_is_displayed = true; + if (in_array($ifdescr, $skipinterfaces)) { + continue; + } + + $interface_is_displayed = true; + $ifinfo_arr[$ifdescr] = get_interface_info($ifdescr); + $ifinfo_arr[$ifdescr]['inbytes'] = format_bytes($ifinfo_arr[$ifdescr]['inbytes']); + $ifinfo_arr[$ifdescr]['outbytes'] = format_bytes($ifinfo_arr[$ifdescr]['outbytes']); + if ($ifinfo_arr[$ifdescr]['status'] != "down") { + print("<th>" . $ifname . "</th>"); } } @@ -111,16 +118,10 @@ if ($_REQUEST && $_REQUEST['ajax']) { continue; } - $ifinfo = get_interface_info($ifdescr); - - if ($ifinfo['status'] == "down") { - continue; + if ($ifinfo_arr[$ifdescr]['status'] != "down") { + print("<td>" . (isset($ifinfo_arr[$ifdescr][$key]) ? htmlspecialchars($ifinfo_arr[$ifdescr][$key]) : 'n/a') . "</td>"); } - $ifinfo['inbytes'] = format_bytes($ifinfo['inbytes']); - $ifinfo['outbytes'] = format_bytes($ifinfo['outbytes']); - - print("<td>" . (isset($ifinfo[$key]) ? htmlspecialchars($ifinfo[$key]) : 'n/a') . "</td>"); } print( "</tr>"); |