您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關zabbix中 init_selfmon_collector函數的作用是什么,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
zbx_free_config();
init_database_cache();
init_configuration_cache();//將配置放到緩存
init_selfmon_collector(); //初始本身進程監控收集
void init_selfmon_collector(void)
{
const char *__function_name = "init_selfmon_collector";
size_t sz, sz_array, sz_process[ZBX_PROCESS_TYPE_COUNT], sz_total;
key_t shm_key;
char *p;
clock_t ticks;
struct tms buf;
unsigned char proc_type;
int proc_num, process_forks;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
sz_total = sz = sizeof(zbx_selfmon_collector_t);
sz_total += sz_array = sizeof(zbx_stat_process_t *) * ZBX_PROCESS_TYPE_COUNT;
for (proc_type = 0; ZBX_PROCESS_TYPE_COUNT > proc_type; proc_type++)
sz_total += sz_process[proc_type] = sizeof(zbx_stat_process_t) * get_process_type_forks(proc_type);
zabbix_log(LOG_LEVEL_DEBUG, "%s() size:" ZBX_FS_SIZE_T, __function_name, (zbx_fs_size_t)sz_total);
if (-1 == (shm_key = zbx_ftok(CONFIG_FILE, ZBX_IPC_SELFMON_ID)))
{
zabbix_log(LOG_LEVEL_CRIT, "cannot create IPC key for a self-monitoring collector");
exit(EXIT_FAILURE);
}
if (FAIL == zbx_mutex_create_force(&sm_lock, ZBX_MUTEX_SELFMON))
{
zbx_error("unable to create mutex for a self-monitoring collector");
exit(EXIT_FAILURE);
}
if (-1 == (shm_id = zbx_shmget(shm_key, sz_total)))
{
zabbix_log(LOG_LEVEL_CRIT, "cannot allocate shared memory for a self-monitoring collector");
exit(EXIT_FAILURE);
}
if ((void *)(-1) == (p = shmat(shm_id, NULL, 0)))
{
zabbix_log(LOG_LEVEL_CRIT, "cannot attach shared memory for a self-monitoring collector: %s",
zbx_strerror(errno));
exit(EXIT_FAILURE);
}
collector = (zbx_selfmon_collector_t *)p; p += sz;
collector->process = (zbx_stat_process_t **)p; p += sz_array;
ticks = times(&buf);
for (proc_type = 0; ZBX_PROCESS_TYPE_COUNT > proc_type; proc_type++)
{
collector->process[proc_type] = (zbx_stat_process_t *)p; p += sz_process[proc_type];
memset(collector->process[proc_type], 0, sz_process[proc_type]);
process_forks = get_process_type_forks(proc_type);
for (proc_num = 0; proc_num < process_forks; proc_num++)
{
collector->process[proc_type][proc_num].last_ticks = ticks;
collector->process[proc_type][proc_num].last_state = ZBX_PROCESS_STATE_BUSY;
}
}
zabbix_log(LOG_LEVEL_DEBUG, "End of %s() collector:%p", __function_name, collector);
}
以上就是zabbix中 init_selfmon_collector函數的作用是什么,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。