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