Source
void zbx_rtc_subscribe(unsigned char proc_type, int proc_num, zbx_uint32_t *msgs, int msgs_num, int config_timeout,
/*
** 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: parse runtime control option target parameter *
* *
* Parameters: opt - [IN] the runtime control option *
* len - [IN] the runtime control option length without *
* parameter *
* size_total - [IN] total number of parsed bytes (optional) *
* j - [OUT] the runtime control option result *
* error - [OUT] error message *
* *
* Return value: SUCCEED - the runtime control option was processed *
* FAIL - otherwise *
* *
******************************************************************************/
static int rtc_parse_target_parameter(const char *opt, size_t len, size_t *size_total, struct zbx_json *j,
char **error)
{
const char *param = opt + len;
char *err_reason = NULL;
int proc_num, proc_type, ret = FAIL;
pid_t pid;
size_t size;
if (SUCCEED != rtc_option_get_parameter(param, &size, &err_reason))
goto out;
if (0 == size)
{
ret = SUCCEED;
goto out;
}
param += size;
if (SUCCEED != rtc_option_get_pid(param, &size, &pid, &err_reason))
goto out;
if (0 != size)
{
param += size;
zbx_json_addint64(j, ZBX_PROTO_TAG_PID, (zbx_uint64_t)pid);
ret = SUCCEED;
goto out;
}
if (SUCCEED != rtc_option_get_process_type(param, &size, &proc_type, &err_reason))
goto out;
zbx_json_addstring(j, ZBX_PROTO_TAG_PROCESS_NAME, get_process_type_string((unsigned char)proc_type),
ZBX_JSON_TYPE_STRING);
param += size;
if (SUCCEED != rtc_option_get_process_num(param, &size, &proc_num, &err_reason))
goto out;
if (0 != size)
{
zbx_json_addint64(j, ZBX_PROTO_TAG_PROCESS_NUM, proc_num);
param += size;
}
if ('\0' == *param)
ret = SUCCEED;
else
err_reason = zbx_dsprintf(NULL, "unrecognized parameter part \"%s\"", param);
out: