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