]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
- use webapps framework
[packages/nagios.git] / nagios.spec
1 # TODO
2 # - check if default config works out of box
3 #
4 # Conditional build:
5 %bcond_without  gd      # without statusmap and trends, which require gd library
6 #
7 Summary:        Host/service/network monitoring program
8 Summary(pl):    Program do monitorowania serwerów/us³ug/sieci
9 Summary(pt_BR): Programa para monitoração de máquinas e serviços
10 Name:           nagios
11 Version:        2.0
12 %define _rc     b4
13 %define _rel    3.10
14 Release:        0.%{_rc}.%{_rel}
15 License:        GPL v2
16 Group:          Networking
17 Source0:        http://dl.sourceforge.net/nagios/%{name}-%{version}%{_rc}.tar.gz
18 # Source0-md5:  206ea26230d1360cc8871c0fee80b4c4
19 Source1:        %{name}-apache.conf
20 Source2:        %{name}.init
21 Source3:        %{name}.sysconfig
22 Source4:        http://www.nagios.org/images/favicon.ico
23 # Source4-md5:  1c4201c7da53d6c7e48251d3a9680449
24 Source5:        %{name}-config-20050514.tar.bz2
25 # Source5-md5:  a2883c65377ef7beb55d48af85ec7ef7
26 Patch0:         %{name}-resources.patch
27 Patch1:         %{name}-iconv-in-libc.patch
28 Patch2:         %{name}-favicon.patch
29 Patch3:         %{name}-webapps.patch
30 URL:            http://www.nagios.org/
31 BuildRequires:  autoconf
32 BuildRequires:  automake
33 %if %{with gd}
34 BuildRequires:  gd-devel
35 BuildRequires:  libjpeg-devel
36 BuildRequires:  libpng-devel
37 %endif
38 BuildRequires:  sed >= 4.0
39 BuildRequires:  rpmbuild(macros) >= 1.264
40 BuildRequires:  tar >= 1:1.15.1
41 Requires:       %{name}-common = %{version}-%{release}
42 Requires:       rc-scripts
43 Requires:       sh-utils
44 Requires:       /bin/mail
45 Requires:       nagios-plugins
46 Requires(post,postun):  /sbin/chkconfig
47 Requires(triggerpostun):        sed >= 4.0
48 Provides:       nagios-core
49 Conflicts:      iputils-ping < 1:ss020124
50 Obsoletes:      netsaint
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
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
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):    Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe
100 Group:          Networking
101 Requires(pre):  /usr/bin/getgid
102 Requires(pre):  /bin/id
103 Requires(pre):  /usr/sbin/groupadd
104 Requires(pre):  /usr/sbin/groupmod
105 Requires(pre):  /usr/sbin/useradd
106 Requires(pre):  /usr/sbin/usermod
107 Requires(postun):       /usr/sbin/groupdel
108 Requires(postun):       /usr/sbin/userdel
109 Provides:       user(nagios)
110 Provides:       group(nagios)
111 Provides:       group(nagios-data)
112
113 %description common
114 Common files needed by both nagios and nrpe.
115
116 %description common -l pl
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):    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:       webapps
128 Requires:       webserver = apache
129 Requires:       apache(mod_alias)
130 Requires:       apache(mod_cgi)
131 Requires:       apache(mod_auth)
132 Requires:       group(http)
133
134 %description cgi
135 CGI webinterface for Nagios.
136
137 %description cgi -l pl
138 Interfejs CGI dla Nagiosa.
139
140 %package theme-default
141 Summary:        Default Nagios theme
142 Summary(pl):    Domy¶lny motyw Nagiosa
143 Group:          Applications/WWW
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
152 Oryginalny motyw z Nagiosa.
153
154 %package devel
155 Summary:        Include files that Nagios-related applications may compile against
156 Summary(pl):    Pliki nag³ówkowe, wykorzystywane przez aplikacje nagiosa
157 Summary(pt_BR): 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
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
170 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
171 aplicativos para o Nagios.
172
173 %prep
174 %setup -q -n %{name}-%{version}%{?_rc}
175 %patch0 -p0
176 %patch1 -p1
177 %patch2 -p1
178 %patch3 -p1
179
180 sed -i -e '
181         s,".*/var/rw/nagios.cmd,"%{_localstatedir}/rw/nagios.cmd,
182         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
183 ' $(find contrib/eventhandlers -type f)
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         %{!?with_gd:--disable-statusmap --disable-trends}
197
198 %{__make} all
199
200 %install
201 rm -rf $RPM_BUILD_ROOT
202 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_includedir}/%{name},%{_libdir}/%{name}/{eventhandlers,plugins}} \
203         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir},%{_sysconfdir}/{plugins,local},%{_examplesdir}/%{name}-%{version}} \
204         $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
205
206 install include/locations.h     $RPM_BUILD_ROOT%{_includedir}/%{name}
207
208 %{__make} install install-html install-init install-commandmode fullinstall \
209         DESTDIR=$RPM_BUILD_ROOT \
210         INSTALL_OPTS="" \
211         INIT_OPTS="" \
212         COMMAND_OPTS=""
213
214 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
215 install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
216 install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}
217
218 # install templated configuration files
219 tar jxf %{SOURCE5} --strip-components=1 -C $RPM_BUILD_ROOT%{_sysconfdir}
220
221 # webserver files
222 install %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
223 install %{SOURCE1} $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
224 mv $RPM_BUILD_ROOT{%{_sysconfdir}/cgi.cfg,%{_webapps}/%{_webapp}}
225 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
226 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
227
228 # install event handlers
229 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
230
231 # Object data/cache files
232 for i in {objects.cache,{comments,downtime,retention,status}.dat,nagios.tmp}; do
233         > $RPM_BUILD_ROOT%{_localstatedir}/$i
234 done
235 > $RPM_BUILD_ROOT%{_localstatedir}/rw/nagios.cmd
236
237 %clean
238 rm -rf $RPM_BUILD_ROOT
239
240 %post
241 /sbin/chkconfig --add %{name}
242 if [ -f /var/lock/subsys/%{name} ]; then
243         /etc/rc.d/init.d/%{name} restart 1>&2
244 fi
245
246 for i in %{_localstatedir}/{objects.cache,{comments,downtime,retention,status}.dat}; do
247         [ ! -f $i ] && touch $i
248         chown root:nagios $i
249         chmod 664 $i
250 done
251
252 %preun
253 if [ "$1" = "0" ] ; then
254         if [ -f /var/lock/subsys/%{name} ]; then
255                 /etc/rc.d/init.d/%{name} stop 1>&2
256         fi
257         /sbin/chkconfig --del %{name}
258 fi
259
260 %pre common
261 if [ "`getgid netsaint`" = "72" ]; then
262         /usr/sbin/groupmod -n nagios netsaint
263 fi
264 %groupadd -g 72 nagios
265 %groupadd -g 147 -f nagios-data
266 if [ -n "`id -u netsaint 2>/dev/null`" ] && [ "`id -u netsaint`" = "72" ]; then
267         /usr/sbin/usermod -d %{_libdir}/nagios -l nagios -c "Nagios User" -G nagios-data netsaint
268 fi
269 %useradd -u 72 -d %{_libdir}/nagios -s /bin/false -c "Nagios User" -g nagios -G nagios-data nagios
270
271 %postun common
272 if [ "$1" = "0" ]; then
273         %userremove nagios
274         %groupremove nagios
275         %groupremove nagios-data
276 fi
277
278 %post cgi
279 if [ "$1" = 1 ]; then
280 %banner %{name} -e <<EOF
281 NOTE:
282 You need to add user to %{_webapps}/%{_webapp}/passwd and
283 %{_webapps}/%{_webapp}/group to access nagios via web.
284
285 EOF
286 fi
287
288 %triggerin cgi -- apache1
289 %addusertogroup http nagios-data
290 %webapp_register apache %{_webapp}
291
292 %triggerun cgi -- apache1
293 %webapp_unregister apache %{_webapp}
294
295 %triggerin cgi -- apache >= 2.0.0
296 %addusertogroup http nagios-data
297 %webapp_register httpd %{_webapp}
298
299 %triggerun -- apache >= 2.0.0
300 %webapp_unregister httpd %{_webapp}
301
302 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
303 chown root:http %{_sysconfdir}/cgi.cfg
304
305 %triggerpostun -- nagios < 2.0-0.b3.21
306 chown root:nagios %{_sysconfdir}/*.cfg
307 chown root:nagios-data %{_sysconfdir}/nagios.cfg
308 %addusertogroup nagios nagios-data
309
310 # must unify nagios.cfg
311 sed -i -e '
312 s,^status_file=.*,status_file=%{_localstatedir}/status.dat,
313 s,^comment_file=.*,comment_file=%{_localstatedir}/comments.dat,
314 s,^downtime_file=.*,downtime_file=%{_localstatedir}/downtime.dat,
315 s,^lock_file=.*,lock_file=%{_localstatedir}/nagios.pid,
316 s,^temp_file=.*,temp_file=%{_localstatedir}/nagios.tmp,
317 s,^state_retention_file=.*,state_retention_file=%{_localstatedir}/retention.dat,
318
319 # option changes
320 s,^log_passive_service_checks=,log_passive_checks=,
321 s,^inter_check_delay_method=,service_inter_check_delay_method=,
322 s,^use_agressive_host_checking=,use_aggressive_host_checking=,
323 s,^freshness_check_interval=,service_freshness_check_interval=,
324
325 ' %{_sysconfdir}/nagios.cfg
326
327 sed -i -e '
328 s,\$DATETIME\$,$LONGDATETIME$,g
329 s,Nagios/1.2,Nagios/%{version},g
330 ' %{_sysconfdir}/misccommands.cfg
331
332 mv -f /var/log/nagios/status.log %{_localstatedir}/status.dat 2>/dev/null
333 mv -f /var/log/nagios/comment.log %{_localstatedir}/comments.dat 2>/dev/null
334 mv -f /var/log/nagios/downtime.log %{_localstatedir}/downtime.dat 2>/dev/null
335 mv -f /var/run/nagios.pid %{_localstatedir}/nagios.pid 2>/dev/null
336 mv -f /var/log/nagios/nagios.tmp %{_localstatedir}/nagios.tmp 2>/dev/null
337 mv -f /var/log/nagios/status.sav %{_localstatedir}/retention.dat 2>/dev/null
338 chown nagios:nagios %{_localstatedir}/nagios.pid 2>/dev/null
339 chown nagios:nagios-data %{_localstatedir}/rw/nagios.cmd 2>/dev/null
340
341 %service %{name} restart
342
343 %banner -e %{name}-2.0 <<'EOF'
344 Please read <http://nagios.sourceforge.net/docs/2_0/whatsnew.html>
345 there are changes that no longer work in Nagios 2.0.
346
347 You could also try use <http://oss.op5.se/nagios/object_config_fix.php.gz>
348 to convert your config (yes i know it's too late to say it now, after
349 the upgrade, but still :))
350 EOF
351 #'vim
352
353 # webapps trigger
354 %triggerpostun cgi -- %{name}-cgi < 2.0-0.b4.3.8
355 for i in cgi.cfg group passwd; do
356         if [ -f /etc/nagios/$i.rpmsave ]; then
357                 mv -f %{_webapps}/%{_webapp}/$i{,.rpmnew}
358                 mv -f /etc/nagios/$i.rpmsave %{_webapps}/%{_webapp}/$i
359         fi
360 done
361
362 # migrate from httpd (apache2) config dir
363 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
364         cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
365         mv -f /etc/httpd/%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
366 fi
367
368 # migrate from apache-config macros
369 if [ -f /etc/%{name}/apache-nagios.conf.rpmsave ]; then
370         if [ -d /etc/apache/webapps.d ]; then
371                 cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
372                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
373         fi
374
375         if [ -d /etc/httpd/webapps.d ]; then
376                 cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
377                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
378         fi
379         rm -f /etc/%{name}/apache-nagios.conf.rpmsave
380 fi
381
382 # place new config location, as trigger puts config only on first install, do it here.
383 # apache1
384 if [ -d /etc/apache/webapps.d ]; then
385         /usr/sbin/webapp register apache %{_webapp}
386         apache_reload=1
387 fi
388 # apache2
389 if [ -d /etc/httpd/webapps.d ]; then
390         /usr/sbin/webapp register httpd %{_webapp}
391         httpd_reload=1
392 fi
393
394 if [ "$httpd_reload" ]; then
395         if [ -f /var/lock/subsys/httpd ]; then
396                 /etc/rc.d/init.d/httpd reload 1>&2
397         fi
398 fi
399 if [ "$apache_reload" ]; then
400         if [ -f /var/lock/subsys/apache ]; then
401                 /etc/rc.d/init.d/apache reload 1>&2
402         fi
403 fi
404
405 %files
406 %defattr(644,root,root,755)
407 %doc Changelog README* UPGRADING INSTALLING LICENSE
408 %doc sample-config/template-object/{bigger,minimal}.cfg
409 %attr(640,root,nagios-data) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nagios.cfg
410 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/[!n]*.cfg
411
412 %attr(754,root,root) /etc/rc.d/init.d/%{name}
413 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
414
415 %attr(755,root,root) %{_bindir}/%{name}
416 %attr(755,root,root) %{_bindir}/nagiostats
417
418 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}
419 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}/archives
420
421 %attr(770,root,nagios-data) %dir %{_localstatedir}
422 %attr(2770,root,nagios-data) %dir %{_localstatedir}/rw
423 %attr(660,nagios,nagios-data) %ghost %{_localstatedir}/rw/nagios.cmd
424 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
425 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
426 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
427
428 %{_examplesdir}/%{name}-%{version}
429
430 %files common
431 %defattr(644,root,root,755)
432 %attr(750,root,nagios-data) %dir %{_sysconfdir}
433 %attr(2750,root,nagios) %dir %{_sysconfdir}/plugins
434 %attr(2750,root,nagios) %dir %{_sysconfdir}/local
435 %dir %{_libdir}/%{name}
436 %dir %{_libdir}/%{name}/plugins
437 %dir %{_libdir}/%{name}/eventhandlers
438
439 %files cgi
440 %defattr(644,root,root,755)
441 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
442 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
443 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
444 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/cgi.cfg
445 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/passwd
446 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/group
447 %dir %{_sbindir}
448 %attr(755,root,root) %{_sbindir}/*.cgi
449
450 %dir %{_datadir}
451 %dir %{_datadir}/images
452 %dir %{_datadir}/stylesheets
453 %{_datadir}/favicon.ico
454 %{_datadir}/robots.txt
455 %{_datadir}/contexthelp
456 %{_datadir}/docs
457 %{_datadir}/media
458 %{_datadir}/ssi
459
460 %files theme-default
461 %defattr(644,root,root,755)
462 %{_datadir}/*.html
463 %{_datadir}/images/*
464 %{_datadir}/stylesheets/*
465
466 %files devel
467 %defattr(644,root,root,755)
468 %dir %{_includedir}/%{name}
469 %{_includedir}/%{name}/*.h
This page took 0.072056 seconds and 4 git commands to generate.