diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php index c2cbc6959..540547bb0 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php @@ -60,7 +60,7 @@ class AliasController extends ApiMutableModelControllerBase } return $this->searchBase( "aliases.alias", - array('enabled', 'name', 'description', 'type', 'content'), + array('enabled', 'name', 'description', 'type', 'content', 'current_items', 'last_updated'), "name", $filter_funct ); diff --git a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasField.php b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasField.php index c56c1b42a..f229c5ba6 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasField.php @@ -31,6 +31,10 @@ namespace OPNsense\Firewall\FieldTypes; use OPNsense\Base\FieldTypes\ArrayField; +use OPNsense\Base\FieldTypes\TextField; +use OPNsense\Base\FieldTypes\IntegerField; +use OPNsense\Core\Backend; + class AliasField extends ArrayField { @@ -65,6 +69,33 @@ class AliasField extends ArrayField ] ]; + private static $current_stats = null; + + protected function actionPostLoadingEvent() + { + if (self::$current_stats === null) { + self::$current_stats = []; + $stats = json_decode((new Backend())->configdRun('filter diag table_size'), true); + if (!empty($stats) && !empty($stats['details'])) { + self::$current_stats = $stats['details']; + } + } + foreach ($this->internalChildnodes as $node) { + if (!$node->getInternalIsVirtual()) { + // generate new unattached fields, which are only usable to read data from (not synched to config.xml) + $current_items = new IntegerField(); + $last_updated = new TextField(); + if (!empty((string)$node->name) && !empty(self::$current_stats[(string)$node->name])) { + $current_items->setValue(self::$current_stats[(string)$node->name]['count']); + $last_updated->setValue(self::$current_stats[(string)$node->name]['updated']); + } + $node->addChildNode('current_items', $current_items); + $node->addChildNode('last_updated', $last_updated); + } + } + return parent::actionPostLoadingEvent(); + } + /** * create virtual alias nodes */ diff --git a/src/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt b/src/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt index 0af3bf3bc..9cf7a5846 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt @@ -513,6 +513,8 @@