diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php index fdec19ef7..e1dacecd3 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php @@ -266,4 +266,32 @@ class InterfaceController extends ApiControllerBase return ['statistics' => $stats]; } + + /** + * retrieve statistics recorded by the memory management routines + * @return mixed + */ + public function getMemoryStatisticsAction() + { + return json_decode((new Backend())->configdRun('interface show memory'), true); + } + + /** + * retrieve bpf(4) peers statistics + * @return mixed + */ + public function getBpfStatisticsAction() + { + return json_decode((new Backend())->configdRun('interface show bpf'), true); + } + + /** + * retrieve netisr(9) statistics + * @return mixed + */ + public function getNetisrStatisticsAction() + { + return json_decode((new Backend())->configdRun('interface show netisr'), true); + } + } diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/InterfaceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/InterfaceController.php index a3249ca0d..b76b2ac6e 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/InterfaceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/InterfaceController.php @@ -67,6 +67,38 @@ class InterfaceController extends IndexController */ public function netstatAction() { + $this->view->tabs = [ + [ + "name" => "bpf", + "caption" => gettext("Bpf"), + "endpoint" => "/api/diagnostics/interface/getBpfStatistics" + ], + [ + "name" => "interfaces", + "caption" => gettext("Interfaces"), + "endpoint" => "/api/diagnostics/interface/getInterfaceStatistics" + ], + [ + "name" => "memory", + "caption" => gettext("Memory"), + "endpoint" => "/api/diagnostics/interface/getMemoryStatistics" + ], + [ + "name" => "netisr", + "caption" => gettext("Netisr"), + "endpoint" => "/api/diagnostics/interface/getNetisrStatistics" + ], + [ + "name" => "protocol", + "caption" => gettext("Protocol"), + "endpoint" => "/api/diagnostics/interface/getProtocolStatistics" + ], + [ + "name" => "sockets", + "caption" => gettext("Sockets"), + "endpoint" => "/api/diagnostics/interface/getSocketStatistics" + ] + ]; $this->view->pick('OPNsense/Diagnostics/netstat'); } } diff --git a/src/opnsense/mvc/app/views/OPNsense/Diagnostics/netstat.volt b/src/opnsense/mvc/app/views/OPNsense/Diagnostics/netstat.volt index c6a1a5b0d..7e887bc28 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Diagnostics/netstat.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Diagnostics/netstat.volt @@ -32,6 +32,8 @@ * https://mbraak.github.io/jqTree/#general */ function dict_to_tree(node, path) { + // some entries are lists, try use a name for the nodes in that case + let node_name_keys = ['name', 'interface-name']; let result = []; if ( path === undefined) { path = ""; @@ -44,8 +46,15 @@ } let item_path = path + key; if (node[key] instanceof Object) { + let node_name = key; + for (idx=0; idx < node_name_keys.length; ++idx) { + if (/^(0|[1-9]\d*)$/.test(node_name) && node[key][node_name_keys[idx]] !== undefined) { + node_name = node[key][node_name_keys[idx]]; + break; + } + } result.push({ - name: key, + name: node_name, id: item_path, children: dict_to_tree(node[key], item_path) }); @@ -126,54 +135,26 @@