Source
int zbx_event_db_count_from_trigger(zbx_uint64_t triggerid, char **replace_to, int problem_only, int acknowledged)
/*
** 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/>.
**/
/* number of selected IPMI-related fields in function */
/* zbx_event_db_get_host() */
int zbx_event_db_get_host(const zbx_db_event *event, zbx_dc_host_t *host, char *error, size_t max_error_len)
{
zbx_db_result_t result;
zbx_db_row_t row;
char sql[512]; /* do not forget to adjust size if SQLs change */
size_t offset;
int ret = SUCCEED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
offset = zbx_snprintf(sql, sizeof(sql), "select distinct h.hostid,h.proxyid,h.host,h.tls_connect");
offset += zbx_snprintf(sql + offset, sizeof(sql) - offset,
/* do not forget to update ZBX_IPMI_FIELDS_NUM if number of selected IPMI fields changes */
",h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password");
offset += zbx_snprintf(sql + offset, sizeof(sql) - offset,
",h.tls_issuer,h.tls_subject,h.tls_psk_identity,h.tls_psk,h.monitored_by,hp.proxyid");
switch (event->source)
{
case EVENT_SOURCE_TRIGGERS:
zbx_snprintf(sql + offset, sizeof(sql) - offset,
" from functions f,items i,hosts h"
" left join host_proxy hp on h.hostid=hp.hostid"
" where f.itemid=i.itemid"
" and i.hostid=h.hostid"
" and h.status=%d"
" and f.triggerid=" ZBX_FS_UI64,
HOST_STATUS_MONITORED, event->objectid);
break;