From fe88e0447ab21e73d347f0933273d2859493ba9d Mon Sep 17 00:00:00 2001 From: Etienne CHAMPETIER Date: Sun, 3 Apr 2016 13:08:23 +0000 Subject: [PATCH] zabbix: update to zabbix 3.0.1 zabbix-agent doesn't exist anymore since 3.0 '-f' option (foreground) is now in zabbix-agentd 003-change-user-and-foreground.patch fixes pending issue https://support.zabbix.com/browse/ZBX-10611 you might need to update your config file to add LogType=system Signed-off-by: Etienne CHAMPETIER --- admin/zabbix/Makefile | 20 +- admin/zabbix/files/zabbix_agentd.init | 2 + .../patches/002-fix-res_send-on-uclibc.patch | 8 +- admin/zabbix/patches/002-uclibc_loadavg.patch | 6 +- .../003-change-user-and-foreground.patch | 17 ++ .../patches/010-change-agentd-config.patch | 19 +- .../patches/015-daemon-foreground.patch | 243 ------------------ admin/zabbix/patches/100-musl-compat.patch | 2 +- 8 files changed, 41 insertions(+), 276 deletions(-) create mode 100644 admin/zabbix/patches/003-change-user-and-foreground.patch delete mode 100644 admin/zabbix/patches/015-daemon-foreground.patch diff --git a/admin/zabbix/Makefile b/admin/zabbix/Makefile index a2a77ba745..87e51c3be6 100644 --- a/admin/zabbix/Makefile +++ b/admin/zabbix/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zabbix -PKG_VERSION:=2.4.6 -PKG_RELEASE:=3 +PKG_VERSION:=3.0.1 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/zabbix -PKG_MD5SUM:=06ad8d5808a0eddf2b9f0a256b6a5fde +PKG_MD5SUM:=890d9eec69304ad552959fabe0a5d122 PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING @@ -36,11 +36,6 @@ define Package/zabbix/Default DEPENDS += $(ICONV_DEPENDS) endef -define Package/zabbix-agent - $(call Package/zabbix/Default) - TITLE+= agent -endef - define Package/zabbix-agentd $(call Package/zabbix/Default) TITLE+= agentd @@ -159,9 +154,6 @@ define Package/zabbix/install/zabbix.conf.d $(1)/etc/zabbix_agentd.conf.d/$(2) endef -define Package/zabbix-agent/conffiles -/etc/zabbix_agent.conf -endef define Package/zabbix-agentd/conffiles /etc/zabbix_agentd.conf endef @@ -193,11 +185,6 @@ define Build/Compile $(call Build/Compile/zabbix-extra-mac80211) endef -define Package/zabbix-agent/install - $(call Package/zabbix/install/sbin,$(1),agent) - $(call Package/zabbix/install/etc,$(1),agent) -endef - define Package/zabbix-agentd/install $(INSTALL_DIR) $(1)/etc/zabbix_agentd.conf.d $(call Package/zabbix/install/sbin,$(1),agentd) @@ -238,7 +225,6 @@ define Package/zabbix-proxy/install $(call Package/zabbix/install/etc,$(1),proxy) endef -$(eval $(call BuildPackage,zabbix-agent)) $(eval $(call BuildPackage,zabbix-agentd)) $(eval $(call BuildPackage,zabbix-extra-mac80211)) $(eval $(call BuildPackage,zabbix-extra-network)) diff --git a/admin/zabbix/files/zabbix_agentd.init b/admin/zabbix/files/zabbix_agentd.init index 86f1cedead..ea886346e7 100755 --- a/admin/zabbix/files/zabbix_agentd.init +++ b/admin/zabbix/files/zabbix_agentd.init @@ -16,6 +16,8 @@ start_service() { procd_open_instance procd_set_param command ${PROG} -c ${CONFIG} -f procd_set_param respawn + procd_set_param stdout 1 + procd_set_param stderr 1 procd_close_instance } diff --git a/admin/zabbix/patches/002-fix-res_send-on-uclibc.patch b/admin/zabbix/patches/002-fix-res_send-on-uclibc.patch index cedad90048..f4b5d33a12 100644 --- a/admin/zabbix/patches/002-fix-res_send-on-uclibc.patch +++ b/admin/zabbix/patches/002-fix-res_send-on-uclibc.patch @@ -1,6 +1,6 @@ --- a/configure.ac +++ b/configure.ac -@@ -152,6 +152,10 @@ if test "x$found_resolv" != "xyes"; then +@@ -161,6 +161,10 @@ if test "x$found_resolv" != "xyes"; then AC_MSG_ERROR([Unable to do DNS lookups (libresolv check failed)]) fi LIBS="${LIBS} ${RESOLV_LIBS}" @@ -13,7 +13,7 @@ dnl * * --- a/src/libs/zbxsysinfo/common/net.c +++ b/src/libs/zbxsysinfo/common/net.c -@@ -450,6 +450,7 @@ static int dns_query(AGENT_REQUEST *requ +@@ -471,6 +471,7 @@ static int dns_query(AGENT_REQUEST *requ return SYSINFO_RET_FAIL; } @@ -21,7 +21,7 @@ if (-1 == (res = res_mkquery(QUERY, zone, C_IN, type, NULL, 0, NULL, buf, sizeof(buf)))) { SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot create DNS query: %s", zbx_strerror(errno))); -@@ -480,6 +481,11 @@ static int dns_query(AGENT_REQUEST *requ +@@ -505,6 +506,11 @@ static int dns_query(AGENT_REQUEST *requ _res.retry = retry; res = res_send(buf, res, answer.buffer, sizeof(answer.buffer)); @@ -31,5 +31,5 @@ + return SYSINFO_RET_FAIL; +#endif + _res.options = saved_options; _res.retrans = saved_retrans; - _res.retry = saved_retry; diff --git a/admin/zabbix/patches/002-uclibc_loadavg.patch b/admin/zabbix/patches/002-uclibc_loadavg.patch index 191f1a136f..ce62d06c33 100644 --- a/admin/zabbix/patches/002-uclibc_loadavg.patch +++ b/admin/zabbix/patches/002-uclibc_loadavg.patch @@ -1,8 +1,8 @@ --- a/src/libs/zbxsysinfo/linux/cpu.c +++ b/src/libs/zbxsysinfo/linux/cpu.c -@@ -62,6 +62,45 @@ int SYSTEM_CPU_DISCOVERY(AGENT_REQUEST * - return SYSINFO_RET_OK; - } +@@ -22,6 +22,45 @@ + #include "stats.h" + #include "log.h" + +/* uclibc and dietlibc do not have this junk -ReneR */ diff --git a/admin/zabbix/patches/003-change-user-and-foreground.patch b/admin/zabbix/patches/003-change-user-and-foreground.patch new file mode 100644 index 0000000000..6779e47194 --- /dev/null +++ b/admin/zabbix/patches/003-change-user-and-foreground.patch @@ -0,0 +1,17 @@ +--- a/src/libs/zbxnix/daemon.c ++++ b/src/libs/zbxnix/daemon.c +@@ -300,11 +300,14 @@ int daemon_start(int allow_root, const c + + if (0 == allow_root && 0 == getuid()) /* running as root? */ + { ++#if 0 ++/* allow changing user and foreground */ + if (0 != (flags & ZBX_TASK_FLAG_FOREGROUND)) + { + zbx_error("cannot run as root!"); + exit(EXIT_FAILURE); + } ++#endif + + if (NULL == user) + user = "zabbix"; diff --git a/admin/zabbix/patches/010-change-agentd-config.patch b/admin/zabbix/patches/010-change-agentd-config.patch index e4812f6ef9..8b16b28032 100644 --- a/admin/zabbix/patches/010-change-agentd-config.patch +++ b/admin/zabbix/patches/010-change-agentd-config.patch @@ -1,6 +1,6 @@ --- a/conf/zabbix_agentd.conf +++ b/conf/zabbix_agentd.conf -@@ -3,12 +3,8 @@ +@@ -3,12 +3,11 @@ ############ GENERAL PARAMETERS ################# @@ -12,10 +12,13 @@ -# PidFile=/tmp/zabbix_agentd.pid +# We do not need PidFile with procd +# PidFile=/var/run/zabbix_agentd.pid ++ ++# use syslog ++LogType=system - ### Option: LogFile - # Name of log file. -@@ -18,8 +14,6 @@ + ### Option: LogType + # Specifies where log messages are written to: +@@ -27,8 +26,6 @@ # Default: # LogFile= @@ -24,7 +27,7 @@ ### Option: LogFileSize # Maximum size of log file in MB. # 0 - disable automatic log rotation. -@@ -104,6 +98,7 @@ Server=127.0.0.1 +@@ -114,6 +111,7 @@ Server=127.0.0.1 # Range: 0-100 # Default: # StartAgents=3 @@ -32,7 +35,7 @@ ##### Active checks related -@@ -119,8 +114,6 @@ Server=127.0.0.1 +@@ -129,8 +127,6 @@ Server=127.0.0.1 # Default: # ServerActive= @@ -41,7 +44,7 @@ ### Option: Hostname # Unique, case sensitive hostname. # Required for active checks and must match hostname as configured on the server. -@@ -130,8 +123,6 @@ ServerActive=127.0.0.1 +@@ -140,8 +136,6 @@ ServerActive=127.0.0.1 # Default: # Hostname= @@ -50,7 +53,7 @@ ### Option: HostnameItem # Item used for generating Hostname if it is undefined. Ignored if Hostname is defined. # Does not support UserParameters or aliases. -@@ -249,8 +240,8 @@ Hostname=Zabbix server +@@ -259,8 +253,8 @@ Hostname=Zabbix server # Include= # Include=/usr/local/etc/zabbix_agentd.userparams.conf diff --git a/admin/zabbix/patches/015-daemon-foreground.patch b/admin/zabbix/patches/015-daemon-foreground.patch deleted file mode 100644 index a0fd9b98be..0000000000 --- a/admin/zabbix/patches/015-daemon-foreground.patch +++ /dev/null @@ -1,243 +0,0 @@ ---- a/include/common.h -+++ b/include/common.h -@@ -1083,4 +1083,7 @@ int parse_serveractive_element(char *str - - char *zbx_dyn_escape_shell_single_quote(const char *text); - -+#define ZBX_RUN_BACKGROUND 0 -+#define ZBX_RUN_FOREGROUND 1 -+ - #endif ---- a/include/daemon.h -+++ b/include/daemon.h -@@ -28,7 +28,7 @@ extern char *CONFIG_PID_FILE; - - #include "threads.h" - --int daemon_start(int allow_root, const char *user); -+int daemon_start(int allow_root, const char *user, int run_foreground); - void daemon_stop(); - - int zbx_sigusr_send(int flags); -@@ -36,6 +36,6 @@ int zbx_sigusr_send(int flags); - #define ZBX_IS_RUNNING() 1 - #define ZBX_DO_EXIT() - --#define START_MAIN_ZABBIX_ENTRY(a, u) daemon_start(a, u) -+#define START_MAIN_ZABBIX_ENTRY(a, u, f) daemon_start(a, u, f) - - #endif /* ZABBIX_DAEMON_H */ ---- a/src/libs/zbxnix/daemon.c -+++ b/src/libs/zbxnix/daemon.c -@@ -272,16 +272,17 @@ static void set_daemon_signal_handlers() - * * - * Purpose: init process as daemon * - * * -- * Parameters: allow_root - allow root permission for application * -- * user - user on the system to which to drop the * -- * privileges * -+ * Parameters: allow_root - allow root permission for application * -+ * user - user on the system to which to drop the * -+ * privileges * -+ * run_foreground - should it close its controlling tty * - * * - * Author: Alexei Vladishev * - * * - * Comments: it doesn't allow running under 'root' if allow_root is zero * - * * - ******************************************************************************/ --int daemon_start(int allow_root, const char *user) -+int daemon_start(int allow_root, const char *user, int run_foreground) - { - pid_t pid; - struct passwd *pwd; -@@ -336,15 +337,22 @@ int daemon_start(int allow_root, const c - #endif - } - -- if (0 != (pid = zbx_fork())) -- exit(EXIT_SUCCESS); -+ if ( ZBX_RUN_FOREGROUND != run_foreground) -+ if (0 != (pid = zbx_fork())) -+ exit(EXIT_SUCCESS); - - setsid(); - - signal(SIGHUP, SIG_IGN); - -- if (0 != (pid = zbx_fork())) -- exit(EXIT_SUCCESS); -+ if ( ZBX_RUN_FOREGROUND == run_foreground) { -+ zabbix_log(LOG_LEVEL_INFORMATION, "Running in foreground..."); -+ } else { -+ if (0 != (pid = zbx_fork())) -+ exit(EXIT_SUCCESS); -+ } -+ -+ - - if (-1 == chdir("/")) /* this is to eliminate warning: ignoring return value of chdir */ - assert(0); ---- a/src/zabbix_agent/zabbix_agentd.c -+++ b/src/zabbix_agent/zabbix_agentd.c -@@ -62,6 +62,8 @@ const char *progname = NULL; - static char DEFAULT_CONFIG_FILE[] = SYSCONFDIR "/zabbix_agentd.conf"; - #endif - -+int CONFIG_FOREGROUND = ZBX_RUN_BACKGROUND; -+ - /* application TITLE */ - const char title_message[] = APPLICATION_NAME - #if defined(_WIN64) -@@ -93,6 +95,7 @@ const char usage_message[] = - const char *help_message[] = { - "Options:", - " -c --config Absolute path to the configuration file", -+ " -f --foreground Run in foreground don't fork", - " -p --print Print known items and exit", - " -t --test Test specified item and exit", - " -h --help Display help information", -@@ -127,6 +130,7 @@ const char *help_message[] = { - /* COMMAND LINE OPTIONS */ - static struct zbx_option longopts[] = - { -+ {"foreground", 0, NULL, 'f'}, - {"config", 1, NULL, 'c'}, - {"help", 0, NULL, 'h'}, - {"version", 0, NULL, 'V'}, -@@ -147,7 +151,7 @@ static struct zbx_option longopts[] = - }; - - static char shortopts[] = -- "c:hVpt:" -+ "c:hfVpt:" - #ifndef _WINDOWS - "R:" - #else -@@ -241,6 +245,9 @@ static void parse_commandline(int argc, - { - switch (ch) - { -+ case 'f': -+ CONFIG_FOREGROUND = ZBX_RUN_FOREGROUND; -+ break; - case 'c': - CONFIG_FILE = strdup(zbx_optarg); - break; -@@ -944,7 +951,7 @@ int main(int argc, char **argv) - break; - } - -- START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, CONFIG_USER); -+ START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, CONFIG_USER, CONFIG_FOREGROUND); - - exit(EXIT_SUCCESS); - } ---- a/src/zabbix_proxy/proxy.c -+++ b/src/zabbix_proxy/proxy.c -@@ -60,6 +60,7 @@ const char usage_message[] = "[-hV] [-c - - const char *help_message[] = { - "Options:", -+ " -f --foreground Run in foreground don't fork", - " -c --config Absolute path to the configuration file", - " -R --runtime-control