Source
xxxxxxxxxx
// #7 Update the widget to display host availability for all interfaces including hosts in maintenance. Layout = Vertical
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../common/testWidgets.php';
/**
* @backup profiles
*/
class testDashboardHostAvailabilityWidget extends testWidgets {
/*
* SQL query to get widget and widget_field tables to compare hash values, but without widget_fieldid
* because it can change.
*/
private $sql = 'SELECT wf.widgetid, wf.type, wf.name, wf.value_int, wf.value_str, wf.value_groupid, wf.value_hostid,'.
' wf.value_itemid, wf.value_graphid, wf.value_sysmapid, w.widgetid, w.dashboard_pageid, w.type, w.name, w.x, w.y,'.
' w.width, w.height'.
' FROM widget_field wf'.
' INNER JOIN widget w'.
' ON w.widgetid=wf.widgetid ORDER BY wf.widgetid, wf.name, wf.value_int, wf.value_str, wf.value_groupid,'.
' wf.value_itemid, wf.value_graphid';
public static function getCreateWidgetData() {
return [
// #0 Create a Host availability widget with default values.
[
[
'fields' => [
'Type' => 'Host availability'
]
]
],
// #1 Create a Host availability widget with default values for Zabbix agent interface.
[
[
'fields' => [
'Type' => 'Host availability',
'Name' => 'Single interface widget - default',
'Interface type' => 'Zabbix agent (passive checks)'
]
]
],
// #2 Create a Host availability widget for Zabbix agent interface specifying every parameter.
[
[
'fields' => [
'Type' => 'Host availability',
'Name' => 'Include hosts in maintenance',
'Refresh interval' => '1 minute',
'Host groups' => ['Group for Host availability widget', 'Group in maintenance for Host availability widget'],
'Interface type' => 'Zabbix agent (passive checks)',
'Include hosts in maintenance' => true
],
'expected_values' => [
'Total' => '6',
'Available' => '2',
'Not available' => '2',
'Unknown' => '2',
'Mixed' => '0'
]
]
],
// #3 Create the same widget as previous one, but with 'Include hosts in maintenance' = false.
[
[
'fields' => [
'Type' => 'Host availability',
'Name' => 'Dont include hosts in maintenance',
'Refresh interval' => '10 minutes',
'Host groups' => ['Group for Host availability widget', 'Group in maintenance for Host availability widget'],
'Interface type' => 'Zabbix agent (passive checks)',
'Include hosts in maintenance' => false
],
'expected_values' => [
'Total' => '3',
'Available' => '1',
'Not available' => '1',
'Unknown' => '1',