Source
* Calculate which items retrieved using the primary filter matches selected subfilter options. Results are added to
<?php declare(strict_types = 0);
/*
** 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/>.
**/
/**
* Common methods for "charts.view" and "charts.view.json" actions.
*/
abstract class CControllerCharts extends CController {
// Number of subfilter values per row.
const SUBFILTERS_VALUES_PER_ROW = 100;
// Number of tag value rows allowed to be included in subfilter.
const SUBFILTERS_TAG_VALUE_ROWS = 20;
/**
* Fetches all host graphs based on hostid and graph name or item name used in graph.
*
* @param array $hostids Limit returned graphs to these hosts.
* @param string $name Graphs or items in them should contain this string in their name.
*
* @return array
*/
protected function getHostGraphs(array $hostids, string $name): array {
$graphs = API::Graph()->get([
'output' => ['graphid', 'name'],
'hostids' => $hostids,
'search' => $name !== '' ? ['name' => $name] : null,
'selectItems' => ['itemid'],
'preservekeys' => true
]);
$graph_items = [];
foreach ($graphs as $graph) {
foreach ($graph['items'] as $item) {
$graph_items[$item['itemid']] = $item;
}
}
$filter_items = [];
if ($name !== '') {
$filter_items = API::Item()->get([
'output' => ['itemid'],
'hostids' => $hostids,
'search' => ['name_resolved' => $name],
'preservekeys' => true
]);
if ($filter_items) {
$graphs += API::Graph()->get([
'output' => ['graphid', 'name'],
'hostids' => $hostids,