Source
* undergoing a rank change, return symptom event icon. Icon can be displayed regardless if current status is in closing.
<?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/>.
**/
/**
* Returns all supported event source-object pairs.
*/
function eventSourceObjects(): array {
return [
['source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER],
['source' => EVENT_SOURCE_DISCOVERY, 'object' => EVENT_OBJECT_DHOST],
['source' => EVENT_SOURCE_DISCOVERY, 'object' => EVENT_OBJECT_DSERVICE],
['source' => EVENT_SOURCE_AUTOREGISTRATION, 'object' => EVENT_OBJECT_AUTOREGHOST],
['source' => EVENT_SOURCE_INTERNAL, 'object' => EVENT_OBJECT_TRIGGER],
['source' => EVENT_SOURCE_INTERNAL, 'object' => EVENT_OBJECT_ITEM],
['source' => EVENT_SOURCE_INTERNAL, 'object' => EVENT_OBJECT_LLDRULE],
['source' => EVENT_SOURCE_SERVICE, 'object' => EVENT_OBJECT_SERVICE]
];
}
function get_events_unacknowledged($db_element, $value_trigger = null, $value_event = null, $ack = false) {
$elements = ['hosts' => [], 'hosts_groups' => [], 'triggers' => []];
get_map_elements($db_element, $elements);
if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) {
return 0;
}
$options = [
'output' => ['triggerid'],
'monitored' => 1,
'skipDependent' => 1,
'limit' => CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT) + 1
];
if (!is_null($value_trigger)) {
$options['filter'] = ['value' => $value_trigger];
}
if (!empty($elements['hosts_groups'])) {
$options['groupids'] = array_unique($elements['hosts_groups']);
}
if (!empty($elements['hosts'])) {
$options['hostids'] = array_unique($elements['hosts']);
}
if (!empty($elements['triggers'])) {
$options['triggerids'] = array_unique($elements['triggers']);
}
$triggerids = API::Trigger()->get($options);
return API::Event()->get([
'source' => EVENT_SOURCE_TRIGGERS,
'object' => EVENT_OBJECT_TRIGGER,
'countOutput' => true,
'objectids' => zbx_objectValues($triggerids, 'triggerid'),
'filter' => [
'value' => $value_event,
'acknowledged' => $ack ? 1 : 0
]
]);
}
/**
*
* @param array $event An array of event data.
* @param string $event['eventid'] Event ID.
* @param string $event['r_eventid'] OK event ID.
* @param string $event['cause_eventid'] Cause event ID.
* @param string $event['correlationid'] OK Event correlation ID.
* @param string $event['userid'] User ID who generated the OK event.
* @param string $event['name'] Event name.
* @param string $event['acknowledged'] State of acknowledgement.
* @param CCOl $event['opdata'] Operational data with expanded macros.
* @param string $event['comments'] Trigger description with expanded macros.
* @param array $allowed An array of user role rules.
* @param bool $allowed['ui_correlation'] Whether user is allowed to visit event correlation page.
*
* @return CTableInfo
*/
function make_event_details(array $event, array $allowed) {
$is_acknowledged = ($event['acknowledged'] == EVENT_ACKNOWLEDGED);