]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
use /var/lib/nagios as nagios $HOME
[packages/nagios.git] / nagios.spec
1 # TODO
2 # - /var/log/nagios/archives -> /var/log/archive/nagios
3 #
4 # Conditional build:
5 %bcond_without  gd      # without statusmap and trends, which require gd library
6 # reeenable when http://tracker.nagios.org/view.php?id=51 is fixed
7 %bcond_with     tests
8
9 Summary:        Host/service/network monitoring program
10 Summary(pl.UTF-8):      Program do monitorowania serwerów/usług/sieci
11 Summary(pt_BR.UTF-8):   Programa para monitoração de máquinas e serviços
12 Name:           nagios
13 Version:        3.2.3
14 Release:        6
15 License:        GPL v2+
16 Group:          Networking
17 Source0:        http://downloads.sourceforge.net/nagios/%{name}-%{version}.tar.gz
18 # Source0-md5:  fe1be46e6976a52acdb021a782b5d04b
19 Source1:        %{name}-apache.conf
20 Source2:        %{name}.init
21 Source3:        %{name}.sysconfig
22 Source4:        %{name}-config-20090914.tar.bz2
23 # Source4-md5:  605f1cd28c00db961dad6f529d849f16
24 Source5:        %{name}-lighttpd.conf
25 Source6:        http://www.google.com/mapfiles/shadow50.png
26 # Source6-md5:  eff99f302f21b95a900d321743fce72b
27 Source7:        http://www.google.com/mapfiles/marker.png
28 # Source7-md5:  edefef4bdfc29e1c953694651f05b466
29 Source8:        googlemap.js
30 Patch0:         %{name}-resources.patch
31 Patch1:         %{name}-iconv-in-libc.patch
32 Patch2:         %{name}-webapps.patch
33 Patch3:         %{name}-cgi-http_charset.patch
34 Patch4:         %{name}-cmd-typo.patch
35 Patch5:         config.patch
36 Patch6:         %{name}-googlemap.patch
37 Patch7:         %{name}-doc-usermacros.patch
38 Patch8:         archivelog-timeformat.patch
39 URL:            http://www.nagios.org/
40 BuildRequires:  autoconf
41 BuildRequires:  automake
42 %if %{with gd}
43 BuildRequires:  gd-devel
44 BuildRequires:  libjpeg-devel
45 BuildRequires:  libpng-devel
46 %endif
47 BuildRequires:  rpmbuild(macros) >= 1.268
48 BuildRequires:  sed >= 4.0
49 Requires(post,preun):   /sbin/chkconfig
50 Requires:       %{name}-common = %{version}-%{release}
51 Requires:       rc-scripts
52 Requires:       sh-utils
53 Suggests:       nagios-notify >= 0.13
54 Suggests:       nagios-plugin-check_load
55 Suggests:       nagios-plugin-check_ping
56 Suggests:       nagios-plugins
57 Provides:       nagios-core
58 Obsoletes:      netsaint
59 Conflicts:      iputils-ping < 1:ss020124
60 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61
62 %define         _sysconfdir     /etc/%{name}
63 %define         cgidir          %{_libdir}/%{name}/cgi
64 %define         htmldir         %{_prefix}/share/%{name}
65 %define         _localstatedir  /var/lib/%{name}
66 %define         nagioshome      %{_localstatedir}
67 %define         _webapps        /etc/webapps
68 %define         _webapp         %{name}
69
70 %description
71 Nagios is a program that will monitor hosts and services on your
72 network. It has the ability to email or page you when a problem arises
73 and when a problem is resolved. Nagios is written in C and is designed
74 to run under Linux (and some other *NIX variants) as a background
75 process, intermittently running checks on various services that you
76 specify.
77
78 The actual service checks are performed by separate "plugin" programs
79 which return the status of the checks to Nagios. The plugins are
80 available in nagios-plugins packages.
81
82 Nagios is successor to NetSaint.
83
84 %description -l pl.UTF-8
85 Nagios to program, który monitoruje serwery oraz usługi w naszej
86 sieci. Posiada on możliwość wysyłania informacji o wystąpieniu oraz
87 rozwiązaniu problemu. Nagios został napisany w C oraz jest
88 zaprojektowany do pracy pod Linuksem (i niektórymi innymi uniksami)
89 jako proces pracujący w tle i bezustannie wykonujący pewne operacje
90 sprawdzające.
91
92 Właściwe sprawdzanie jest wykonywane przez osobne programy
93 ("wtyczki"), które zwracają informacje o statusie do Nagiosa. Wtyczki
94 są dostępne na stronie w pakietach nagios-plugins.
95
96 Nagios jest następcą NetSainta.
97
98 %description -l pt_BR.UTF-8
99 O Nagios é um programa que monitora máquinas e serviços na sua rede.
100 Ele pode enviar um email ou um aviso de pager para o administrador
101 quando surgir um problema e quando ele for resolvido. Nagios é escrito
102 em C e foi desenvolvido para rodar em plataformas Linux (e algumas
103 variações de *NIX) como um processo em segundo plano, periodicamente
104 executando checagens nos diversos serviços que forem especificados.
105
106 %package common
107 Summary:        Common files needed by both nagios and nrpe
108 Summary(pl.UTF-8):      Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe
109 Group:          Networking
110 Requires(postun):       /usr/sbin/groupdel
111 Requires(postun):       /usr/sbin/userdel
112 Requires(pre):  /bin/id
113 Requires(pre):  /usr/bin/getgid
114 Requires(pre):  /usr/sbin/groupadd
115 Requires(pre):  /usr/sbin/groupmod
116 Requires(pre):  /usr/sbin/useradd
117 Requires(pre):  /usr/sbin/usermod
118 Provides:       group(nagcmd)
119 Provides:       group(nagios)
120 Provides:       user(nagios)
121
122 %description common
123 Common files needed by both nagios and nrpe.
124
125 %description common -l pl.UTF-8
126 Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe.
127
128 %package cgi
129 Summary:        CGI webinterface for Nagios
130 Summary(pl.UTF-8):      Interfejs WWW/CGI dla Nagiosa
131 Group:          Applications/WWW
132 # for dirs... and accessing local logs, nagios config
133 Requires:       %{name} = %{version}-%{release}
134 Requires:       %{name}-imagepaks
135 Requires:       %{name}-theme
136 Requires:       group(http)
137 Requires:       webapps
138 Requires:       webserver
139 Requires:       webserver(access)
140 Requires:       webserver(alias)
141 Requires:       webserver(auth)
142 Requires:       webserver(cgi)
143 Requires:       webserver(indexfile)
144 Suggests:       %{name}-doc
145
146 %description cgi
147 CGI webinterface for Nagios.
148
149 %description cgi -l pl.UTF-8
150 Interfejs CGI dla Nagiosa.
151
152 %package doc
153 Summary:        HTML Documentation for Nagios
154 Group:          Documentation
155 # does not require base
156
157 %description doc
158 HTML Documentation for Nagios.
159
160 %package theme-default
161 Summary:        Default Nagios theme
162 Summary(pl.UTF-8):      Domyślny motyw Nagiosa
163 Group:          Applications/WWW
164 Requires:       %{name}-cgi = %{version}-%{release}
165 Requires:       webserver(php)
166 Provides:       nagios-theme
167 Obsoletes:      nagios-theme
168
169 %description theme-default
170 Original theme from Nagios.
171
172 %description theme-default -l pl.UTF-8
173 Oryginalny motyw z Nagiosa.
174
175 %package devel
176 Summary:        Include files that Nagios-related applications may compile against
177 Summary(pl.UTF-8):      Pliki nagłówkowe, wykorzystywane przez aplikacje nagiosa
178 Summary(pt_BR.UTF-8):   Arquivos de cabeçalho necessários para desenvolvimento de aplicativos para o Nagios
179 Group:          Development/Libraries
180 # doesn't require base
181
182 %description devel
183 This package provides include files that Nagios-related applications
184 may compile against.
185
186 %description devel -l pl.UTF-8
187 Ten pakiet dostarcza pliki nagłówkowe, które mogą być wykorzystywane
188 przez aplikacje związane z nagiosem podczas kompilacji.
189
190 %description devel -l pt_BR.UTF-8
191 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
192 aplicativos para o Nagios.
193
194 %prep
195 %setup -q -a4
196 %patch0 -p0
197 %patch1 -p1
198 %patch2 -p1
199 %patch3 -p1
200 %patch4 -p1
201 %patch5 -p1
202 %patch6 -p1
203 %patch7 -p1
204 %patch8 -p1
205
206 find -name .cvsignore -o -name .gitignore | xargs rm
207
208 mv nagios-config-*/objects/*.cfg sample-config/template-object
209 mv nagios-config-*/*.cfg sample-config
210
211 # cleanup backups after patching
212 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
213
214 sed -i -e '
215         s,".*/var/rw/%{name}.cmd,"%{_localstatedir}/rw/%{name}.cmd,
216         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
217 ' $(find contrib/eventhandlers -type f)
218
219 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE1} > apache.conf
220 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE5} > lighttpd.conf
221
222 # fixup cgi config
223 %{__sed} -i -e '
224         # kill trailing spaces
225         s, \+$,,
226         # use real paths
227         s,/usr/local/%{name}/share,@datadir@,g
228         # we want all authorized users have default access
229         s,=nagiosadmin,=*,g
230 ' sample-config/*.cfg.in
231
232 # fixup paths in doc
233 %{__sed} -i -e '
234         s,/usr/local/%{name}/var/archives/,/var/log/%{name}/archives/,
235 ' html/docs/configmain.html
236
237 %build
238 cp -f /usr/share/automake/config.sub .
239 %{__aclocal}
240 %{__autoconf}
241 %configure \
242         CFLAGS="%{rpmcflags} %{rpmcppflags}" \
243         --bindir=%{_sbindir} \
244         --sbindir=%{cgidir} \
245         --datadir=%{htmldir} \
246         --with-nagios-user=%{name} \
247         --with-nagios-grp=%{name} \
248         --with-command-user=%{name} \
249         --with-command-grp=%{name} \
250         --with-lockfile=%{_localstatedir}/%{name}.pid \
251         --with-checkresult-dir=%{_var}/spool/%{name}/checkresults \
252         --with-ping_command='/bin/ping -n %%s -c %%d' \
253         %{!?with_gd:--disable-statusmap --disable-trends} \
254         %{?with_tests:--enable-libtap} \
255         --enable-event-broker
256
257 %{__make} all
258
259 %{?with_tests:%{__make} test}
260
261 %install
262 rm -rf $RPM_BUILD_ROOT
263 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_webapps}/%{_webapp}} \
264         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir}/rw} \
265         $RPM_BUILD_ROOT%{_sysconfdir}/{plugins,objects} \
266         $RPM_BUILD_ROOT%{_libdir}/%{name}/{eventhandlers,plugins,brokers} \
267 %if "%{_lib}" != "lib"
268         $RPM_BUILD_ROOT%{_prefix}/lib/%{name}/{eventhandlers,plugins} \
269 %endif
270
271 install -d $RPM_BUILD_ROOT%{_includedir}/%{name}
272 cp -a include/*.h       $RPM_BUILD_ROOT%{_includedir}/%{name}
273
274 %{__make} install-unstripped \
275         DESTDIR=$RPM_BUILD_ROOT \
276         INSTALL_OPTS="" \
277         INIT_OPTS="" \
278         COMMAND_OPTS=""
279
280 install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
281 cp -a %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
282
283 # install templated configuration files
284 for a in %{name}.cfg resource.cfg commands.cfg contactgroups.cfg contacts.cfg templates.cfg timeperiods.cfg; do
285         cp -a sample-config/$a $RPM_BUILD_ROOT%{_sysconfdir}
286 done
287
288 # webserver files
289 cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
290 cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
291 cp -a lighttpd.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
292 cp -a sample-config/cgi.cfg $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
293 cp -a %{SOURCE6} $RPM_BUILD_ROOT%{htmldir}/images
294 cp -a %{SOURCE7} $RPM_BUILD_ROOT%{htmldir}/images
295 cp -a %{SOURCE8} $RPM_BUILD_ROOT%{htmldir}/images
296 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
297 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
298
299 # install event handlers, sample config
300 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
301 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
302 cp -a sample-config $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
303 find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.in' | xargs rm
304
305 # Object data/cache files
306 for i in {objects.{cache,precache},{retention,status}.dat,%{name}.{tmp,pid}}; do
307         > $RPM_BUILD_ROOT%{_localstatedir}/$i
308 done
309 > $RPM_BUILD_ROOT%{_localstatedir}/rw/%{name}.cmd
310
311 install -d $RPM_BUILD_ROOT%{_docdir}/%{name}
312 mv $RPM_BUILD_ROOT{%{htmldir}/docs/*,%{_docdir}/%{name}}
313
314 %clean
315 rm -rf $RPM_BUILD_ROOT
316
317 %post
318 for i in %{_localstatedir}/{objects.{cache,precache},{retention,status}.dat}; do
319         [ ! -f $i ] && touch $i
320         chown root:nagios $i
321         chmod 664 $i
322 done
323
324 /sbin/chkconfig --add %{name}
325 %service %{name} restart "Nagios service"
326
327 %preun
328 if [ "$1" = "0" ] ; then
329         %service %{name} stop
330         /sbin/chkconfig --del %{name}
331 fi
332
333 %pre common
334 # rename group netsaint -> nagios
335 if [ "$(getgid netsaint 2>/dev/null)" = "72" ]; then
336         /usr/sbin/groupmod -n nagios netsaint
337 fi
338 # rename group nagios-data -> nagcmd
339 if [ "$(getgid nagios-data 2>/dev/null)" = "147" ]; then
340         /usr/sbin/groupmod -n nagcmd nagios-data
341 fi
342 %groupadd -g 72 nagios
343 %groupadd -g 147 -f nagcmd
344 if [ -n "$(id -u netsaint 2>/dev/null)" ] && [ "$(id -u netsaint)" = "72" ]; then
345         /usr/sbin/usermod -d %{_libdir}/%{name} -l nagios -c "Nagios Daemon" -G nagcmd netsaint
346 fi
347 %useradd -u 72 -d %{nagioshome} -s /bin/false -c "Nagios Daemon" -g nagios -G nagcmd nagios
348 # update nagios user home
349 home=$(IFS=:; set -- $(getent passwd nagios); echo $6)
350 if [ "$home" != %{nagioshome} ]; then
351         /usr/sbin/usermod -d %{nagioshome} nagios
352 fi
353
354 %postun common
355 if [ "$1" = "0" ]; then
356         %userremove nagios
357         %groupremove nagios
358         %groupremove nagcmd
359 fi
360
361 %post cgi
362 if [ "$1" = 1 ]; then
363 %banner %{name} -e <<EOF
364 NOTE:
365 You need to add user to %{_webapps}/%{_webapp}/passwd and
366 %{_webapps}/%{_webapp}/group to access Nagios via web.
367
368 EOF
369 fi
370
371 %triggerin cgi -- apache1 < 1.3.37-3, apache1-base
372 %addusertogroup http nagcmd
373 %webapp_register apache %{_webapp}
374
375 %triggerun cgi -- apache1 < 1.3.37-3, apache1-base
376 %webapp_unregister apache %{_webapp}
377
378 %triggerin cgi -- apache < 2.2.0, apache-base
379 %addusertogroup http nagcmd
380 %webapp_register httpd %{_webapp}
381
382 %triggerun cgi -- apache < 2.2.0, apache-base
383 %webapp_unregister httpd %{_webapp}
384
385 %triggerin cgi -- lighttpd
386 %addusertogroup lighttpd nagcmd
387 %webapp_register lighttpd %{_webapp}
388
389 %triggerun cgi -- lighttpd
390 %webapp_unregister lighttpd %{_webapp}
391
392 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
393 chown root:http %{_sysconfdir}/cgi.cfg
394
395 %triggerpostun -- nagios < 3.1.2-4
396 # restore lost files
397 for a in dependencies.cfg services.cfg serviceextinfo.cfg hosts.cfg hostgroups.cfg hostextinfo.cfg escalations.cfg checkcommands.cfg misccommands.cfg; do
398         if [ -f %{_sysconfdir}/$a.rpmsave -a ! -f %{_sysconfdir}/$a ]; then
399                 mv -f %{_sysconfdir}/$a{.rpmsave,}
400         fi
401 done
402 %{__sed} -i -e 's,^check_result_path=.*,check_result_path=%{_var}/spool/%{name}/checkresults,' %{_sysconfdir}/%{name}.cfg
403
404
405 %triggerpostun -- nagios-common < 3.2.3-6
406 %banner -e %{name}-common <<EOF
407
408 IMPORTANT: nagios user home changed to %{nagioshome}, you may need to move files from previous location %{_libdir}/%{name}.
409
410 EOF
411
412 %files
413 %defattr(644,root,root,755)
414 %doc Changelog README* UPGRADING INSTALLING LICENSE
415 %attr(750,root,nagios) %dir %{_sysconfdir}/objects
416
417 # leave main nagios config readable for -cgi.
418 %attr(640,root,nagcmd) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}.cfg
419
420 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/commands.cfg
421 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/contactgroups.cfg
422 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/contacts.cfg
423 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/resource.cfg
424 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/templates.cfg
425 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/timeperiods.cfg
426
427 %attr(754,root,root) /etc/rc.d/init.d/%{name}
428 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
429
430 %attr(755,root,root) %{_sbindir}/%{name}
431 %attr(755,root,root) %{_sbindir}/nagiostats
432 %dir %{_libdir}/%{name}/brokers
433
434 %attr(770,root,nagcmd) %dir %{_var}/log/%{name}
435 %attr(770,root,nagcmd) %dir %{_var}/log/%{name}/archives
436
437 %attr(770,root,nagcmd) %dir %{_localstatedir}
438 %attr(2770,root,nagcmd) %dir %{_localstatedir}/rw
439 %attr(660,nagios,nagcmd) %ghost %{_localstatedir}/rw/%{name}.cmd
440 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
441 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.precache
442 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
443 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
444 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.pid
445
446 %attr(770,root,nagios) %dir %{_var}/spool/%{name}/checkresults
447
448 %{_examplesdir}/%{name}-%{version}
449
450 %files common
451 %defattr(644,root,root,755)
452 %attr(750,root,nagcmd) %dir %{_sysconfdir}
453 %attr(750,root,nagios) %dir %{_sysconfdir}/plugins
454 %dir %{_libdir}/%{name}
455 %dir %{_libdir}/%{name}/plugins
456 %dir %{_libdir}/%{name}/eventhandlers
457
458 %if "%{_lib}" != "lib"
459 %dir %{_prefix}/lib/%{name}
460 %dir %{_prefix}/lib/%{name}/plugins
461 %dir %{_prefix}/lib/%{name}/eventhandlers
462 %endif
463
464 %attr(770,root,nagios) %dir %{_var}/spool/%{name}
465
466 %files doc
467 %defattr(644,root,root,755)
468 %{_docdir}/%{name}
469
470 %files cgi
471 %defattr(644,root,root,755)
472 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
473 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
474 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
475 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/lighttpd.conf
476 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/cgi.cfg
477 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/passwd
478 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/group
479 %dir %{cgidir}
480 %attr(755,root,root) %{cgidir}/*.cgi
481
482 %dir %{htmldir}
483 %dir %{htmldir}/includes
484 %dir %{htmldir}/images
485 %dir %{htmldir}/stylesheets
486 %{htmldir}/robots.txt
487 %{htmldir}/contexthelp
488 %{htmldir}/media
489 %{htmldir}/ssi
490 %{htmldir}/images/favicon.ico
491 %{htmldir}/images/marker.png
492 %{htmldir}/images/shadow50.png
493
494 %files theme-default
495 %defattr(644,root,root,755)
496 %{htmldir}/*.php
497 %{htmldir}/includes/*
498 %{htmldir}/images/*
499 %exclude %{htmldir}/images/favicon.ico
500 %exclude %{htmldir}/images/marker.png
501 %exclude %{htmldir}/images/shadow50.png
502 %{htmldir}/stylesheets/*
503
504 %files devel
505 %defattr(644,root,root,755)
506 %dir %{_includedir}/%{name}
507 %{_includedir}/%{name}/*.h
This page took 0.132155 seconds and 3 git commands to generate.