Source
// It's required to set time selector only for pages with classic graph widgets, SVG graphs have period set in config.
<?php
/*
** Zabbix
** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__) . '/../../include/CWebTest.php';
/**
* @backup profiles
*
* @onBefore prepareGraphData
*/
class testDataDisplayInGraphs extends CWebTest {
protected static $hostid;
protected static $itemids;
protected static $dashboardid;
const TIMESTAMPS = [
'history' => [
'from' => '2023-10-07 12:58:00',
'to' => '2023-10-07 13:20:00'
],
'trends' => [
'from' => '2023-10-03 00:00:00',
'to' => '2023-10-07 12:00:00'
],
'pie' => [
'from' => 'now-1h',
'to' => 'now'
]
];
public static function prepareGraphData() {
$host_responce = CDataHelper::createHosts([
[
'host' => 'Host for data display on graphs',
'interfaces' => [
[
'type' => INTERFACE_TYPE_AGENT,
'main' => 1,
'useip' => 1,
'ip' => '127.0.0.1',
'dns' => '',
'port' => 10051
]
],
'groups' => [
'groupid' => 4 // Host group "Zabbix servers".
],
'status' => HOST_STATUS_MONITORED,
'items' => [
[
'name' => 'Item for history data display 1',
'key_' => 'item_key_1',
'type' => ITEM_TYPE_ZABBIX,
'value_type' => ITEM_VALUE_TYPE_FLOAT,
'delay' => '1m',
'history' => '9125d',
'trends' => 0
],
[
'name' => 'Item for history data display 2',
'key_' => 'item_key_2',
'type' => ITEM_TYPE_ZABBIX,
'value_type' => ITEM_VALUE_TYPE_FLOAT,
'delay' => '1m',
'history' => '9125d',
'trends' => 0
],
[
'name' => 'Item for trends data display 1',
'key_' => 'item_key_3',
'type' => ITEM_TYPE_ZABBIX,
'value_type' => ITEM_VALUE_TYPE_FLOAT,