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