Source
xxxxxxxxxx
static void am_db_update_event_tags(zbx_uint64_t eventid, const char *params, zbx_vector_events_tags_t *events_tags)
/*
** Copyright (C) 2001-2024 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/>.
**/
typedef struct
{
zbx_hashset_t mediatypes;
zbx_ipc_async_socket_t am;
}
zbx_am_db_t;
/******************************************************************************
* *
* Purpose: creates new alert object *
* *
* Parameters: ... - [IN] alert data *
* *
* Return value: alert object. *
* *
******************************************************************************/
static zbx_am_db_alert_t *am_db_create_alert(zbx_uint64_t alertid, zbx_uint64_t mediatypeid, int source,
int object, zbx_uint64_t objectid, zbx_uint64_t eventid, zbx_uint64_t p_eventid, const char *sendto,
const char *subject, const char *message, const char *params, int status, int retries)
{
zbx_am_db_alert_t *alert;
alert = (zbx_am_db_alert_t *)zbx_malloc(NULL, sizeof(zbx_am_db_alert_t));
alert->alertid = alertid;
alert->mediatypeid = mediatypeid;
alert->source = source;
alert->object = object;
alert->objectid = objectid;
alert->eventid = eventid;
alert->p_eventid = p_eventid;
alert->sendto = zbx_strdup(NULL, sendto);
alert->subject = zbx_strdup(NULL, subject);
alert->message = zbx_strdup(NULL, message);
alert->params = zbx_strdup(NULL, params);
alert->status = status;
alert->retries = retries;
alert->expression = NULL;
alert->recovery_expression = NULL;
return alert;
}
static int am_db_init(zbx_am_db_t *amdb, char **error)
{
zbx_hashset_create(&amdb->mediatypes, 5, ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
if (SUCCEED != zbx_ipc_async_socket_open(&amdb->am, ZBX_IPC_SERVICE_ALERTER, SEC_PER_MIN, error))
return FAIL;
return SUCCEED;
}