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/>.
**/
/******************************************************************************
* *
* Purpose: registers LLD worker with LLD manager *
* *
* Parameters: socket - [IN] connections socket *
* *
******************************************************************************/
static void lld_register_worker(zbx_ipc_socket_t *socket)
{
pid_t ppid;
ppid = getppid();
zbx_ipc_socket_write(socket, ZBX_IPC_LLD_REGISTER, (unsigned char *)&ppid, sizeof(ppid));
}
/******************************************************************************
* *
* Purpose: Processes LLD task and updates rule state/error in configuration *
* cache and database. *
* *
* Parameters: message - [IN] message with LLD request *
* *
******************************************************************************/
static void lld_process_task(const zbx_ipc_message_t *message)
{
zbx_uint64_t itemid, hostid, lastlogsize;
char *value, *error;
zbx_timespec_t ts;
zbx_item_diff_t diff;
zbx_dc_item_t item;
int errcode, mtime;
unsigned char state, meta;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
zbx_lld_deserialize_item_value(message->data, &itemid, &hostid, &value, &ts, &meta, &lastlogsize, &mtime,
&error);
zbx_dc_config_get_items_by_itemids(&item, &itemid, &errcode, 1);
if (SUCCEED != errcode)
goto out;
zabbix_log(LOG_LEVEL_DEBUG, "processing discovery rule:" ZBX_FS_UI64, itemid);
diff.flags = ZBX_FLAGS_ITEM_DIFF_UNSET;
if (NULL != error || NULL != value)
{
if (NULL == error && SUCCEED == lld_process_discovery_rule(itemid, value, &error))
state = ITEM_STATE_NORMAL;
else
state = ITEM_STATE_NOTSUPPORTED;
if (state != item.state)
{
diff.state = state;
diff.flags |= ZBX_FLAGS_ITEM_DIFF_UPDATE_STATE;