Source
xxxxxxxxxx
<?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/>.
**/
/**
* Base controller for the "Monitoring->Problems" page and the "Problems" asynchronous requests.
*/
abstract class CControllerProblem extends CController {
// Filter idx prefix.
const FILTER_IDX = 'web.monitoring.problem';
// Filter fields default values.
const FILTER_FIELDS_DEFAULT = [
'show' => TRIGGERS_OPTION_RECENT_PROBLEM,
'groupids' => [],
'hostids' => [],
'triggerids' => [],
'name' => '',
'severities' => [],
'age_state' => 0,
'age' => 14,
'inventory' => [],
'evaltype' => TAG_EVAL_TYPE_AND_OR,
'tags' => [],
'show_tags' => SHOW_TAGS_3,
'show_symptoms' => 0,
'show_suppressed' => 0,
'acknowledgement_status' => ZBX_ACK_STATUS_ALL,
'acknowledged_by_me' => 0,
'compact_view' => 0,
'show_timeline' => ZBX_TIMELINE_ON,
'details' => 0,
'highlight_row' => 0,
'show_opdata' => OPERATIONAL_DATA_SHOW_NONE,
'tag_name_format' => TAG_NAME_FULL,
'tag_priority' => '',
'page' => null,
'sort' => 'clock',
'sortorder' => ZBX_SORT_DOWN,
'from' => '',
'to' => ''
];
/**
* Get count of resulting rows for specified filter.
*
* @param array $filter Filter fields values.
*
* @return int
*/
protected function getCount(array $filter): int {
$range_time_parser = new CRangeTimeParser();
$range_time_parser->parse($filter['from']);
$filter['from'] = $range_time_parser->getDateTime(true)->getTimestamp();
$range_time_parser->parse($filter['to']);
$filter['to'] = $range_time_parser->getDateTime(false)->getTimestamp();
$data = CScreenProblem::getData($filter, CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT));
return count($data['problems']);
}
/**
* Get additional data required for render filter as HTML.
*
* @param array $filter Filter fields values.
*
* @return array
*/
protected function getAdditionalData(array $filter): array {
$data = [
'groups' => [],
'hosts' => [],
'triggers' => []
];
// Host groups multiselect.
if ($filter['groupids']) {