source:
npl/monitoring/zabbix/zabbix-foreground.patch
@
105afb5
Last change on this file since 105afb5 was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 6.9 KB |
-
include/common.h
diff -u -r zabbix-2.2.1/include/common.h zabbix-2.2.1.new/include/common.h
old new 751 751 ZBX_TASK_START_SERVICE, 752 752 ZBX_TASK_STOP_SERVICE, 753 753 ZBX_TASK_CHANGE_NODEID, 754 ZBX_TASK_CONFIG_CACHE_RELOAD 754 ZBX_TASK_CONFIG_CACHE_RELOAD, 755 ZBX_TASK_START_FOREGROUND 755 756 } 756 757 zbx_task_t; 757 758 -
include/daemon.h
diff -u -r zabbix-2.2.1/include/daemon.h zabbix-2.2.1.new/include/daemon.h
old new 30 30 31 31 #include "threads.h" 32 32 33 int daemon_start(int allow_root );33 int daemon_start(int allow_root, int foreground); 34 34 void daemon_stop(); 35 35 36 36 int zbx_sigusr_send(zbx_task_t task); … … 38 38 #define ZBX_IS_RUNNING() 1 39 39 #define ZBX_DO_EXIT() 40 40 41 #define START_MAIN_ZABBIX_ENTRY(a ) daemon_start(a)41 #define START_MAIN_ZABBIX_ENTRY(a,b) daemon_start(a,b) 42 42 43 43 #endif /* ZABBIX_DAEMON_H */ -
src/libs/zbxnix/daemon.c
Only in zabbix-2.2.1/include: stamp-h1 diff -u -r zabbix-2.2.1/src/libs/zbxnix/daemon.c zabbix-2.2.1.new/src/libs/zbxnix/daemon.c
old new 140 140 * Comments: it doesn't allow running under 'root' if allow_root is zero * 141 141 * * 142 142 ******************************************************************************/ 143 int daemon_start(int allow_root )143 int daemon_start(int allow_root, int foreground) 144 144 { 145 145 pid_t pid; 146 146 struct passwd *pwd; … … 186 186 #endif 187 187 } 188 188 189 if (0 != (pid = zbx_fork())) 190 exit(0); 189 /* The actual daemonizing is done here. Since nowadays deamons run as normal processes under service supervisors, we provide a foreground-option as well. edwin@datux.nl */ 190 if (!foreground) 191 { 192 if (0 != (pid = zbx_fork())) 193 exit(0); 191 194 192 setsid();195 setsid(); 193 196 194 signal(SIGHUP, SIG_IGN);197 signal(SIGHUP, SIG_IGN); 195 198 196 if (0 != (pid = zbx_fork())) 197 exit(0); 199 if (0 != (pid = zbx_fork())) 200 exit(0); 201 } 198 202 199 203 if (-1 == chdir("/")) /* this is to eliminate warning: ignoring return value of chdir */ 200 204 assert(0); -
src/zabbix_agent/zabbix_agentd.c
diff -u -r zabbix-2.2.1/src/zabbix_agent/zabbix_agentd.c zabbix-2.2.1.new/src/zabbix_agent/zabbix_agentd.c
old new 89 89 " -c --config <config-file> Absolute path to the configuration file", 90 90 " -p --print Print known items and exit", 91 91 " -t --test <item key> Test specified item and exit", 92 " -f --foreground Start in the foreground. (for running a service supervisor)", 92 93 " -h --help Give this help", 93 94 " -V --version Display version number", 94 95 #ifdef _WINDOWS … … 112 113 { 113 114 {"config", 1, NULL, 'c'}, 114 115 {"help", 0, NULL, 'h'}, 116 {"foreground", 0, NULL, 'f'}, 115 117 {"version", 0, NULL, 'V'}, 116 118 {"print", 0, NULL, 'p'}, 117 119 {"test", 1, NULL, 't'}, … … 128 130 }; 129 131 130 132 static char shortopts[] = 131 "c:h Vpt:"133 "c:hfVpt:" 132 134 #ifdef _WINDOWS 133 135 "idsxm" 134 136 #endif … … 187 189 TEST_METRIC = strdup(zbx_optarg); 188 190 } 189 191 break; 192 case 'f': 193 t->task = ZBX_TASK_START_FOREGROUND; 194 break; 190 195 #ifdef _WINDOWS 191 196 case 'i': 192 197 t->task = ZBX_TASK_INSTALL_SERVICE; 193 198 break; 194 case 'd':195 t->task = ZBX_TASK_UNINSTALL_SERVICE;196 break;197 199 case 's': 198 200 t->task = ZBX_TASK_START_SERVICE; 199 201 break; … … 826 828 alias_list_free(); 827 829 exit(SUCCEED); 828 830 break; 829 default:831 case ZBX_TASK_START: 830 832 zbx_load_config(ZBX_CFG_FILE_REQUIRED); 833 START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, 0); 831 834 break; 835 case ZBX_TASK_START_FOREGROUND: 836 zbx_load_config(ZBX_CFG_FILE_REQUIRED); 837 START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, 1); 838 break; 839 832 840 } 833 841 834 START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT);835 836 842 exit(SUCCEED); 837 843 } -
src/zabbix_proxy/proxy.c
diff -u -r zabbix-2.2.1/src/zabbix_proxy/proxy.c zabbix-2.2.1.new/src/zabbix_proxy/proxy.c
old new 65 65 const char *help_message[] = { 66 66 "Options:", 67 67 " -c --config <file> Absolute path to the configuration file", 68 " -f --foreground Run in foreground (under a service supervisor)", 68 69 " -R --runtime-control <option> Perform administrative functions", 69 70 "", 70 71 "Runtime control options:", … … 84 85 {"config", 1, NULL, 'c'}, 85 86 {"runtime-control", 1, NULL, 'R'}, 86 87 {"help", 0, NULL, 'h'}, 88 {"foreground", 0, NULL, 'f'}, 87 89 {"version", 0, NULL, 'V'}, 88 90 {NULL} 89 91 }; 90 92 91 93 /* short options */ 92 static char shortopts[] = "c:n:h VR:";94 static char shortopts[] = "c:n:hfVR:"; 93 95 94 96 /* end of COMMAND LINE OPTIONS */ 95 97 … … 548 550 version(); 549 551 exit(-1); 550 552 break; 553 case 'f': 554 task=ZBX_TASK_START_FOREGROUND; 555 break; 551 556 default: 552 557 usage(); 553 558 exit(-1); … … 570 575 init_ipmi_handler(); 571 576 #endif 572 577 573 return daemon_start(CONFIG_ALLOW_ROOT );578 return daemon_start(CONFIG_ALLOW_ROOT, task==ZBX_TASK_START_FOREGROUND); 574 579 } 575 580 576 581 int MAIN_ZABBIX_ENTRY() -
src/zabbix_server/server.c
diff -u -r zabbix-2.2.1/src/zabbix_server/server.c zabbix-2.2.1.new/src/zabbix_server/server.c
old new 72 72 "Options:", 73 73 " -c --config <file> Absolute path to the configuration file", 74 74 " -n --new-nodeid <nodeid> Convert database data to new nodeid", 75 " -f --foreground Run in foreground. (for use with service supervisors)", 75 76 " -R --runtime-control <option> Perform administrative functions", 76 77 "", 77 78 "Runtime control options:", … … 92 93 {"new-nodeid", 1, NULL, 'n'}, 93 94 {"runtime-control", 1, NULL, 'R'}, 94 95 {"help", 0, NULL, 'h'}, 96 {"foreground", 0, NULL, 'f'}, 95 97 {"version", 0, NULL, 'V'}, 96 98 {NULL} 97 99 }; 98 100 99 101 /* short options */ 100 static char shortopts[] = "c:n:h VR:";102 static char shortopts[] = "c:n:hfVR:"; 101 103 102 104 /* end of COMMAND LINE OPTIONS */ 103 105 … … 512 514 help(); 513 515 exit(-1); 514 516 break; 517 case 'f': 518 task = ZBX_TASK_START_FOREGROUND; 519 break; 515 520 case 'n': 516 521 nodeid = (NULL == zbx_optarg ? 0 : atoi(zbx_optarg)); 517 522 task = ZBX_TASK_CHANGE_NODEID; … … 547 552 case ZBX_TASK_CHANGE_NODEID: 548 553 exit(SUCCEED == change_nodeid(nodeid) ? EXIT_SUCCESS : EXIT_FAILURE); 549 554 break; 550 default: 555 case ZBX_TASK_START: 556 return daemon_start(CONFIG_ALLOW_ROOT, 0); 557 break; 558 case ZBX_TASK_START_FOREGROUND: 559 return daemon_start(CONFIG_ALLOW_ROOT, 1); 551 560 break; 552 561 } 553 562 554 return daemon_start(CONFIG_ALLOW_ROOT);555 563 } 556 564 557 565 int MAIN_ZABBIX_ENTRY()
Note: See TracBrowser
for help on using the repository browser.