From: Marcin Krol Date: Sun, 3 Jan 2021 22:27:42 +0000 (+0100) Subject: - Zabbix 5.0.x LTS, based on PLD and Fedora specs, NFY X-Git-Url: https://git.tld-linux.org/?p=packages%2Fzabbix.git;a=commitdiff_plain;h=4523bfffb57a373581cdf4a1f86ebd4e56216bde - Zabbix 5.0.x LTS, based on PLD and Fedora specs, NFY --- 4523bfffb57a373581cdf4a1f86ebd4e56216bde diff --git a/always_compile_ipc.patch b/always_compile_ipc.patch new file mode 100644 index 0000000..076dcd7 --- /dev/null +++ b/always_compile_ipc.patch @@ -0,0 +1,12 @@ +diff -ur zabbix-5.0.7.orig/configure.ac zabbix-5.0.7/configure.ac +--- zabbix-5.0.7.orig/configure.ac 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/configure.ac 2021-01-03 20:31:44.256798240 +0100 +@@ -1668,7 +1668,7 @@ + AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes") + + dnl Check if Zabbix internal IPC services are used +-have_ipcservice="no" ++have_ipcservice="yes" + if test "x$have_ipmi" = "xyes"; then + have_ipcservice="yes" + fi diff --git a/sqlite3_dbname.patch b/sqlite3_dbname.patch new file mode 100644 index 0000000..0288f6a --- /dev/null +++ b/sqlite3_dbname.patch @@ -0,0 +1,33 @@ +diff -ur zabbix-5.0.7.orig/conf/zabbix_proxy.conf zabbix-5.0.7/conf/zabbix_proxy.conf +--- zabbix-5.0.7.orig/conf/zabbix_proxy.conf 2021-01-03 20:22:59.543798240 +0100 ++++ zabbix-5.0.7/conf/zabbix_proxy.conf 2021-01-03 20:28:36.745798240 +0100 +@@ -158,6 +158,7 @@ + ### Option: DBName + # Database name. + # For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. ++# If provided name does not contain '/' or ':' (no a path or special type) a .db file in /var/lib/zabbix will be used. + # Warning: do not attempt to use the same database Zabbix server is using. + # + # Mandatory: yes +diff -ur zabbix-5.0.7.orig/src/libs/zbxdb/db.c zabbix-5.0.7/src/libs/zbxdb/db.c +--- zabbix-5.0.7.orig/src/libs/zbxdb/db.c 2020-12-14 11:27:17.000000000 +0100 ++++ zabbix-5.0.7/src/libs/zbxdb/db.c 2021-01-03 20:30:32.174798240 +0100 +@@ -383,6 +383,7 @@ + unsigned int i = 0; + #elif defined(HAVE_SQLITE3) + char *p, *path = NULL; ++ char dbname_buf[1024]; + #endif + + #ifndef HAVE_MYSQL +@@ -830,6 +831,10 @@ + ZBX_UNUSED(ca); + ZBX_UNUSED(cipher); + ZBX_UNUSED(cipher_13); ++ if (!strchr(dbname, '/') && !strchr(dbname, ':')) { ++ zbx_snprintf(dbname_buf, sizeof(dbname_buf), "/var/lib/zabbix/%s.db", dbname); ++ dbname = dbname_buf; ++ } + #ifdef HAVE_FUNCTION_SQLITE3_OPEN_V2 + if (SQLITE_OK != sqlite3_open_v2(dbname, &conn, SQLITE_OPEN_READWRITE, NULL)) + #else diff --git a/tld.patch b/tld.patch new file mode 100644 index 0000000..c5546ed --- /dev/null +++ b/tld.patch @@ -0,0 +1,232 @@ +diff -ur zabbix-5.0.7.orig/conf/zabbix_agentd.conf zabbix-5.0.7/conf/zabbix_agentd.conf +--- zabbix-5.0.7.orig/conf/zabbix_agentd.conf 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/conf/zabbix_agentd.conf 2021-01-03 22:16:31.046106105 +0100 +@@ -8,7 +8,7 @@ + # + # Mandatory: no + # Default: +-# PidFile=/tmp/zabbix_agentd.pid ++# PidFile=/var/run/zabbix/zabbix_agentd.pid + + ### Option: LogType + # Specifies where log messages are written to: +@@ -27,7 +27,7 @@ + # Default: + # LogFile= + +-LogFile=/tmp/zabbix_agentd.log ++LogFile=/var/log/zabbix/zabbix_agentd.log + + ### Option: LogFileSize + # Maximum size of log file in MB. +@@ -296,15 +296,12 @@ + + ### Option: Include + # You may include individual files or all files in a directory in the configuration file. +-# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. + # + # Mandatory: no + # Default: + # Include= + +-# Include=/usr/local/etc/zabbix_agentd.userparams.conf +-# Include=/usr/local/etc/zabbix_agentd.conf.d/ +-# Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf ++Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf + + ####### USER-DEFINED MONITORED PARAMETERS ####### + +diff -ur zabbix-5.0.7.orig/conf/zabbix_proxy.conf zabbix-5.0.7/conf/zabbix_proxy.conf +--- zabbix-5.0.7.orig/conf/zabbix_proxy.conf 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/conf/zabbix_proxy.conf 2021-01-03 22:17:05.509106105 +0100 +@@ -88,7 +88,7 @@ + # Default: + # LogFile= + +-LogFile=/tmp/zabbix_proxy.log ++LogFile=/var/log/zabbix/zabbix_proxy.log + + ### Option: LogFileSize + # Maximum size of log file in MB. +@@ -136,7 +136,7 @@ + # + # Mandatory: no + # Default: +-# PidFile=/tmp/zabbix_proxy.pid ++# PidFile=/var/run/zabbix/zabbix_proxy.pid + + ### Option: SocketDir + # IPC socket directory. +@@ -578,15 +578,12 @@ + + ### Option: Include + # You may include individual files or all files in a directory in the configuration file. +-# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. + # + # Mandatory: no + # Default: + # Include= + +-# Include=/usr/local/etc/zabbix_proxy.general.conf +-# Include=/usr/local/etc/zabbix_proxy.conf.d/ +-# Include=/usr/local/etc/zabbix_proxy.conf.d/*.conf ++Include=/etc/zabbix/zabbix_proxy.conf.d/*.conf + + ### Option: SSLCertLocation + # Location of SSL client certificates. +diff -ur zabbix-5.0.7.orig/conf/zabbix_server.conf zabbix-5.0.7/conf/zabbix_server.conf +--- zabbix-5.0.7.orig/conf/zabbix_server.conf 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/conf/zabbix_server.conf 2021-01-03 22:17:13.072106105 +0100 +@@ -35,7 +35,7 @@ + # Default: + # LogFile= + +-LogFile=/tmp/zabbix_server.log ++LogFile=/var/log/zabbix/zabbix_server.log + + ### Option: LogFileSize + # Maximum size of log file in MB. +@@ -65,7 +65,7 @@ + # + # Mandatory: no + # Default: +-# PidFile=/tmp/zabbix_server.pid ++# PidFile=/var/run/zabbix/zabbix_server.pid + + ### Option: SocketDir + # IPC socket directory. +@@ -612,15 +612,12 @@ + + ### Option: Include + # You may include individual files or all files in a directory in the configuration file. +-# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. + # + # Mandatory: no + # Default: + # Include= + +-# Include=/usr/local/etc/zabbix_server.general.conf +-# Include=/usr/local/etc/zabbix_server.conf.d/ +-# Include=/usr/local/etc/zabbix_server.conf.d/*.conf ++Include=/etc/zabbix/zabbix_server.conf.d/*.conf + + ### Option: SSLCertLocation + # Location of SSL client certificates. +diff -ur zabbix-5.0.7.orig/src/zabbix_agent/zabbix_agentd.c zabbix-5.0.7/src/zabbix_agent/zabbix_agentd.c +--- zabbix-5.0.7.orig/src/zabbix_agent/zabbix_agentd.c 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/src/zabbix_agent/zabbix_agentd.c 2021-01-03 22:04:59.483106105 +0100 +@@ -598,7 +598,7 @@ + CONFIG_LOAD_MODULE_PATH = zbx_strdup(CONFIG_LOAD_MODULE_PATH, DEFAULT_LOAD_MODULE_PATH); + + if (NULL == CONFIG_PID_FILE) +- CONFIG_PID_FILE = (char *)"/tmp/zabbix_agentd.pid"; ++ CONFIG_PID_FILE = (char *)"/var/run/zabbix/zabbix_agentd.pid"; + #endif + if (NULL == CONFIG_LOG_TYPE_STR) + CONFIG_LOG_TYPE_STR = zbx_strdup(CONFIG_LOG_TYPE_STR, ZBX_OPTION_LOGTYPE_FILE); +diff -ur zabbix-5.0.7.orig/src/zabbix_java/lib/logback.xml zabbix-5.0.7/src/zabbix_java/lib/logback.xml +--- zabbix-5.0.7.orig/src/zabbix_java/lib/logback.xml 2020-12-14 11:27:17.000000000 +0100 ++++ zabbix-5.0.7/src/zabbix_java/lib/logback.xml 2021-01-03 22:03:05.902106105 +0100 +@@ -2,10 +2,10 @@ + + + +- /tmp/zabbix_java.log ++ /var/log/zabbix/zabbix_java.log + + +- /tmp/zabbix_java.log.%i ++ /var/log/zabbix/zabbix_java.log.%i + 1 + 3 + +diff -ur zabbix-5.0.7.orig/src/zabbix_java/settings.sh zabbix-5.0.7/src/zabbix_java/settings.sh +--- zabbix-5.0.7.orig/src/zabbix_java/settings.sh 2020-12-14 11:27:17.000000000 +0100 ++++ zabbix-5.0.7/src/zabbix_java/settings.sh 2021-01-03 22:03:05.902106105 +0100 +@@ -24,7 +24,7 @@ + # Default: + # PID_FILE= + +-PID_FILE="/tmp/zabbix_java.pid" ++PID_FILE="/var/run/zabbix/zabbix_java.pid" + + ### Option: zabbix.startPollers + # Number of worker threads to start. +diff -ur zabbix-5.0.7.orig/src/zabbix_proxy/proxy.c zabbix-5.0.7/src/zabbix_proxy/proxy.c +--- zabbix-5.0.7.orig/src/zabbix_proxy/proxy.c 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/src/zabbix_proxy/proxy.c 2021-01-03 22:08:43.899106105 +0100 +@@ -474,7 +474,7 @@ + CONFIG_SNMPTRAP_FILE = zbx_strdup(CONFIG_SNMPTRAP_FILE, "/tmp/zabbix_traps.tmp"); + + if (NULL == CONFIG_PID_FILE) +- CONFIG_PID_FILE = zbx_strdup(CONFIG_PID_FILE, "/tmp/zabbix_proxy.pid"); ++ CONFIG_PID_FILE = zbx_strdup(CONFIG_PID_FILE, "/var/run/zabbix/zabbix_proxy.pid"); + + if (NULL == CONFIG_TMPDIR) + CONFIG_TMPDIR = zbx_strdup(CONFIG_TMPDIR, "/tmp"); +diff -ur zabbix-5.0.7.orig/src/zabbix_server/server.c zabbix-5.0.7/src/zabbix_server/server.c +--- zabbix-5.0.7.orig/src/zabbix_server/server.c 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/src/zabbix_server/server.c 2021-01-03 22:08:56.453106105 +0100 +@@ -482,7 +482,7 @@ + CONFIG_SNMPTRAP_FILE = zbx_strdup(CONFIG_SNMPTRAP_FILE, "/tmp/zabbix_traps.tmp"); + + if (NULL == CONFIG_PID_FILE) +- CONFIG_PID_FILE = zbx_strdup(CONFIG_PID_FILE, "/tmp/zabbix_server.pid"); ++ CONFIG_PID_FILE = zbx_strdup(CONFIG_PID_FILE, "/var/run/zabbix/zabbix_server.pid"); + + if (NULL == CONFIG_ALERT_SCRIPTS_PATH) + CONFIG_ALERT_SCRIPTS_PATH = zbx_strdup(CONFIG_ALERT_SCRIPTS_PATH, DEFAULT_ALERT_SCRIPTS_PATH); +diff -ur zabbix-5.0.7.orig/ui/include/classes/core/CConfigFile.php zabbix-5.0.7/ui/include/classes/core/CConfigFile.php +--- zabbix-5.0.7.orig/ui/include/classes/core/CConfigFile.php 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/ui/include/classes/core/CConfigFile.php 2021-01-03 22:57:20.570106105 +0100 +@@ -24,7 +24,7 @@ + const CONFIG_NOT_FOUND = 1; + const CONFIG_ERROR = 2; + +- const CONFIG_FILE_PATH = '/conf/zabbix.conf.php'; ++ const CONFIG_FILE_PATH = '/etc/zabbix/web/zabbix.conf.php'; + + private static $supported_db_types = [ + ZBX_DB_MYSQL => true, +diff -ur zabbix-5.0.7.orig/ui/include/classes/core/ZBase.php zabbix-5.0.7/ui/include/classes/core/ZBase.php +--- zabbix-5.0.7.orig/ui/include/classes/core/ZBase.php 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/ui/include/classes/core/ZBase.php 2021-01-03 22:57:20.571106105 +0100 +@@ -322,7 +322,7 @@ + * @throws Exception + */ + protected function setMaintenanceMode() { +- require_once 'conf/maintenance.inc.php'; ++ require_once '/etc/zabbix/web/maintenance.inc.php'; + + if (defined('ZBX_DENY_GUI_ACCESS')) { + if (!isset($ZBX_GUI_ACCESS_IP_RANGE) || !in_array(CWebUser::getIp(), $ZBX_GUI_ACCESS_IP_RANGE)) { +@@ -335,7 +335,7 @@ + * Load zabbix config file. + */ + protected function loadConfigFile() { +- $configFile = $this->getRootDir().CConfigFile::CONFIG_FILE_PATH; ++ $configFile = CConfigFile::CONFIG_FILE_PATH; + $config = new CConfigFile($configFile); + $this->config = $config->load(); + } +diff -ur zabbix-5.0.7.orig/ui/include/classes/setup/CSetupWizard.php zabbix-5.0.7/ui/include/classes/setup/CSetupWizard.php +--- zabbix-5.0.7.orig/ui/include/classes/setup/CSetupWizard.php 2020-12-21 10:38:31.000000000 +0100 ++++ zabbix-5.0.7/ui/include/classes/setup/CSetupWizard.php 2021-01-03 22:58:00.877106105 +0100 +@@ -425,7 +425,7 @@ + private function stage5(): array { + $this->setConfig('ZBX_CONFIG_FILE_CORRECT', true); + +- $config_file_name = APP::getInstance()->getRootDir().CConfigFile::CONFIG_FILE_PATH; ++ $config_file_name = CConfigFile::CONFIG_FILE_PATH; + $config = new CConfigFile($config_file_name); + $config->config = [ + 'DB' => [ +@@ -682,7 +682,7 @@ + // make zabbix.conf.php downloadable + header('Content-Type: application/x-httpd-php'); + header('Content-Disposition: attachment; filename="'.basename(CConfigFile::CONFIG_FILE_PATH).'"'); +- $config = new CConfigFile(APP::getInstance()->getRootDir().CConfigFile::CONFIG_FILE_PATH); ++ $config = new CConfigFile(CConfigFile::CONFIG_FILE_PATH); + $config->config = [ + 'DB' => [ + 'TYPE' => $this->getConfig('DB_TYPE'), diff --git a/zabbix-agent.inetd b/zabbix-agent.inetd new file mode 100644 index 0000000..a6e2ee7 --- /dev/null +++ b/zabbix-agent.inetd @@ -0,0 +1,8 @@ +SERVICE_NAME=zabbix-agent +SOCK_TYPE=stream +PROTOCOL=tcp +PORT=10000 +FLAGS=nowait +USER=zabbix +SERVER=tcpd +DAEMON=/usr/sbin/zabbix_agent diff --git a/zabbix-apache.conf b/zabbix-apache.conf new file mode 100644 index 0000000..35429ee --- /dev/null +++ b/zabbix-apache.conf @@ -0,0 +1,11 @@ +Alias /zabbix /usr/share/zabbix/frontends/php + + + Require all granted + + + Order allow,deny + Allow from all + + + diff --git a/zabbix.spec b/zabbix.spec new file mode 100644 index 0000000..d4ea014 --- /dev/null +++ b/zabbix.spec @@ -0,0 +1,554 @@ +# TODO: +# - initscript for zabbix-server, zabbix-proxy and zabbix-java +# +# Conditional build: +%bcond_without pgsql # enable PostgreSQL support +%bcond_without sqlite3 # enable sqlite3 support +%bcond_without mysql # enable MySQL support +%bcond_without java # disable java support + +%define databases %{?with_sqlite3:sqlite3} %{?with_pgsql:postgresql} %{?with_mysql:mysql} +%define any_database %{with pgsql}%{with mysql}%{with sqlite3} + +%define php_min_version 5.4.0 +Summary: Zabbix - network monitoring software +Summary(pl.UTF-8): Zabbix - oprogramowanie do monitorowania sieci +Name: zabbix +Version: 5.0.7 +Release: 0.1 +License: GPL v2+ +Group: Networking/Utilities +Source0: https://cdn.zabbix.com/zabbix/sources/stable/5.0/%{name}-%{version}.tar.gz +# Source0-md5: e0798bb1b53ab7b451556dc34c3b1827 +Source1: %{name}-apache.conf +Source2: %{name}_agentd.init +Patch0: tld.patch +Patch1: sqlite3_dbname.patch +Patch2: always_compile_ipc.patch +URL: https://www.zabbix.com/ +BuildRequires: OpenIPMI-devel +BuildRequires: autoconf +BuildRequires: automake >= 1:1.15 +BuildRequires: curl-devel +#BuildRequires: iksemel-devel +%{?with_java:BuildRequires: jdk} +BuildRequires: libevent-devel +BuildRequires: libssh2-devel +BuildRequires: libtool +BuildRequires: libxml2-devel +%{?with_mysql:BuildRequires: mysql-devel} +BuildRequires: net-snmp-devel +BuildRequires: openldap-devel >= 2.4.6 +BuildRequires: openssl-devel >= 0.9.7d +BuildRequires: pcre-devel +%{?with_pgsql:BuildRequires: postgresql-devel} +BuildRequires: rpmbuild(macros) >= 1.671 +%{?with_sqlite3:BuildRequires: sqlite3-devel} +BuildRequires: unixODBC-devel +BuildRequires: zlib-devel +Requires: %{name}-agentd = %{version}-%{release} +Requires: %{name}-web = %{version}-%{release} +Requires: %{name}-server = %{version}-%{release} +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%define _sysconfdir /etc/%{name} +%define _appdir %{_datadir}/%{name} +%define _webapps /etc/webapps +%define _webapp %{name} + +%description +Zabbix is software that monitors numerous parameters of a network and +the servers on that network. It is a useful tool for monitoring the +health and integrity of servers. Zabbix uses a flexible notification +mechanism that allows users to configure email based alerts for +virtually any event. All monitored parameters are stored in a +database. Zabbix offers excellent reporting and data visualisation +features based on the stored data. Zabbix supports both polling and +trapping. All Zabbix reports and statistics, as well as configuration +parameters, are accessed through a web-based front end. + +%description -l pl.UTF-8 +Zabbix to oprogramowanie do monitorowania licznych parametrów sieci i +serwerów sieciowych. Jest przydatny przy monitorowaniu działania +serwerów. Jorzysta z elastycznego mechanizmu powiadamiania, który +pozwala użytkownikom konfigurować powiadamianie pocztą elektroniczną +dla praktycznie wszelkich zdarzeń. Monitorowane parametry są +przechowywane w bazie danych. W oparciu o przechowywane dane Zabbix +oferuje świetne raportowanie i funkcje wizualizacji. Wspiera zarówno +odpytywanie jak i pułapkowanie. Dostęp do wszystkich raportów i +statystyk Zabbiksa jest możliwy poprzez interfejs oparty o WWW. + +%package common +Summary: Common files for Zabbix monitoring software +Summary(pl.UTF-8): Wspólne pliki dla oprogramowania monitorującego Zabbix +Group: Networking/Utilities +Requires(postun): /usr/sbin/groupdel +Requires(postun): /usr/sbin/userdel +Requires(pre): /bin/id +Requires(pre): /usr/bin/getgid +Requires(pre): /usr/sbin/groupadd +Requires(pre): /usr/sbin/useradd +Provides: group(zabbix) +Provides: user(zabbix) + +%description common +Common files for Zabbix monitoring software. + +%description common -l pl.UTF-8 +Wspólne pliki dla oprogramowania monitorującego Zabbix. + +%package agentd +Summary: Zabbix Agent +Summary(pl.UTF-8): Agenta Zabbiksa +Group: Networking/Utilities +Requires: %{name}-common = %{version}-%{release} +Obsoletes: zabbix-agent-inetd +Obsoletes: zabbix-agent-standalone +Requires(post,preun): /sbin/chkconfig +Requires: rc-scripts + +%description agentd +Zabbix agent collects data from the local system for a Zabbix server. + +%description agentd -l pl.UTF-8 +Agent zbiera dane z lokalnej maszyny dla serwera Zabbix. + +%package web +Summary: Web frontend for Zabbix +Summary(pl.UTF-8): Interfejs Web dla Zabbiksa +Group: Applications/WWW +Requires: php(bcmath) +Requires: php(core) >= %{php_min_version} +Requires: php(ctype) +Requires: php(gd) +Requires: php(gettext) +Requires: php(json) +Requires: php(mbstring) +Requires: php(pcre) +Requires: php(session) +Requires: php(sockets) +Requires: php(xml) +Requires: php(xmlreader) +Requires: php(xmlwriter) +Requires: webapps +Requires: webserver(alias) +Requires: webserver(indexfile) +Requires: webserver(php) +Suggests: php(mysql) +Suggests: php(pgsql) +Suggests: php(sqlite3) +# used with sqlite3 +Suggests: php(sysvsem) +BuildArch: noarch + +%description web +This package provides web based (PHP) frontend for Zabbix. + +%description web -l pl.UTF-8 +Ten pakiet dostarcza napisany w PHP frontend dla Zabbiksa. + +%package proxy +Summary: Zabbix proxy +Summary(pl.UTF-8): Proxy do Zabbiksa +Group: Networking/Utilities +Requires: %{name}-common = %{version}-%{release} +Requires: zabbix-proxy(db) = %{version}-%{release} + +%description proxy +This package provides the Zabbix proxy. + +%description proxy -l pl.UTF-8 +Ten pakiet zawiera proxy Zabbix. + +%package proxy-mysql +Summary: MySQL support for Zabbix proxy +Summary(pl.UTF-8): Obsługa MySQL dla proxy do Zabbiksa +Group: Networking/Utilities +Provides: %{name}-proxy(db) = %{version}-%{release} +Obsoletes: zabbix-proxy-postgresql +Obsoletes: zabbix-proxy-sqlite3 + +%description proxy-mysql +This package provides the Zabbix proxy binary with MySQL support. + +%description proxy-mysql -l pl.UTF-8 +Ten pakiet zawiera proxy Zabbix z obsługą MySQL. + +%package proxy-postgresql +Summary: PostgreSQL support for Zabbix proxy +Summary(pl.UTF-8): Obsługa PostgreSQL dla proxy do Zabbiksa +Group: Networking/Utilities +Provides: %{name}-proxy(db) = %{version}-%{release} +Obsoletes: zabbix-proxy-mysql +Obsoletes: zabbix-proxy-sqlite3 + +%description proxy-postgresql +This package provides the Zabbix proxy binary with PostgreSQL support. + +%description proxy-postgresql -l pl.UTF-8 +Ten pakiet zawiera proxy Zabbix z obsługą PostgreSQL. + +%package proxy-sqlite3 +Summary: SQLite 3 support for Zabbix proxy +Summary(pl.UTF-8): Obsługa SQLite 3 dla proxy do Zabbiksa +Group: Networking/Utilities +Provides: %{name}-proxy(db) = %{version}-%{release} +Obsoletes: zabbix-proxy-mysql +Obsoletes: zabbix-proxy-postgresql + +%description proxy-sqlite3 +This package provides the Zabbix proxy binary with SQLite 3 support. + +%description proxy-sqlite3 -l pl.UTF-8 +Ten pakiet zawiera proxy Zabbix z obsługą SQLite 3. + +%package server +Summary: Zabbix server +Summary(pl.UTF-8): Serwer Zabbiksa +Group: Networking/Utilities +Requires: %{name}-common = %{version}-%{release} +Requires: %{name}-server(db) = %{version}-%{release} +Obsoletes: zabbix-suckerd +Obsoletes: zabbix-trapper-inetd +Obsoletes: zabbix-trapper-standalone + +%description server +This package provides the Zabbix server. + +%description server -l pl.UTF-8 +Ten pakiet zawiera serwer Zabbiksa. + +%package server-mysql +Summary: MySQL support for Zabbix server +Summary(pl.UTF-8): Obsługa MySQL sla serwera Zabbiksa +Group: Networking/Utilities +Provides: %{name}-server(db) = %{version}-%{release} +Obsoletes: zabbix-server-postgresql +Obsoletes: zabbix-server-sqlite3 + +%description server-mysql +This package provides the Zabbix server binary for use with MySQL +database. + +%description server-mysql -l pl.UTF-8 +Ten pakiet zawiera serwer Zabbiksa z obsługą bazy danych MySQL. + +%package server-postgresql +Summary: PostgreSQL support for Zabbix server +Summary(pl.UTF-8): Obsługa PostgreSQL sla serwera Zabbiksa +Group: Networking/Utilities +Provides: %{name}-server(db) = %{version}-%{release} +Obsoletes: zabbix-server-mysql +Obsoletes: zabbix-server-sqlite3 + +%description server-postgresql +This package provides the Zabbix server binary for use with PostgreSQL +database. + +%description server-postgresql -l pl.UTF-8 +Ten pakiet zawiera serwer Zabbiksa z obsługą bazy danych PostgreSQL. + +%package java +Summary: Zabbix Java Gateway +Group: Networking/Utilities +Requires: %{name}-common = %{version}-%{release} + +%description java +This package provides the Zabbix Java Gateway. + +%prep +%setup -q + +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 + +%build +%{__libtoolize} +%{__aclocal} -I m4 +%{__autoconf} +%{__autoheader} +%{__automake} + +configure() { + %configure \ + --enable-agent \ + --enable-ipv6 \ + %{__enable_disable java} \ + --with-jabber \ + --with-ldap \ + --with-libcurl \ + --with-libxml2 \ + --with-net-snmp \ + --with-openipmi \ + --with-openssl \ + --with-ssh2 \ + --with-unixodbc \ + "$@" +} + +configure \ + --disable-server \ + --disable-proxy + +%{__make} + +for database in %{databases} ; do + if [ "$database" = "sqlite3" ] ; then + enable_server="" + else + enable_server="--enable-server" + fi + configure \ + --with-$database \ + $enable_server \ + --enable-proxy + + %{__make} + + if [ "$enable_server" ] ; then + %{__make} install \ + -C src/zabbix_server \ + DESTDIR=$PWD/install-${database} + fi + + %{__make} install \ + -C src/zabbix_proxy \ + DESTDIR=$PWD/install-${database} +done + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT{%{_sysconfdir},/etc/rc.d/init.d,/etc/webapps/%{_webapp},%{_appdir}} \ + $RPM_BUILD_ROOT{/var/run/zabbix,/var/log/zabbix} + +%{__make} install \ + DESTDIR=$RPM_BUILD_ROOT \ + ZJG_DEST=$RPM_BUILD_ROOT%{_datadir}/zabbix_java + +for database in %{databases} ; do + if [ "$database" != "sqlite3" ] ; then + cp -p install-$database/%{_sbindir}/zabbix_server \ + $RPM_BUILD_ROOT%{_sbindir}/zabbix_server-$database + fi + cp -p install-$database/%{_sbindir}/zabbix_proxy \ + $RPM_BUILD_ROOT%{_sbindir}/zabbix_proxy-$database +done + +if [ -n "$database" ] ; then + ln -sf %{_sbindir}/zabbix_server-$database $RPM_BUILD_ROOT%{_sbindir}/zabbix_server + ln -sf %{_sbindir}/zabbix_proxy-$database $RPM_BUILD_ROOT%{_sbindir}/zabbix_proxy +fi + +cp -r ui $RPM_BUILD_ROOT%{_appdir} + +cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf +cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf + +install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/zabbix_agentd + +mv $RPM_BUILD_ROOT%{_appdir}/ui/conf $RPM_BUILD_ROOT%{_sysconfdir}/web +ln -s %{_sysconfdir}/web $RPM_BUILD_ROOT%{_appdir}/ui/conf +touch $RPM_BUILD_ROOT%{_sysconfdir}/web/zabbix.conf.php + +%if %{with java} +mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/settings.sh $RPM_BUILD_ROOT%{_sysconfdir}/zabbix_java.conf +ln -s %{_sysconfdir}/zabbix_java.conf $RPM_BUILD_ROOT%{_datadir}/zabbix_java/settings.sh +mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback.xml $RPM_BUILD_ROOT%{_sysconfdir}/java-logback.xml +ln -s %{_sysconfdir}/java-logback.xml $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback.xml +mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback-console.xml $RPM_BUILD_ROOT%{_sysconfdir}/java-logback-console.xml +ln -s %{_sysconfdir}/java-logback-console.xml $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback-console.xml + +cat >$RPM_BUILD_ROOT%{_sbindir}/zabbix_java-start <<'EOF' +#!/bin/sh + +exec %{_datadir}/zabbix_java/startup.sh "$@" +EOF + +cat >$RPM_BUILD_ROOT%{_sbindir}/zabbix_java-stop <<'EOF' +#!/bin/sh + +exec %{_datadir}/zabbix_java/shutdown.sh "$@" +EOF +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%triggerin web -- apache < 2.2.0, apache-base +%webapp_register httpd %{_webapp} + +%triggerun web -- apache < 2.2.0, apache-base +%webapp_unregister httpd %{_webapp} + +%pre common +%groupadd -g 111 zabbix +%useradd -d / -u 111 -g zabbix -c "Zabbix User" -s /bin/false zabbix +%addusertogroup -q zabbix proc + +%postun common +if [ "$1" = "0" ]; then + %userremove zabbix + %groupremove zabbix +fi + +%post server-mysql +if [ "$1" = 1 ]; then + %banner -e %{name}-server <<-EOF + You should create database for Zabbix. + + Running these should be fine in most cases: + mysqladmin create zabbix + zcat %{_docdir}/%{name}-server-mysql-%{version}/schema.sql.gz | mysql zabbix + zcat %{_docdir}/%{name}-server-mysql-%{version}/images.sql.gz | mysql zabbix + zcat %{_docdir}/%{name}-server-mysql-%{version}/data.sql.gz | mysql zabbix +EOF +fi +ln -sf %{_sbindir}/zabbix_server-mysql %{_sbindir}/zabbix_server || : + +%post server-postgresql +if [ "$1" = 1 ]; then + %banner -e %{name}-server <<-EOF + You should create database for Zabbix. + + Running these should be fine in most cases: + + createuser zabbix + createdb -O zabbix zabbix + zcat %{_docdir}/%{name}-server-postgresql-%{version}/schema.sql.gz | psql -u zabbix zabbix + zcat %{_docdir}/%{name}-server-postgresql-%{version}/images.sql.gz | psql -u zabbix zabbix + zcat %{_docdir}/%{name}-server-postgresql-%{version}/data.sql.gz | psql -u zabbix zabbix +EOF +fi +ln -sf %{_sbindir}/zabbix_server-postgresql %{_sbindir}/zabbix_server || : + +%postun server +if [ "$1" = "0" ]; then + if [ -L %{_sbindir}/zabbix_server ] ; then + rm -f %{_sbindir}/zabbix_server || : + fi +fi + +%post agentd +/sbin/chkconfig --add zabbix_agentd +%service zabbix_agentd restart + +%preun agentd +if [ "$1" = "0" ]; then + %service -q zabbix_agentd stop + /sbin/chkconfig --del zabbix_agentd +fi + +%post proxy-mysql +ln -sf %{_sbindir}/zabbix_proxy-mysql %{_sbindir}/zabbix_proxy || : + +%post proxy-postgresql +ln -sf %{_sbindir}/zabbix_proxy-postgresql %{_sbindir}/zabbix_proxy || : + +%post proxy-sqlite3 +ln -sf %{_sbindir}/zabbix_proxy-sqlite3 %{_sbindir}/zabbix_proxy || : + +%files +%defattr(644,root,root,755) +%doc AUTHORS ChangeLog README + +%files common +%defattr(644,root,root,755) +%doc AUTHORS ChangeLog README +%attr(755,root,root) %{_bindir}/zabbix_get +%attr(755,root,root) %{_bindir}/zabbix_js +%attr(755,root,root) %{_bindir}/zabbix_sender +%attr(751,root,zabbix) %dir %{_sysconfdir} +%attr(751,root,http) %dir %{_sysconfdir}/web +%dir %{_appdir} +%dir %attr(770,root,zabbix) /var/run/zabbix +%dir %attr(775,root,zabbix) /var/log/zabbix +%{_mandir}/man1/zabbix_get* +%{_mandir}/man1/zabbix_sender* + +%files agentd +%defattr(644,root,root,755) +%doc conf/zabbix_agentd/*.conf +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_agentd.conf +%dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_agentd.conf.d +%attr(754,root,root) /etc/rc.d/init.d/zabbix_agentd +%attr(755,root,root) %{_sbindir}/zabbix_agentd +%{_mandir}/man8/zabbix_agentd* + +%files web +%defattr(644,root,root,755) +%attr(750,root,http) %dir %{_webapps}/%{_webapp} +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf +%ghost %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/zabbix.conf.php +%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/.htaccess +%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/maintenance.inc.php +%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/zabbix.conf.php.example +%{_appdir}/ui + +%if %{any_database} +%files proxy +%defattr(644,root,root,755) +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_proxy.conf +%dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_proxy.conf.d +%ghost %attr(755,root,root) %{_sbindir}/zabbix_proxy +%{_mandir}/man8/zabbix_proxy* +%endif + +%if %{with mysql} +%files proxy-mysql +%defattr(644,root,root,755) +%attr(755,root,root) %{_sbindir}/zabbix_proxy-mysql +%endif + +%if %{with pgsql} +%files proxy-postgresql +%defattr(644,root,root,755) +%attr(755,root,root) %{_sbindir}/zabbix_proxy-postgresql +%endif + +%if %{with sqlite3} +%files proxy-sqlite3 +%defattr(644,root,root,755) +%attr(755,root,root) %{_sbindir}/zabbix_proxy-sqlite3 +%endif + + +%if %{any_database} +%files server +%defattr(644,root,root,755) +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_server.conf +%dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_server.conf.d +%ghost %attr(755,root,root) %{_sbindir}/zabbix_server +%{_mandir}/man8/zabbix_server* +%endif + +%if %{with mysql} +%files server-mysql +%defattr(644,root,root,755) +%doc database/mysql/*.sql +%attr(755,root,root) %{_sbindir}/zabbix_server-mysql +%endif + +%if %{with pgsql} +%files server-postgresql +%defattr(644,root,root,755) +%doc database/postgresql/*.sql +%attr(755,root,root) %{_sbindir}/zabbix_server-postgresql +%endif + +%if %{with java} +%files java +%defattr(644,root,root,755) +%attr(755,root,root) %{_sbindir}/zabbix_java-start +%attr(755,root,root) %{_sbindir}/zabbix_java-stop +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_java.conf +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/java-logback.xml +%attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/java-logback-console.xml +%dir %{_datadir}/zabbix_java +%{_datadir}/zabbix_java/bin +%{_datadir}/zabbix_java/lib +%{_datadir}/zabbix_java/settings.sh +%attr(755,root,root) %{_datadir}/zabbix_java/shutdown.sh +%attr(755,root,root) %{_datadir}/zabbix_java/startup.sh +%endif diff --git a/zabbix_agentd.init b/zabbix_agentd.init new file mode 100755 index 0000000..9472eff --- /dev/null +++ b/zabbix_agentd.init @@ -0,0 +1,97 @@ +#!/bin/sh +# +# Starts the zabbix_agentd daemon +# +# chkconfig: 345 95 5 +# +# description: zabbix_agentd long service description +# +# processname: zabbix_agentd +# processname: zabbix_agentd + +# Source function library +. /etc/rc.d/init.d/functions + +# Get network config +. /etc/sysconfig/network + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down "Zabbix Agent" + exit 1 + fi +else + exit 0 +fi + +# Get service config - may override defaults +[ -f /etc/sysconfig/zabbix_agentd ] && . /etc/sysconfig/zabbix_agentd + +pidfile="/var/run/zabbix/zabbix_agentd.pid" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/zabbix_agentd ]; then + msg_already_running "Zabbix Agent" + return + fi + + msg_starting "Zabbix Agent" + daemon /usr/sbin/zabbix_agentd + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd +} + +stop() { + if [ ! -f /var/lock/subsys/zabbix_agentd ]; then + msg_not_running "Zabbix Agent" + return + fi + + # Stop daemons. + msg_stopping "Zabbix Agent" + killproc --pidfile $pidfile zabbix_agentd -TERM + rm -f /var/lock/subsys/zabbix_agentd +} + +condrestart() { + if [ ! -f /var/lock/subsys/zabbix_agentd ]; then + msg_not_running "Zabbix Agent" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + status) + status --pidfile $pidfile zabbix_agentd + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL