Source
zbx_uint32_t zbx_discovery_pack_usage_stats(unsigned char **data, const zbx_vector_dbl_t *usage, int count)
/*
** 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/>.
**/
static int discoverer_initialized = 0;
void zbx_discoverer_init(void)
{
discoverer_initialized = DISCOVERER_INITIALIZED_YES;
}
/******************************************************************************
* *
* Purpose: frees discovery check *
* *
******************************************************************************/
void zbx_discovery_dcheck_free(zbx_dc_dcheck_t *dcheck)
{
zbx_free(dcheck->key_);
zbx_free(dcheck->ports);
if (SVC_SNMPv1 == dcheck->type || SVC_SNMPv2c == dcheck->type || SVC_SNMPv3 == dcheck->type)
{
zbx_free(dcheck->snmp_community);
zbx_free(dcheck->snmpv3_securityname);
zbx_free(dcheck->snmpv3_authpassphrase);
zbx_free(dcheck->snmpv3_privpassphrase);
zbx_free(dcheck->snmpv3_contextname);
}
zbx_free(dcheck);
}
/******************************************************************************
* *
* Purpose: frees discovery rule *
* *
******************************************************************************/
void zbx_discovery_drule_free(zbx_dc_drule_t *drule)
{
zbx_free(drule->delay_str);
zbx_free(drule->iprange);
zbx_free(drule->name);
zbx_vector_dc_dcheck_ptr_clear_ext(&drule->dchecks, zbx_discovery_dcheck_free);
zbx_vector_dc_dcheck_ptr_destroy(&drule->dchecks);
zbx_free(drule);
}
/******************************************************************************
* *
* Purpose: sends command to discovery manager *
* *
* Parameters: code - [IN] message code *
* data - [IN] message data *
* size - [IN] message data size *
* response - [OUT] response message (can be NULL if response is *
* not requested) *
* *
******************************************************************************/
static void discovery_send(zbx_uint32_t code, unsigned char *data, zbx_uint32_t size,
zbx_ipc_message_t *response)
{
char *error = NULL;
static zbx_ipc_socket_t socket = {0};
/* each process has a permanent connection to discovery manager */
if (0 == socket.fd && FAIL == zbx_ipc_socket_open(&socket, ZBX_IPC_SERVICE_DISCOVERER, SEC_PER_MIN,