Source
xxxxxxxxxx
/*
** 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/>.
**/
static ZBX_THREAD_LOCAL zbx_ipc_socket_t pgservice_sock;
ZBX_VECTOR_IMPL(objmove, zbx_objmove_t)
/******************************************************************************
* *
* Purpose: send object relocation updates to proxy group service *
* *
* Comments: used only by server *
* *
******************************************************************************/
void zbx_pg_update_object_relocations(zbx_uint32_t code, zbx_vector_objmove_t *updates)
{
if (0 == updates->values_num)
return;
if (0 == pgservice_sock.fd)
{
char *error = NULL;
if (FAIL == zbx_ipc_socket_open(&pgservice_sock, ZBX_IPC_SERVICE_PGSERVICE, ZBX_PG_SERVICE_TIMEOUT,
&error))
{
zabbix_log(LOG_LEVEL_CRIT, "Cannot connect to proxy group manager service: %s", error);
zbx_free(error);
exit(EXIT_FAILURE);
}
}
unsigned char *data, *ptr;
ptr = data = (unsigned char *)zbx_malloc(NULL, sizeof(zbx_uint64_t) * 3 * (size_t)updates->values_num);
for (int i = 0; i < updates->values_num; i++)
{
ptr += zbx_serialize_value(ptr, updates->values[i].objid);
ptr += zbx_serialize_value(ptr, updates->values[i].srcid);
ptr += zbx_serialize_value(ptr, updates->values[i].dstid);
}
if (FAIL == zbx_ipc_socket_write(&pgservice_sock, code, data, (zbx_uint32_t)(ptr - data)))
{