/****************************************************************************** * * * Function: main * * * * Purpose: executes proxy processes * * * * Author: Eugene Grigorjev * * * ******************************************************************************/ int main(int argc, char **argv) { zbx_task_t task = ZBX_TASK_START; char ch; progname = get_program_name(argv[0]); /* parse the command-line */ while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, shortopts, longopts, NULL))) { switch (ch) { case 'c': CONFIG_FILE = zbx_strdup(CONFIG_FILE, zbx_optarg); break; case 'R': if (0 == strcmp(zbx_optarg, ZBX_CONFIG_CACHE_RELOAD)) task = ZBX_TASK_CONFIG_CACHE_RELOAD; else { printf("invalid runtime control option: %s\n", zbx_optarg); exit(EXIT_FAILURE); } break; case 'h': help(); exit(-1); break; case 'V': version(); exit(-1); break; default: usage(); exit(-1); break; } } if (NULL == CONFIG_FILE) CONFIG_FILE = zbx_strdup(CONFIG_FILE, SYSCONFDIR "/zabbix_proxy.conf"); /* required for simple checks */ init_metrics(); zbx_load_config(); if (ZBX_TASK_CONFIG_CACHE_RELOAD == task) exit(SUCCEED == zbx_sigusr_send(ZBX_TASK_CONFIG_CACHE_RELOAD) ? EXIT_SUCCESS : EXIT_FAILURE); #ifdef HAVE_OPENIPMI init_ipmi_handler(); #endif return daemon_start(CONFIG_ALLOW_ROOT); }
/****************************************************************************** * * * Function: main * * * * Purpose: executes proxy processes * * * * Author: Eugene Grigorjev * * * ******************************************************************************/ int main(int argc, char **argv) { ZBX_TASK_EX t = {ZBX_TASK_START}; char ch; #if defined(PS_OVERWRITE_ARGV) || defined(PS_PSTAT_ARGV) argv = setproctitle_save_env(argc, argv); #endif progname = get_program_name(argv[0]); /* parse the command-line */ while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, shortopts, longopts, NULL))) { switch (ch) { case 'c': CONFIG_FILE = zbx_strdup(CONFIG_FILE, zbx_optarg); break; case 'R': if (SUCCEED != parse_rtc_options(zbx_optarg, daemon_type, &t.flags)) exit(EXIT_FAILURE); t.task = ZBX_TASK_RUNTIME_CONTROL; break; case 'h': help(); exit(EXIT_SUCCESS); break; case 'V': version(); exit(EXIT_SUCCESS); break; default: usage(); exit(EXIT_FAILURE); break; } } if (NULL == CONFIG_FILE) CONFIG_FILE = zbx_strdup(CONFIG_FILE, SYSCONFDIR "/zabbix_proxy.conf"); /* required for simple checks */ init_metrics(); zbx_load_config(); if (ZBX_TASK_RUNTIME_CONTROL == t.task) exit(SUCCEED == zbx_sigusr_send(t.flags) ? EXIT_SUCCESS : EXIT_FAILURE); #ifdef HAVE_OPENIPMI init_ipmi_handler(); #endif return daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER); }
/****************************************************************************** * * * Function: main * * * * Purpose: executes server processes * * * * Author: Eugene Grigorjev * * * ******************************************************************************/ int main(int argc, char **argv) { ZBX_TASK_EX t = {ZBX_TASK_START}; char ch, *error = NULL; int opt_c = 0, opt_r = 0; #if defined(PS_OVERWRITE_ARGV) || defined(PS_PSTAT_ARGV) argv = setproctitle_save_env(argc, argv); #endif progname = get_program_name(argv[0]); /* parse the command-line */ while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, shortopts, longopts, NULL))) { switch (ch) { case 'c': opt_c++; if (NULL == CONFIG_FILE) CONFIG_FILE = zbx_strdup(CONFIG_FILE, zbx_optarg); break; case 'R': opt_r++; if (SUCCEED != parse_rtc_options(zbx_optarg, program_type, &t.data)) exit(EXIT_FAILURE); t.task = ZBX_TASK_RUNTIME_CONTROL; break; case 'h': help(); exit(EXIT_SUCCESS); break; case 'V': version(); exit(EXIT_SUCCESS); break; case 'f': t.flags |= ZBX_TASK_FLAG_FOREGROUND; break; default: usage(); exit(EXIT_FAILURE); break; } } /* every option may be specified only once */ if (1 < opt_c || 1 < opt_r) { if (1 < opt_c) zbx_error("option \"-c\" or \"--config\" specified multiple times"); if (1 < opt_r) zbx_error("option \"-R\" or \"--runtime-control\" specified multiple times"); exit(EXIT_FAILURE); } /* Parameters which are not option values are invalid. The check relies on zbx_getopt_internal() which */ /* always permutes command line arguments regardless of POSIXLY_CORRECT environment variable. */ if (argc > zbx_optind) { int i; for (i = zbx_optind; i < argc; i++) zbx_error("invalid parameter \"%s\"", argv[i]); exit(EXIT_FAILURE); } if (NULL == CONFIG_FILE) CONFIG_FILE = zbx_strdup(NULL, DEFAULT_CONFIG_FILE); /* required for simple checks */ init_metrics(); zbx_load_config(&t); if (ZBX_TASK_RUNTIME_CONTROL == t.task) exit(SUCCEED == zbx_sigusr_send(t.data) ? EXIT_SUCCESS : EXIT_FAILURE); zbx_initialize_events(); if (FAIL == zbx_ipc_service_init_env(CONFIG_SOCKET_PATH, &error)) { zbx_error("Cannot initialize IPC services: %s", error); zbx_free(error); exit(EXIT_FAILURE); } return daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags); }
/****************************************************************************** * * * Function: main * * * * Purpose: executes server processes * * * * Author: Eugene Grigorjev * * * ******************************************************************************/ int main(int argc, char **argv) { zbx_task_t task = ZBX_TASK_START; char ch = '\0'; int nodeid = 0; #if defined(PS_OVERWRITE_ARGV) || defined(PS_PSTAT_ARGV) argv = setproctitle_save_env(argc, argv); #endif progname = get_program_name(argv[0]); /* parse the command-line */ while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, shortopts, longopts, NULL))) { switch (ch) { case 'c': CONFIG_FILE = zbx_strdup(CONFIG_FILE, zbx_optarg); break; case 'R': if (0 == strcmp(zbx_optarg, ZBX_CONFIG_CACHE_RELOAD)) task = ZBX_TASK_CONFIG_CACHE_RELOAD; else { printf("invalid runtime control option: %s\n", zbx_optarg); exit(EXIT_FAILURE); } break; case 'h': help(); exit(-1); break; case 'n': nodeid = (NULL == zbx_optarg ? 0 : atoi(zbx_optarg)); task = ZBX_TASK_CHANGE_NODEID; break; case 'V': version(); exit(-1); break; default: usage(); exit(-1); break; } } if (NULL == CONFIG_FILE) CONFIG_FILE = zbx_strdup(CONFIG_FILE, SYSCONFDIR "/zabbix_server.conf"); /* required for simple checks */ init_metrics(); zbx_load_config(); if (ZBX_TASK_CONFIG_CACHE_RELOAD == task) exit(SUCCEED == zbx_sigusr_send(ZBX_TASK_CONFIG_CACHE_RELOAD) ? EXIT_SUCCESS : EXIT_FAILURE); #ifdef HAVE_OPENIPMI init_ipmi_handler(); #endif switch (task) { case ZBX_TASK_CHANGE_NODEID: exit(SUCCEED == change_nodeid(nodeid) ? EXIT_SUCCESS : EXIT_FAILURE); break; default: break; } return daemon_start(CONFIG_ALLOW_ROOT); }