]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
- 2.0 b4
[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 Release:        0.%{_rc}.1
14 License:        GPL v2
15 Group:          Networking
16 Source0:        http://dl.sourceforge.net/nagios/%{name}-%{version}%{_rc}.tar.gz
17 # Source0-md5:  206ea26230d1360cc8871c0fee80b4c4
18 Source1:        %{name}-apache.conf
19 Source2:        %{name}.init
20 Source3:        %{name}.sysconfig
21 Source4:        http://www.nagios.org/images/favicon.ico
22 # Source4-md5:  1c4201c7da53d6c7e48251d3a9680449
23 Source5:        nagios-config-20050514.tar.bz2
24 # Source5-md5:  a2883c65377ef7beb55d48af85ec7ef7
25 Patch0:         %{name}-resources.patch
26 Patch1:         %{name}-iconv-in-libc.patch
27 Patch2:         %{name}-favicon.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 BuildRequires:  sed >= 4.0
36 %endif
37 BuildRequires:  rpmbuild(macros) >= 1.202
38 BuildRequires:  tar >= 1:1.15.1
39 PreReq:         %{name}-common = %{version}-%{release}
40 PreReq:         rc-scripts
41 PreReq:         sh-utils
42 Requires:       /bin/mail
43 Requires:       nagios-plugins
44 Requires(post,postun):  /sbin/chkconfig
45 Requires(triggerpostun):        sed >= 4.0
46 Provides:       nagios-core
47 Conflicts:      iputils-ping < 1:ss020124
48 Obsoletes:      netsaint
49 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
50
51 %define         _sysconfdir     /etc/%{name}
52 %define         _bindir         %{_prefix}/sbin
53 %define         _sbindir        %{_libdir}/%{name}/cgi
54 %define         _datadir        %{_prefix}/share/%{name}
55 %define         _localstatedir  /var/lib/%{name}
56
57 %define         _apache1dir     /etc/apache
58 %define         _apache2dir     /etc/httpd
59
60 %description
61 Nagios is a program that will monitor hosts and services on your
62 network. It has the ability to email or page you when a problem arises
63 and when a problem is resolved. Nagios is written in C and is designed
64 to run under Linux (and some other *NIX variants) as a background
65 process, intermittently running checks on various services that you
66 specify.
67
68 The actual service checks are performed by separate "plugin" programs
69 which return the status of the checks to Nagios. The plugins are
70 available in nagios-plugins packages.
71
72 Nagios is successor to NetSaint.
73
74 %description -l pl
75 Nagios to program, który monitoruje serwery oraz us³ugi w naszej
76 sieci. Posiada on mo¿liwo¶æ wysy³ania informacji o wyst±pieniu oraz
77 rozwi±zaniu problemu. Nagios zosta³ napisany w C oraz jest
78 zaprojektowany do pracy pod Linuksem (i niektórymi innymi uniksami)
79 jako proces pracuj±cy w tle i bezustannie wykonuj±cy pewne operacje
80 sprawdzaj±ce.
81
82 W³a¶ciwe sprawdzanie jest wykonywane przez osobne programy
83 ("wtyczki"), które zwracaj± informacje o statusie do Nagiosa. Wtyczki
84 s± dostêpne na stronie w pakietach nagios-plugins.
85
86 Nagios jest nastêpc± NetSainta.
87
88 %description -l pt_BR
89 O Nagios é um programa que monitora máquinas e serviços na sua rede.
90 Ele pode enviar um email ou um aviso de pager para o administrador
91 quando surgir um problema e quando ele for resolvido. Nagios é escrito
92 em C e foi desenvolvido para rodar em plataformas Linux (e algumas
93 variações de *NIX) como um processo em segundo plano, periodicamente
94 executando checagens nos diversos serviços que forem especificados.
95
96 %package common
97 Summary:        Common files needed by both nagios and nrpe
98 Summary(pl):    Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe
99 Group:          Networking
100 Requires(pre):  /usr/bin/getgid
101 Requires(pre):  /bin/id
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 Requires(postun):       /usr/sbin/groupdel
107 Requires(postun):       /usr/sbin/userdel
108 Provides:       user(nagios)
109 Provides:       group(nagios)
110 Provides:       group(nagios-data)
111
112 %description common
113 Common files needed by both nagios and nrpe.
114
115 %description common -l pl
116 Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe.
117
118 %package cgi
119 Summary:        CGI webinterface for Nagios
120 Summary(pl):    Interfejs WWW/CGI dla Nagiosa
121 Group:          Applications/WWW
122 # for dirs... and accessing local logs(?)
123 Requires:       %{name} = %{version}-%{release}
124 Requires:       %{name}-imagepaks
125 Requires:       %{name}-theme
126 Requires:       webserver = apache
127 Requires:       apache(mod_alias)
128 Requires:       apache(mod_cgi)
129 Requires:       apache(mod_auth)
130 Requires:       group(http)
131
132 %description cgi
133 CGI webinterface for Nagios.
134
135 %description cgi -l pl
136 Interfejs CGI dla Nagiosa.
137
138 %package theme-default
139 Summary:        Default Nagios theme
140 Summary(pl):    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
150 Oryginalny motyw z Nagiosa.
151
152 %package devel
153 Summary:        Include files that Nagios-related applications may compile against
154 Summary(pl):    Pliki nag³ówkowe, wykorzystywane przez aplikacje nagiosa
155 Summary(pt_BR): 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
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
168 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
169 aplicativos para o Nagios.
170
171 %prep
172 %setup -q -n %{name}-%{version}%{?_rc}
173 %patch0 -p0
174 %patch1 -p1
175 %patch2 -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 %build
183 cp -f /usr/share/automake/config.sub .
184 %{__aclocal}
185 %{__autoconf}
186 %configure \
187         --with-nagios-user=%{name} \
188         --with-nagios-grp=%{name} \
189         --with-command-user=%{name} \
190         --with-command-grp=%{name} \
191         --with-lockfile=%{_localstatedir}/%{name}.pid \
192         --with-ping_command='/bin/ping -n %%s -c %%d' \
193         %{!?with_gd:--disable-statusmap --disable-trends}
194
195 %{__make} all
196
197 %install
198 rm -rf $RPM_BUILD_ROOT
199 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_includedir}/%{name},%{_libdir}/%{name}/{eventhandlers,plugins}} \
200         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir},%{_sysconfdir}/{plugins,local},%{_examplesdir}/%{name}-%{version}}
201
202 install include/locations.h     $RPM_BUILD_ROOT%{_includedir}/%{name}
203
204 %{__make} install install-html install-init install-commandmode fullinstall \
205         DESTDIR=$RPM_BUILD_ROOT \
206         INSTALL_OPTS="" \
207         INIT_OPTS="" \
208         COMMAND_OPTS=""
209
210 install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache-%{name}.conf
211 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
212 install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
213 install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}
214
215 # install templated configuration files
216 tar jxf %{SOURCE5} --strip-components=1 -C $RPM_BUILD_ROOT%{_sysconfdir}
217
218 > $RPM_BUILD_ROOT%{_sysconfdir}/passwd
219 echo 'nagios:' > $RPM_BUILD_ROOT%{_sysconfdir}/group
220
221 # install event handlers
222 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
223
224 # Object data/cache files
225 for i in {objects.cache,{comments,downtime,retention,status}.dat,nagios.tmp}; do
226         > $RPM_BUILD_ROOT%{_localstatedir}/$i
227 done
228 > $RPM_BUILD_ROOT%{_localstatedir}/rw/nagios.cmd
229
230 %clean
231 rm -rf $RPM_BUILD_ROOT
232
233 %post
234 /sbin/chkconfig --add %{name}
235 if [ -f /var/lock/subsys/%{name} ]; then
236         /etc/rc.d/init.d/%{name} restart 1>&2
237 fi
238
239 for i in %{_localstatedir}/{objects.cache,{comments,downtime,retention,status}.dat}; do
240         [ ! -f $i ] && touch $i
241         chown root:nagios $i
242         chmod 664 $i
243 done
244
245 %preun
246 if [ "$1" = "0" ] ; then
247         if [ -f /var/lock/subsys/%{name} ]; then
248                 /etc/rc.d/init.d/%{name} stop 1>&2
249         fi
250         /sbin/chkconfig --del %{name}
251 fi
252
253 %pre common
254 if [ "`getgid netsaint`" = "72" ]; then
255         /usr/sbin/groupmod -n nagios netsaint
256 fi
257 %groupadd -g 72 nagios
258 %groupadd -g 147 -f nagios-data
259 if [ -n "`id -u netsaint 2>/dev/null`" ] && [ "`id -u netsaint`" = "72" ]; then
260         /usr/sbin/usermod -d %{_libdir}/nagios -l nagios -c "Nagios User" -G nagios-data netsaint
261 fi
262 %useradd -u 72 -d %{_libdir}/nagios -s /bin/false -c "Nagios User" -g nagios -G nagios-data nagios
263
264 %postun common
265 if [ "$1" = "0" ]; then
266         %userremove nagios
267         %groupremove nagios
268         %groupremove nagios-data
269 fi
270
271 %post cgi
272 %addusertogroup http nagios-data
273
274 # apache1
275 if [ -d %{_apache1dir}/conf.d ]; then
276         ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache1dir}/conf.d/99_%{name}.conf
277         if [ -f /var/lock/subsys/apache ]; then
278                 /etc/rc.d/init.d/apache restart 1>&2
279         fi
280 fi
281 # apache2
282 if [ -d %{_apache2dir}/httpd.conf ]; then
283         ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache2dir}/httpd.conf/99_%{name}.conf
284         if [ -f /var/lock/subsys/httpd ]; then
285                 /etc/rc.d/init.d/httpd restart 1>&2
286         fi
287 fi
288
289 if [ "$1" = 1 ]; then
290 %banner %{name} -e <<EOF
291 NOTE:
292 You need to add user to %{_sysconfdir}/passwd and %{_sysconfdir}/group to acccess nagios via web.
293
294 EOF
295 fi
296
297 %preun cgi
298 if [ "$1" = "0" ]; then
299         # apache1
300         if [ -d %{_apache1dir}/conf.d ]; then
301                 rm -f %{_apache1dir}/conf.d/99_%{name}.conf
302                 if [ -f /var/lock/subsys/apache ]; then
303                         /etc/rc.d/init.d/apache restart 1>&2
304                 fi
305         fi
306         # apache2
307         if [ -d %{_apache2dir}/httpd.conf ]; then
308                 rm -f %{_apache2dir}/httpd.conf/99_%{name}.conf
309                 if [ -f /var/lock/subsys/httpd ]; then
310                         /etc/rc.d/init.d/httpd restart 1>&2
311                 fi
312         fi
313 fi
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 if [ -f /var/lock/subsys/%{name} ]; then
355         /etc/rc.d/init.d/%{name} restart 1>&2 || :
356 fi
357
358 # apache2 config was also moved.
359 if [ -f /etc/httpd/nagios.conf.rpmsave ]; then
360         cp -f %{_sysconfdir}/apache-%{name}.conf{,.rpmnew}
361         mv -f /etc/httpd/nagios.conf.rpmsave %{_sysconfdir}/apache-%{name}.conf
362
363         if [ -f /var/lock/subsys/httpd ]; then
364                 /etc/rc.d/init.d/httpd restart 1>&2 || :
365         fi
366 fi
367
368 %banner -e %{name}-2.0 <<'EOF'
369 Please read <http://nagios.sourceforge.net/docs/2_0/whatsnew.html>
370 there are changes that no longer work in Nagios 2.0.
371
372 You could also try use <http://oss.op5.se/nagios/object_config_fix.php.gz>
373 to convert your config (yes i know it's too late to say it now, after
374 the upgrade, but still :))
375 EOF
376 #'vim
377
378 %files
379 %defattr(644,root,root,755)
380 %doc Changelog README* UPGRADING INSTALLING LICENSE
381 %doc sample-config/template-object/{bigger,minimal}.cfg
382 %attr(640,root,nagios-data) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nagios.cfg
383 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/[!n]*.cfg
384 %exclude %{_sysconfdir}/cgi.cfg
385
386 %attr(754,root,root) /etc/rc.d/init.d/%{name}
387 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
388
389 %attr(755,root,root) %{_bindir}/%{name}
390 %attr(755,root,root) %{_bindir}/nagiostats
391
392 %attr(770,root,nagios-data) %{_var}/log/%{name}
393 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}/archives
394
395 %attr(770,root,nagios-data) %dir %{_localstatedir}
396 %attr(2770,root,nagios-data) %dir %{_localstatedir}/rw
397 %attr(660,nagios,nagios-data) %ghost %{_localstatedir}/rw/nagios.cmd
398 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
399 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
400 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
401
402 %{_examplesdir}/%{name}-%{version}
403
404 %files common
405 %defattr(644,root,root,755)
406 %attr(750,root,nagios-data) %dir %{_sysconfdir}
407 %attr(2750,root,nagios) %dir %{_sysconfdir}/plugins
408 %attr(2750,root,nagios) %dir %{_sysconfdir}/local
409 %dir %{_libdir}/%{name}
410 %dir %{_libdir}/%{name}/plugins
411 %dir %{_libdir}/%{name}/eventhandlers
412
413 %files cgi
414 %defattr(644,root,root,755)
415 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache-%{name}.conf
416 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cgi.cfg
417 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/passwd
418 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/group
419 %dir %{_sbindir}
420 %attr(755,root,root) %{_sbindir}/*.cgi
421
422 %dir %{_datadir}
423 %dir %{_datadir}/images
424 %dir %{_datadir}/stylesheets
425 %{_datadir}/favicon.ico
426 %{_datadir}/robots.txt
427 %{_datadir}/contexthelp
428 %{_datadir}/docs
429 %{_datadir}/media
430 %{_datadir}/ssi
431
432 %files theme-default
433 %defattr(644,root,root,755)
434 %{_datadir}/*.html
435 %{_datadir}/images/*
436 %{_datadir}/stylesheets/*
437
438 %files devel
439 %defattr(644,root,root,755)
440 %dir %{_includedir}/%{name}
441 %{_includedir}/%{name}/*.h
This page took 0.101861 seconds and 4 git commands to generate.