Source
xxxxxxxxxx
if (SUCCEED != zbx_timekeeper_get_stat(collector.monitor, unit_index, unit_count, aggr_func, state, value, &error))
/*
** 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/>.
**/
typedef struct
{
zbx_timekeeper_t *monitor;
zbx_timekeeper_sync_t sync;
int process_index[ZBX_PROCESS_TYPE_COUNT];
}
zbx_selfmon_collector_t;
static zbx_selfmon_collector_t collector;
static zbx_get_config_forks_f get_config_forks_cb = NULL;
static zbx_mutex_t sm_lock = ZBX_MUTEX_NULL;
static zbx_shmem_info_t *sm_mem = NULL;
ZBX_SHMEM_FUNC_IMPL(__sm, sm_mem)
static void sm_sync_lock(void *data)
{
zbx_mutex_t *mutex = (zbx_mutex_t *)data;
zbx_mutex_lock(*mutex);
}
static void sm_sync_unlock(void *data)
{
zbx_mutex_t *mutex = (zbx_mutex_t *)data;
zbx_mutex_unlock(*mutex);
}
static int selfmon_is_process_monitored(unsigned char proc_type)
{
switch (proc_type)
{
case ZBX_PROCESS_TYPE_PREPROCESSOR:
case ZBX_PROCESS_TYPE_DISCOVERER:
return FAIL;
default:
return SUCCEED;
}
}
/******************************************************************************
* *
* Purpose: Initialize structures and prepare state *
* for self-monitoring collector *
* *
******************************************************************************/
int zbx_init_selfmon_collector(zbx_get_config_forks_f get_config_forks, char **error)
{
size_t sz_total;
unsigned char proc_type;
int units_num = 0, ret = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
get_config_forks_cb = get_config_forks;