diff options
author | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2021-01-06 16:02:16 +0300 |
---|---|---|
committer | Gregory Chalenko <gregory.chalenko@zabbix.com> | 2021-01-06 16:02:16 +0300 |
commit | bd1c2e4693dcd81afa6a0f29cad4057c527addd8 (patch) | |
tree | a9d76c33b2259c142d73e9a51a95dd61495922e9 /ui/app/controllers | |
parent | 141a6627039eb9da13a93509a419ac4a984a79e1 (diff) |
..F....... [ZBXNEXT-6311,ZBXNEXT-6314] changes in host availability widget
Diffstat (limited to 'ui/app/controllers')
-rw-r--r-- | ui/app/controllers/CControllerWidgetHostAvailView.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ui/app/controllers/CControllerWidgetHostAvailView.php b/ui/app/controllers/CControllerWidgetHostAvailView.php index 3defee59135..a7f05aabb16 100644 --- a/ui/app/controllers/CControllerWidgetHostAvailView.php +++ b/ui/app/controllers/CControllerWidgetHostAvailView.php @@ -58,18 +58,22 @@ class CControllerWidgetHostAvailView extends CControllerWidget { ? ['status' => HOST_STATUS_MONITORED, 'maintenance_status' => HOST_MAINTENANCE_STATUS_OFF] : ['status' => HOST_STATUS_MONITORED] ]); + $availability_priority = [INTERFACE_AVAILABLE_FALSE, INTERFACE_AVAILABLE_UNKNOWN, INTERFACE_AVAILABLE_TRUE]; foreach ($db_hosts as $host) { - $ignore_types = []; + $host_interfaces = array_fill_keys($interface_types, []); foreach ($host['interfaces'] as $interface) { - if (array_key_exists($interface['type'], $ignore_types)) { - continue; - } + $host_interfaces[$interface['type']][] = $interface['available']; + } + + $host_interfaces = array_filter($host_interfaces); - $ignore_types[$interface['type']] = 1; - $hosts_count[$interface['type']][$interface['available']]++; - $hosts_total[$interface['type']]++; + foreach ($host_interfaces as $type => $interfaces) { + $interfaces_availability = array_intersect($availability_priority, $interfaces); + $available = reset($interfaces_availability); + $hosts_count[$type][$available]++; + $hosts_total[$type]++; } } |