您好,登录后才能下订单哦!
本篇文章给大家分享的是有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。