]> TLD Linux GIT Repositories - packages/zabbix.git/blob - zabbix.spec
- fix paths
[packages/zabbix.git] / zabbix.spec
1 # TODO:
2 # - initscript for zabbix-server, zabbix-proxy and zabbix-java
3 #
4 # Conditional build:
5 %bcond_without  pgsql   # enable PostgreSQL support
6 %bcond_without  sqlite3 # enable sqlite3 support
7 %bcond_without  mysql   # enable MySQL support
8 %bcond_without  java    # disable java support
9
10 %define databases %{?with_sqlite3:sqlite3} %{?with_pgsql:postgresql} %{?with_mysql:mysql}
11 %define any_database %{with pgsql}%{with mysql}%{with sqlite3}
12
13 %define         php_min_version 5.4.0
14 Summary:        Zabbix - network monitoring software
15 Summary(pl.UTF-8):      Zabbix - oprogramowanie do monitorowania sieci
16 Name:           zabbix
17 Version:        5.0.7
18 Release:        0.1
19 License:        GPL v2+
20 Group:          Networking/Utilities
21 Source0:        https://cdn.zabbix.com/zabbix/sources/stable/5.0/%{name}-%{version}.tar.gz
22 # Source0-md5:  e0798bb1b53ab7b451556dc34c3b1827
23 Source1:        %{name}-apache.conf
24 Source2:        %{name}_agentd.init
25 Patch0:         tld.patch
26 Patch1:         sqlite3_dbname.patch
27 Patch2:         always_compile_ipc.patch
28 URL:            https://www.zabbix.com/
29 BuildRequires:  OpenIPMI-devel
30 BuildRequires:  autoconf
31 BuildRequires:  automake >= 1:1.15
32 BuildRequires:  curl-devel
33 #BuildRequires: iksemel-devel
34 %{?with_java:BuildRequires:     jdk}
35 BuildRequires:  libevent-devel
36 BuildRequires:  libssh2-devel
37 BuildRequires:  libtool
38 BuildRequires:  libxml2-devel
39 %{?with_mysql:BuildRequires:    mysql-devel}
40 BuildRequires:  net-snmp-devel
41 BuildRequires:  openldap-devel >= 2.4.6
42 BuildRequires:  openssl-devel >= 0.9.7d
43 BuildRequires:  pcre-devel
44 %{?with_pgsql:BuildRequires:    postgresql-devel}
45 BuildRequires:  rpmbuild(macros) >= 1.671
46 %{?with_sqlite3:BuildRequires:  sqlite3-devel}
47 BuildRequires:  unixODBC-devel
48 BuildRequires:  zlib-devel
49 Requires(postun):       /usr/sbin/groupdel
50 Requires(postun):       /usr/sbin/userdel
51 Requires(pre):  /bin/id
52 Requires(pre):  /usr/bin/getgid
53 Requires(pre):  /usr/sbin/groupadd
54 Requires(pre):  /usr/sbin/useradd
55 Provides:       group(zabbix)
56 Provides:       user(zabbix)
57 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
58
59 %define         _sysconfdir     /etc/%{name}
60 %define         _appdir         %{_datadir}/%{name}
61 %define         _webapps        /etc/webapps
62 %define         _webapp         %{name}
63
64 %description
65 Zabbix is software that monitors numerous parameters of a network and
66 the servers on that network. It is a useful tool for monitoring the
67 health and integrity of servers. Zabbix uses a flexible notification
68 mechanism that allows users to configure email based alerts for
69 virtually any event. All monitored parameters are stored in a
70 database. Zabbix offers excellent reporting and data visualisation
71 features based on the stored data. Zabbix supports both polling and
72 trapping. All Zabbix reports and statistics, as well as configuration
73 parameters, are accessed through a web-based front end.
74
75 %description -l pl.UTF-8
76 Zabbix to oprogramowanie do monitorowania licznych parametrów sieci i
77 serwerów sieciowych. Jest przydatny przy monitorowaniu działania
78 serwerów. Jorzysta z elastycznego mechanizmu powiadamiania, który
79 pozwala użytkownikom konfigurować powiadamianie pocztą elektroniczną
80 dla praktycznie wszelkich zdarzeń. Monitorowane parametry są
81 przechowywane w bazie danych. W oparciu o przechowywane dane Zabbix
82 oferuje świetne raportowanie i funkcje wizualizacji. Wspiera zarówno
83 odpytywanie jak i pułapkowanie. Dostęp do wszystkich raportów i
84 statystyk Zabbixa jest możliwy poprzez interfejs oparty o WWW.
85
86 %package agentd
87 Summary:        Zabbix Agent
88 Summary(pl.UTF-8):      Agenta Zabbixa
89 Group:          Networking/Utilities
90 Requires:       %{name} = %{version}-%{release}
91 Obsoletes:      zabbix-agent-inetd
92 Obsoletes:      zabbix-agent-standalone
93 Requires(post,preun):   /sbin/chkconfig
94 Requires:       rc-scripts
95
96 %description agentd
97 Zabbix agent collects data from the local system for a Zabbix server.
98
99 %description agentd -l pl.UTF-8
100 Agent zbiera dane z lokalnej maszyny dla serwera Zabbix.
101
102 %package web
103 Summary:        Web frontend for Zabbix
104 Summary(pl.UTF-8):      Interfejs Web dla Zabbixa
105 Group:          Applications/WWW
106 Requires:       php(bcmath)
107 Requires:       php(core) >= %{php_min_version}
108 Requires:       php(ctype)
109 Requires:       php(gd)
110 Requires:       php(gettext)
111 Requires:       php(json)
112 Requires:       php(mbstring)
113 Requires:       php(pcre)
114 Requires:       php(session)
115 Requires:       php(sockets)
116 Requires:       php(xml)
117 Requires:       php(xmlreader)
118 Requires:       php(xmlwriter)
119 Requires:       webapps
120 Requires:       webserver(alias)
121 Requires:       webserver(indexfile)
122 Requires:       webserver(php)
123 Suggests:       php(mysql)
124 Suggests:       php(pgsql)
125 Suggests:       php(sqlite3)
126 # used with sqlite3
127 Suggests:       php(sysvsem)
128 BuildArch:      noarch
129
130 %description web
131 This package provides web based (PHP) frontend for Zabbix.
132
133 %description web -l pl.UTF-8
134 Ten pakiet dostarcza napisany w PHP frontend dla Zabbixa.
135
136 %package proxy
137 Summary:        Zabbix proxy
138 Summary(pl.UTF-8):      Proxy do Zabbixa
139 Group:          Networking/Utilities
140 Requires:       %{name} = %{version}-%{release}
141 Requires:       zabbix-proxy(db) = %{version}-%{release}
142
143 %description proxy
144 This package provides the Zabbix proxy.
145
146 %description proxy -l pl.UTF-8
147 Ten pakiet zawiera proxy Zabbix.
148
149 %package proxy-mysql
150 Summary:        MySQL support for Zabbix proxy
151 Summary(pl.UTF-8):      Obsługa MySQL dla proxy do Zabbixa
152 Group:          Networking/Utilities
153 Provides:       %{name}-proxy(db) = %{version}-%{release}
154 Obsoletes:      zabbix-proxy-postgresql
155 Obsoletes:      zabbix-proxy-sqlite3
156
157 %description proxy-mysql
158 This package provides the Zabbix proxy binary with MySQL support.
159
160 %description proxy-mysql -l pl.UTF-8
161 Ten pakiet zawiera proxy Zabbix z obsługą MySQL.
162
163 %package proxy-postgresql
164 Summary:        PostgreSQL support for Zabbix proxy
165 Summary(pl.UTF-8):      Obsługa PostgreSQL dla proxy do Zabbixa
166 Group:          Networking/Utilities
167 Provides:       %{name}-proxy(db) = %{version}-%{release}
168 Obsoletes:      zabbix-proxy-mysql
169 Obsoletes:      zabbix-proxy-sqlite3
170
171 %description proxy-postgresql
172 This package provides the Zabbix proxy binary with PostgreSQL support.
173
174 %description proxy-postgresql -l pl.UTF-8
175 Ten pakiet zawiera proxy Zabbix z obsługą PostgreSQL.
176
177 %package proxy-sqlite3
178 Summary:        SQLite 3 support for Zabbix proxy
179 Summary(pl.UTF-8):      Obsługa SQLite 3 dla proxy do Zabbixa
180 Group:          Networking/Utilities
181 Provides:       %{name}-proxy(db) = %{version}-%{release}
182 Obsoletes:      zabbix-proxy-mysql
183 Obsoletes:      zabbix-proxy-postgresql
184
185 %description proxy-sqlite3
186 This package provides the Zabbix proxy binary with SQLite 3 support.
187
188 %description proxy-sqlite3 -l pl.UTF-8
189 Ten pakiet zawiera proxy Zabbix z obsługą SQLite 3.
190
191 %package server
192 Summary:        Zabbix server
193 Summary(pl.UTF-8):      Serwer Zabbixa
194 Group:          Networking/Utilities
195 Requires:       %{name} = %{version}-%{release}
196 Requires:       %{name}-server(db) = %{version}-%{release}
197 Obsoletes:      zabbix-suckerd
198 Obsoletes:      zabbix-trapper-inetd
199 Obsoletes:      zabbix-trapper-standalone
200
201 %description server
202 This package provides the Zabbix server.
203
204 %description server -l pl.UTF-8
205 Ten pakiet zawiera serwer Zabbixa.
206
207 %package server-mysql
208 Summary:        MySQL support for Zabbix server
209 Summary(pl.UTF-8):      Obsługa MySQL sla serwera Zabbixa
210 Group:          Networking/Utilities
211 Provides:       %{name}-server(db) = %{version}-%{release}
212 Obsoletes:      zabbix-server-postgresql
213 Obsoletes:      zabbix-server-sqlite3
214
215 %description server-mysql
216 This package provides the Zabbix server binary for use with MySQL
217 database.
218
219 %description server-mysql -l pl.UTF-8
220 Ten pakiet zawiera serwer Zabbixa z obsługą bazy danych MySQL.
221
222 %package server-postgresql
223 Summary:        PostgreSQL support for Zabbix server
224 Summary(pl.UTF-8):      Obsługa PostgreSQL sla serwera Zabbixa
225 Group:          Networking/Utilities
226 Provides:       %{name}-server(db) = %{version}-%{release}
227 Obsoletes:      zabbix-server-mysql
228 Obsoletes:      zabbix-server-sqlite3
229
230 %description server-postgresql
231 This package provides the Zabbix server binary for use with PostgreSQL
232 database.
233
234 %description server-postgresql -l pl.UTF-8
235 Ten pakiet zawiera serwer Zabbixa z obsługą bazy danych PostgreSQL.
236
237 %package java
238 Summary:        Zabbix Java Gateway
239 Group:          Networking/Utilities
240 Requires:       %{name} = %{version}-%{release}
241
242 %description java
243 This package provides the Zabbix Java Gateway.
244
245 %prep
246 %setup -q
247
248 %patch0 -p1
249 %patch1 -p1
250 %patch2 -p1
251
252 %build
253 %{__libtoolize}
254 %{__aclocal} -I m4
255 %{__autoconf}
256 %{__autoheader}
257 %{__automake}
258
259 configure() {
260         %configure \
261         --enable-agent \
262         --enable-ipv6 \
263         %{__enable_disable java} \
264         --with-jabber \
265         --with-ldap \
266         --with-libcurl \
267         --with-libxml2 \
268         --with-net-snmp \
269         --with-openipmi \
270         --with-openssl \
271         --with-ssh2 \
272         --with-unixodbc \
273         "$@"
274 }
275
276 configure \
277         --disable-server \
278         --disable-proxy
279
280 %{__make}
281
282 for database in %{databases} ; do
283         if [ "$database" = "sqlite3" ] ; then
284                 enable_server=""
285         else
286                 enable_server="--enable-server"
287         fi
288         configure \
289                 --with-$database \
290                 $enable_server \
291                 --enable-proxy
292
293         %{__make}
294
295         if [ "$enable_server" ] ; then
296                 %{__make} install \
297                         -C src/zabbix_server \
298                         DESTDIR=$PWD/install-${database}
299         fi
300
301         %{__make} install \
302                 -C src/zabbix_proxy \
303                 DESTDIR=$PWD/install-${database}
304 done
305
306 %install
307 rm -rf $RPM_BUILD_ROOT
308 install -d $RPM_BUILD_ROOT{%{_sysconfdir},/etc/rc.d/init.d,/etc/webapps/%{_webapp},%{_appdir}} \
309         $RPM_BUILD_ROOT{/var/run/zabbix,/var/log/zabbix}
310
311 %{__make} install \
312         DESTDIR=$RPM_BUILD_ROOT \
313         ZJG_DEST=$RPM_BUILD_ROOT%{_datadir}/zabbix_java
314
315 for database in %{databases} ; do
316         if [ "$database" != "sqlite3" ] ; then
317                 cp -p install-$database/%{_sbindir}/zabbix_server \
318                         $RPM_BUILD_ROOT%{_sbindir}/zabbix_server-$database
319         fi
320         cp -p install-$database/%{_sbindir}/zabbix_proxy \
321                 $RPM_BUILD_ROOT%{_sbindir}/zabbix_proxy-$database
322 done
323
324 if [ -n "$database" ] ; then
325         ln -sf %{_sbindir}/zabbix_server-$database $RPM_BUILD_ROOT%{_sbindir}/zabbix_server
326         ln -sf %{_sbindir}/zabbix_proxy-$database $RPM_BUILD_ROOT%{_sbindir}/zabbix_proxy
327 fi
328
329 cp -r ui $RPM_BUILD_ROOT%{_appdir}
330
331 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
332 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
333
334 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/zabbix_agentd
335
336 mv $RPM_BUILD_ROOT%{_appdir}/ui/conf $RPM_BUILD_ROOT%{_sysconfdir}/web
337 ln -s %{_sysconfdir}/web $RPM_BUILD_ROOT%{_appdir}/ui/conf
338 touch $RPM_BUILD_ROOT%{_sysconfdir}/web/zabbix.conf.php
339
340 %if %{with java}
341 mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/settings.sh $RPM_BUILD_ROOT%{_sysconfdir}/zabbix_java.conf
342 ln -s %{_sysconfdir}/zabbix_java.conf $RPM_BUILD_ROOT%{_datadir}/zabbix_java/settings.sh
343 mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback.xml $RPM_BUILD_ROOT%{_sysconfdir}/java-logback.xml
344 ln -s %{_sysconfdir}/java-logback.xml $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback.xml
345 mv $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback-console.xml $RPM_BUILD_ROOT%{_sysconfdir}/java-logback-console.xml
346 ln -s %{_sysconfdir}/java-logback-console.xml $RPM_BUILD_ROOT%{_datadir}/zabbix_java/lib/logback-console.xml
347
348 cat >$RPM_BUILD_ROOT%{_sbindir}/zabbix_java-start <<'EOF'
349 #!/bin/sh
350
351 exec %{_datadir}/zabbix_java/startup.sh "$@"
352 EOF
353
354 cat >$RPM_BUILD_ROOT%{_sbindir}/zabbix_java-stop <<'EOF'
355 #!/bin/sh
356
357 exec %{_datadir}/zabbix_java/shutdown.sh "$@"
358 EOF
359 %endif
360
361 %clean
362 rm -rf $RPM_BUILD_ROOT
363
364 %triggerin web -- apache < 2.2.0, apache-base
365 %webapp_register httpd %{_webapp}
366
367 %triggerun web -- apache < 2.2.0, apache-base
368 %webapp_unregister httpd %{_webapp}
369
370 %pre
371 %groupadd -g 111 zabbix
372 %useradd -d / -u 111 -g zabbix -c "Zabbix User" -s /bin/false zabbix
373 %addusertogroup -q zabbix proc
374
375 %postun
376 if [ "$1" = "0" ]; then
377         %userremove zabbix
378         %groupremove zabbix
379 fi
380
381 %post server-mysql
382 if [ "$1" = 1 ]; then
383         %banner -e %{name}-server <<-EOF
384         You should create database for Zabbix.
385
386         Running these should be fine in most cases:
387         mysqladmin create zabbix
388         zcat %{_docdir}/%{name}-server-mysql-%{version}/schema.sql.gz | mysql zabbix
389         zcat %{_docdir}/%{name}-server-mysql-%{version}/images.sql.gz | mysql zabbix
390         zcat %{_docdir}/%{name}-server-mysql-%{version}/data.sql.gz | mysql zabbix
391 EOF
392 fi
393 ln -sf %{_sbindir}/zabbix_server-mysql %{_sbindir}/zabbix_server || :
394
395 %post server-postgresql
396 if [ "$1" = 1 ]; then
397         %banner -e %{name}-server <<-EOF
398         You should create database for Zabbix.
399
400         Running these should be fine in most cases:
401
402         createuser zabbix
403         createdb -O zabbix zabbix
404         zcat %{_docdir}/%{name}-server-postgresql-%{version}/schema.sql.gz | psql -u zabbix zabbix
405         zcat %{_docdir}/%{name}-server-postgresql-%{version}/images.sql.gz | psql -u zabbix zabbix
406         zcat %{_docdir}/%{name}-server-postgresql-%{version}/data.sql.gz | psql -u zabbix zabbix
407 EOF
408 fi
409 ln -sf %{_sbindir}/zabbix_server-postgresql %{_sbindir}/zabbix_server || :
410
411 %postun server
412 if [ "$1" = "0" ]; then
413         if [ -L %{_sbindir}/zabbix_server ] ; then
414                 rm -f %{_sbindir}/zabbix_server || :
415         fi
416 fi
417
418 %post agentd
419 /sbin/chkconfig --add zabbix_agentd
420 %service zabbix_agentd restart
421
422 %preun agentd
423 if [ "$1" = "0" ]; then
424         %service -q zabbix_agentd stop
425         /sbin/chkconfig --del zabbix_agentd
426 fi
427
428 %post proxy-mysql
429 ln -sf %{_sbindir}/zabbix_proxy-mysql %{_sbindir}/zabbix_proxy || :
430
431 %post proxy-postgresql
432 ln -sf %{_sbindir}/zabbix_proxy-postgresql %{_sbindir}/zabbix_proxy || :
433
434 %post proxy-sqlite3
435 ln -sf %{_sbindir}/zabbix_proxy-sqlite3 %{_sbindir}/zabbix_proxy || :
436
437 %files
438 %defattr(644,root,root,755)
439 %doc AUTHORS ChangeLog README
440 %attr(755,root,root) %{_bindir}/zabbix_get
441 %attr(755,root,root) %{_bindir}/zabbix_js
442 %attr(755,root,root) %{_bindir}/zabbix_sender
443 %attr(751,root,zabbix) %dir %{_sysconfdir}
444 %attr(751,root,http) %dir %{_sysconfdir}/web
445 %dir %{_appdir}
446 %dir %attr(770,root,zabbix) /var/run/zabbix
447 %dir %attr(775,root,zabbix) /var/log/zabbix
448 %{_mandir}/man1/zabbix_get*
449 %{_mandir}/man1/zabbix_sender*
450
451 %files agentd
452 %defattr(644,root,root,755)
453 %doc conf/zabbix_agentd/*.conf
454 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_agentd.conf
455 %dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_agentd.conf.d
456 %attr(754,root,root) /etc/rc.d/init.d/zabbix_agentd
457 %attr(755,root,root) %{_sbindir}/zabbix_agentd
458 %{_mandir}/man8/zabbix_agentd*
459
460 %files web
461 %defattr(644,root,root,755)
462 %attr(750,root,http) %dir %{_webapps}/%{_webapp}
463 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
464 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
465 %ghost %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/zabbix.conf.php
466 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/.htaccess
467 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/maintenance.inc.php
468 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/web/zabbix.conf.php.example
469 %{_appdir}/ui
470
471 %if %{any_database}
472 %files proxy
473 %defattr(644,root,root,755)
474 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_proxy.conf
475 %dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_proxy.conf.d
476 %ghost %attr(755,root,root) %{_sbindir}/zabbix_proxy
477 %{_mandir}/man8/zabbix_proxy*
478 %endif
479
480 %if %{with mysql}
481 %files proxy-mysql
482 %defattr(644,root,root,755)
483 %attr(755,root,root) %{_sbindir}/zabbix_proxy-mysql
484 %endif
485
486 %if %{with pgsql}
487 %files proxy-postgresql
488 %defattr(644,root,root,755)
489 %attr(755,root,root) %{_sbindir}/zabbix_proxy-postgresql
490 %endif
491
492 %if %{with sqlite3}
493 %files proxy-sqlite3
494 %defattr(644,root,root,755)
495 %attr(755,root,root) %{_sbindir}/zabbix_proxy-sqlite3
496 %endif
497
498
499 %if %{any_database}
500 %files server
501 %defattr(644,root,root,755)
502 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_server.conf
503 %dir %attr(751,root,zabbix) %{_sysconfdir}/zabbix_server.conf.d
504 %ghost %attr(755,root,root) %{_sbindir}/zabbix_server
505 %{_mandir}/man8/zabbix_server*
506 %endif
507
508 %if %{with mysql}
509 %files server-mysql
510 %defattr(644,root,root,755)
511 %doc database/mysql/*.sql
512 %attr(755,root,root) %{_sbindir}/zabbix_server-mysql
513 %endif
514
515 %if %{with pgsql}
516 %files server-postgresql
517 %defattr(644,root,root,755)
518 %doc database/postgresql/*.sql
519 %attr(755,root,root) %{_sbindir}/zabbix_server-postgresql
520 %endif
521
522 %if %{with java}
523 %files java
524 %defattr(644,root,root,755)
525 %attr(755,root,root) %{_sbindir}/zabbix_java-start
526 %attr(755,root,root) %{_sbindir}/zabbix_java-stop
527 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/zabbix_java.conf
528 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/java-logback.xml
529 %attr(640,root,zabbix) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/java-logback-console.xml
530 %dir %{_datadir}/zabbix_java
531 %{_datadir}/zabbix_java/bin
532 %{_datadir}/zabbix_java/lib
533 %{_datadir}/zabbix_java/settings.sh
534 %attr(755,root,root) %{_datadir}/zabbix_java/shutdown.sh
535 %attr(755,root,root) %{_datadir}/zabbix_java/startup.sh
536 %endif