Source
xxxxxxxxxx
static void rtc_notify_service(zbx_rtc_sub_t *sub, zbx_uint32_t code, const unsigned char *data, zbx_uint32_t size)
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
ZBX_PTR_VECTOR_IMPL(rtc_sub, zbx_rtc_sub_t *)
ZBX_PTR_VECTOR_IMPL(rtc_hook, zbx_rtc_hook_t *)
/******************************************************************************
* *
* Purpose: get runtime control option targets *
* *
******************************************************************************/
int zbx_rtc_get_command_target(const char *data, pid_t *pid, int *proc_type, int *proc_num, int *scope,
char **result)
{
struct zbx_json_parse jp;
char buf[MAX_STRING_LEN];
if (FAIL == zbx_json_open(data, &jp))
{
*result = zbx_dsprintf(NULL, "Invalid parameters \"%s\"\n", data);
return FAIL;
}
if (NULL != scope)
{
if (SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_SCOPE, buf, sizeof(buf), NULL))
*scope = atoi(buf);
else
*scope = ZBX_PROF_UNKNOWN;
}
if (SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_PID, buf, sizeof(buf), NULL))
{
zbx_uint64_t pid_ui64;
if (SUCCEED != zbx_is_uint64(buf, &pid_ui64) || 0 == pid_ui64)
{
*result = zbx_dsprintf(NULL, "Invalid pid value \"%s\"\n", buf);
return FAIL;
}
*pid = (pid_t)pid_ui64;
}
else
*pid = 0;
if (SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_PROCESS_NUM, buf, sizeof(buf), NULL))
*proc_num = atoi(buf);
else
*proc_num = 0;
if (SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_PROCESS_NAME, buf, sizeof(buf), NULL))
{
if (ZBX_PROCESS_TYPE_UNKNOWN == (*proc_type = get_process_type_by_name(buf)))
{
*result = zbx_dsprintf(NULL, "Invalid parameters \"%s\"\n", data);
return FAIL;
}
}
else
*proc_type = ZBX_PROCESS_TYPE_UNKNOWN;
return SUCCEED;
}