Source
xxxxxxxxxx
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
/* number of selected IPMI-related fields in function */
/* get_host_from_event() */
int get_host_from_event(const zbx_db_event *event, DC_HOST *host, char *error, size_t max_error_len)
{
DB_RESULT result;
DB_ROW 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.proxy_hostid,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");
switch (event->source)
{
case EVENT_SOURCE_TRIGGERS:
zbx_snprintf(sql + offset, sizeof(sql) - offset,
" from functions f,items i,hosts h"
" 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);