]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
- create /usr/lib/nagios/{plugins,eventhandlers} for lib64 archidectures to be able...
[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:        2.9
10 Release:        2
11 License:        GPL v2
12 Group:          Networking
13 Source0:        http://dl.sourceforge.net/nagios/%{name}-%{version}.tar.gz
14 # Source0-md5:  b6e3a21c91edb063c00712c6001e15ec
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-20050514.tar.bz2
21 # Source5-md5:  a2883c65377ef7beb55d48af85ec7ef7
22 Source6:        %{name}-lighttpd.conf
23 Patch0:         %{name}-resources.patch
24 Patch1:         %{name}-iconv-in-libc.patch
25 Patch2:         %{name}-favicon.patch
26 Patch3:         %{name}-webapps.patch
27 URL:            http://www.nagios.org/
28 BuildRequires:  autoconf
29 BuildRequires:  automake
30 %if %{with gd}
31 BuildRequires:  gd-devel
32 BuildRequires:  libjpeg-devel
33 BuildRequires:  libpng-devel
34 %endif
35 BuildRequires:  rpmbuild(macros) >= 1.268
36 BuildRequires:  sed >= 4.0
37 BuildRequires:  tar >= 1:1.15.1
38 Requires(post,preun):   /sbin/chkconfig
39 Requires(triggerpostun):        sed >= 4.0
40 Requires:       %{name}-common = %{version}-%{release}
41 Requires:       /bin/mail
42 Requires:       nagios-plugins
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(alias)
128 Requires:       webserver(auth)
129 Requires:       webserver(cgi)
130 Requires:       webserver(indexfile)
131
132 %description cgi
133 CGI webinterface for Nagios.
134
135 %description cgi -l pl.UTF-8
136 Interfejs CGI dla Nagiosa.
137
138 %package theme-default
139 Summary:        Default Nagios theme
140 Summary(pl.UTF-8):      Domyślny motyw Nagiosa
141 Group:          Applications/WWW
142 Requires:       nagios-cgi = %{version}-%{release}
143 Provides:       nagios-theme
144 Obsoletes:      nagios-theme
145
146 %description theme-default
147 Original theme from Nagios.
148
149 %description theme-default -l pl.UTF-8
150 Oryginalny motyw z Nagiosa.
151
152 %package devel
153 Summary:        Include files that Nagios-related applications may compile against
154 Summary(pl.UTF-8):      Pliki nagłówkowe, wykorzystywane przez aplikacje nagiosa
155 Summary(pt_BR.UTF-8):   Arquivos de cabeçalho necessários para desenvolvimento de aplicativos para o Nagios
156 Group:          Development/Libraries
157 # doesn't require base
158
159 %description devel
160 This package provides include files that Nagios-related applications
161 may compile against.
162
163 %description devel -l pl.UTF-8
164 Ten pakiet dostarcza pliki nagłówkowe, które mogą być wykorzystywane
165 przez aplikacje związane z nagiosem podczas kompilacji.
166
167 %description devel -l pt_BR.UTF-8
168 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
169 aplicativos para o Nagios.
170
171 %prep
172 %setup -q
173 %patch0 -p0
174 %patch1 -p1
175 %patch2 -p1
176 %patch3 -p1
177
178 sed -i -e '
179         s,".*/var/rw/nagios.cmd,"%{_localstatedir}/rw/nagios.cmd,
180         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
181 ' $(find contrib/eventhandlers -type f)
182
183 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE1} > apache.conf
184 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE6} > lighttpd.conf
185
186 %build
187 cp -f /usr/share/automake/config.sub .
188 %{__aclocal}
189 %{__autoconf}
190 %configure \
191         --with-nagios-user=%{name} \
192         --with-nagios-grp=%{name} \
193         --with-command-user=%{name} \
194         --with-command-grp=%{name} \
195         --with-lockfile=%{_localstatedir}/%{name}.pid \
196         --with-ping_command='/bin/ping -n %%s -c %%d' \
197         --enable-event-broker \
198         %{!?with_gd:--disable-statusmap --disable-trends}
199
200 %{__make} all
201
202 %install
203 rm -rf $RPM_BUILD_ROOT
204 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_webapps}/%{_webapp}} \
205         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir}/rw} \
206         $RPM_BUILD_ROOT%{_sysconfdir}/{plugins,local} \
207         $RPM_BUILD_ROOT%{_libdir}/%{name}/{eventhandlers,plugins} \
208 %if "%{_lib}" != "lib"
209         $RPM_BUILD_ROOT%{_prefix}/lib/%{name}/{eventhandlers,plugins} \
210 %endif
211
212 install -d $RPM_BUILD_ROOT%{_includedir}/%{name}
213 install include/*.h     $RPM_BUILD_ROOT%{_includedir}/%{name}
214
215 %{__make} install-unstripped \
216         DESTDIR=$RPM_BUILD_ROOT \
217         INSTALL_OPTS="" \
218         INIT_OPTS="" \
219         COMMAND_OPTS=""
220
221 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
222 install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
223 install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}
224
225 # install templated configuration files
226 tar jxf %{SOURCE5} --strip-components=1 -C $RPM_BUILD_ROOT%{_sysconfdir}
227 sed -i -e 's,%{_prefix}/lib/,%{_libdir}/,' $RPM_BUILD_ROOT%{_sysconfdir}/resource.cfg
228
229 # webserver files
230 install apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
231 install apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
232 install lighttpd.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
233 mv $RPM_BUILD_ROOT{%{_sysconfdir}/cgi.cfg,%{_webapps}/%{_webapp}}
234 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
235 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
236
237 # install event handlers
238 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
239 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
240
241 # Object data/cache files
242 for i in {objects.cache,{comments,downtime,retention,status}.dat,nagios.tmp}; do
243         > $RPM_BUILD_ROOT%{_localstatedir}/$i
244 done
245 > $RPM_BUILD_ROOT%{_localstatedir}/rw/nagios.cmd
246
247 %clean
248 rm -rf $RPM_BUILD_ROOT
249
250 %post
251 for i in %{_localstatedir}/{objects.cache,{comments,downtime,retention,status}.dat}; do
252         [ ! -f $i ] && touch $i
253         chown root:nagios $i
254         chmod 664 $i
255 done
256
257 /sbin/chkconfig --add %{name}
258 %service %{name} restart "Nagios service"
259
260 %preun
261 if [ "$1" = "0" ] ; then
262         %service %{name} stop
263         /sbin/chkconfig --del %{name}
264 fi
265
266 %pre common
267 if [ "`getgid netsaint`" = "72" ]; then
268         /usr/sbin/groupmod -n nagios netsaint
269 fi
270 %groupadd -g 72 nagios
271 %groupadd -g 147 -f nagios-data
272 if [ -n "`id -u netsaint 2>/dev/null`" ] && [ "`id -u netsaint`" = "72" ]; then
273         /usr/sbin/usermod -d %{_libdir}/nagios -l nagios -c "Nagios User" -G nagios-data netsaint
274 fi
275 %useradd -u 72 -d %{_libdir}/nagios -s /bin/false -c "Nagios User" -g nagios -G nagios-data nagios
276
277 %postun common
278 if [ "$1" = "0" ]; then
279         %userremove nagios
280         %groupremove nagios
281         %groupremove nagios-data
282 fi
283
284 %post cgi
285 if [ "$1" = 1 ]; then
286 %banner %{name} -e <<EOF
287 NOTE:
288 You need to add user to %{_webapps}/%{_webapp}/passwd and
289 %{_webapps}/%{_webapp}/group to access Nagios via web.
290
291 EOF
292 fi
293
294 %triggerin cgi -- apache1 < 1.3.37-3, apache1-base
295 %addusertogroup http nagios-data
296 %webapp_register apache %{_webapp}
297
298 %triggerun cgi -- apache1 < 1.3.37-3, apache1-base
299 %webapp_unregister apache %{_webapp}
300
301 %triggerin cgi -- apache < 2.2.0, apache-base
302 %addusertogroup http nagios-data
303 %webapp_register httpd %{_webapp}
304
305 %triggerun cgi -- apache < 2.2.0, apache-base
306 %webapp_unregister httpd %{_webapp}
307
308 %triggerin cgi -- lighttpd
309 %addusertogroup lighttpd nagios-data
310 %webapp_register lighttpd %{_webapp}
311
312 %triggerun cgi -- lighttpd
313 %webapp_unregister lighttpd %{_webapp}
314
315 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
316 chown root:http %{_sysconfdir}/cgi.cfg
317
318 %triggerpostun -- nagios < 2.0-0.b3.21
319 chown root:nagios %{_sysconfdir}/*.cfg
320 chown root:nagios-data %{_sysconfdir}/nagios.cfg
321 %addusertogroup nagios nagios-data
322
323 # must unify nagios.cfg
324 sed -i -e '
325 s,^status_file=.*,status_file=%{_localstatedir}/status.dat,
326 s,^comment_file=.*,comment_file=%{_localstatedir}/comments.dat,
327 s,^downtime_file=.*,downtime_file=%{_localstatedir}/downtime.dat,
328 s,^lock_file=.*,lock_file=%{_localstatedir}/nagios.pid,
329 s,^temp_file=.*,temp_file=%{_localstatedir}/nagios.tmp,
330 s,^state_retention_file=.*,state_retention_file=%{_localstatedir}/retention.dat,
331
332 # option changes
333 s,^log_passive_service_checks=,log_passive_checks=,
334 s,^inter_check_delay_method=,service_inter_check_delay_method=,
335 s,^use_agressive_host_checking=,use_aggressive_host_checking=,
336 s,^freshness_check_interval=,service_freshness_check_interval=,
337
338 ' %{_sysconfdir}/nagios.cfg
339
340 sed -i -e '
341 s,\$DATETIME\$,$LONGDATETIME$,g
342 s,Nagios/1.2,Nagios/%{version},g
343 ' %{_sysconfdir}/misccommands.cfg
344
345 mv -f /var/log/nagios/status.log %{_localstatedir}/status.dat 2>/dev/null
346 mv -f /var/log/nagios/comment.log %{_localstatedir}/comments.dat 2>/dev/null
347 mv -f /var/log/nagios/downtime.log %{_localstatedir}/downtime.dat 2>/dev/null
348 mv -f /var/run/nagios.pid %{_localstatedir}/nagios.pid 2>/dev/null
349 mv -f /var/log/nagios/nagios.tmp %{_localstatedir}/nagios.tmp 2>/dev/null
350 mv -f /var/log/nagios/status.sav %{_localstatedir}/retention.dat 2>/dev/null
351 chown nagios:nagios %{_localstatedir}/nagios.pid 2>/dev/null
352 chown nagios:nagios-data %{_localstatedir}/rw/nagios.cmd 2>/dev/null
353
354 %service -q %{name} restart
355
356 %banner -e %{name}-2.0 <<'EOF'
357 Please read <http://nagios.sourceforge.net/docs/2_0/whatsnew.html>
358 there are changes that no longer work in Nagios 2.0.
359
360 You could also try use <http://oss.op5.se/nagios/object_config_fix.php.gz>
361 to convert your config (yes i know it's too late to say it now, after
362 the upgrade, but still :))
363 EOF
364 #'vim
365
366 # webapps trigger
367 %triggerpostun cgi -- %{name}-cgi < 2.0-0.b6.0.2
368 for i in cgi.cfg group passwd; do
369         if [ -f /etc/nagios/$i.rpmsave ]; then
370                 mv -f %{_webapps}/%{_webapp}/$i{,.rpmnew}
371                 mv -f /etc/nagios/$i.rpmsave %{_webapps}/%{_webapp}/$i
372         fi
373 done
374
375 # migrate from httpd (apache2) config dir
376 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
377         cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
378         mv -f /etc/httpd/%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
379 fi
380
381 # migrate from apache-config macros
382 if [ -f /etc/%{name}/apache-nagios.conf.rpmsave ]; then
383         if [ -d /etc/apache/webapps.d ]; then
384                 cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
385                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
386         fi
387
388         if [ -d /etc/httpd/webapps.d ]; then
389                 cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
390                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
391         fi
392         rm -f /etc/%{name}/apache-nagios.conf.rpmsave
393 fi
394
395 # place new config location, as trigger puts config only on first install, do it here.
396 if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then
397         rm -f /etc/apache/conf.d/99_%{name}.conf
398         apache_reload=1
399 fi
400 if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
401         rm -f /etc/httpd/httpd.conf/99_%{name}.conf
402         httpd_reload=1
403 fi
404
405 if [ "$apache_reload" ]; then
406         /usr/sbin/webapp register apache %{_webapp}
407         %service -q apache reload
408 fi
409 if [ "$httpd_reload" ]; then
410         /usr/sbin/webapp register httpd %{_webapp}
411         %service -q httpd reload
412 fi
413
414 %files
415 %defattr(644,root,root,755)
416 %doc Changelog README* UPGRADING INSTALLING LICENSE
417 %doc sample-config/template-object/{localhost,commands}.cfg
418 %attr(640,root,nagios-data) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nagios.cfg
419 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/[!n]*.cfg
420
421 %attr(754,root,root) /etc/rc.d/init.d/%{name}
422 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
423
424 %attr(755,root,root) %{_bindir}/%{name}
425 %attr(755,root,root) %{_bindir}/nagiostats
426
427 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}
428 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}/archives
429
430 %attr(770,root,nagios-data) %dir %{_localstatedir}
431 %attr(2770,root,nagios-data) %dir %{_localstatedir}/rw
432 %attr(660,nagios,nagios-data) %ghost %{_localstatedir}/rw/nagios.cmd
433 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
434 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
435 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
436
437 %{_examplesdir}/%{name}-%{version}
438
439 %files common
440 %defattr(644,root,root,755)
441 %attr(750,root,nagios-data) %dir %{_sysconfdir}
442 %attr(2750,root,nagios) %dir %{_sysconfdir}/plugins
443 %attr(2750,root,nagios) %dir %{_sysconfdir}/local
444 %dir %{_libdir}/%{name}
445 %dir %{_libdir}/%{name}/plugins
446 %dir %{_libdir}/%{name}/eventhandlers
447
448 %if "%{_lib}" != "lib"
449 %dir %{_prefix}/lib/%{name}
450 %dir %{_prefix}/lib/%{name}/plugins
451 %dir %{_prefix}/lib/%{name}/eventhandlers
452 %endif
453
454 %files cgi
455 %defattr(644,root,root,755)
456 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
457 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
458 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
459 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/lighttpd.conf
460 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/cgi.cfg
461 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/passwd
462 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/group
463 %dir %{_sbindir}
464 %attr(755,root,root) %{_sbindir}/*.cgi
465
466 %dir %{_datadir}
467 %dir %{_datadir}/images
468 %dir %{_datadir}/stylesheets
469 %{_datadir}/favicon.ico
470 %{_datadir}/robots.txt
471 %{_datadir}/contexthelp
472 %{_datadir}/docs
473 %{_datadir}/media
474 %{_datadir}/ssi
475
476 %files theme-default
477 %defattr(644,root,root,755)
478 %{_datadir}/*.html
479 %{_datadir}/images/*
480 %{_datadir}/stylesheets/*
481
482 %files devel
483 %defattr(644,root,root,755)
484 %dir %{_includedir}/%{name}
485 %{_includedir}/%{name}/*.h
This page took 0.090001 seconds and 4 git commands to generate.