1 |
%define nsusr nagios |
2 |
%define nsgrp nagios |
3 |
%define cmdusr apache |
4 |
%define cmdgrp apache |
5 |
%define _disable_ld_no_undefined 1 |
6 |
|
7 |
Summary: Host/service/network monitoring program |
8 |
Name: nagios |
9 |
Epoch: 1 |
10 |
Version: 4.4.3 |
11 |
Release: %mkrel 2 |
12 |
License: GPLv2 |
13 |
Group: Monitoring |
14 |
URL: http://www.nagios.org/ |
15 |
Source0: http://prdownloads.sourceforge.net/nagios/%{name}-%{version}.tar.gz |
16 |
Source1: %{name}.service |
17 |
Source2: %{name}.tmpfiles |
18 |
Source5: favicon.ico |
19 |
Patch1: nagios-4.0.0-conf.d.patch |
20 |
Patch2: rpmarch.patch |
21 |
Requires(post): rpm-helper |
22 |
Requires(preun): rpm-helper |
23 |
Requires(pre): rpm-helper |
24 |
Requires(postun): rpm-helper |
25 |
Requires: nagios-plugins |
26 |
Recommends: nagios-check_http |
27 |
Recommends: nagios-check_ssh |
28 |
Recommends: nagios-check_ping |
29 |
Recommends: nagios-check_disk |
30 |
Recommends: nagios-check_load |
31 |
Recommends: nagios-check_procs |
32 |
Recommends: nagios-check_users |
33 |
Recommends: nagios-check_swap |
34 |
BuildRequires: pkgconfig(gdlib) |
35 |
BuildRequires: imagemagick |
36 |
BuildRequires: pkgconfig(libjpeg) |
37 |
BuildRequires: libtool-devel |
38 |
BuildRequires: multiarch-utils >= 1.0.3 |
39 |
BuildRequires: perl-devel |
40 |
Provides: nagios-agent |
41 |
|
42 |
%description |
43 |
Nagios is a program that will monitor hosts and services on your |
44 |
network. It has the ability to email or page you when a problem |
45 |
arises and when a problem is resolved. Nagios is written in C and |
46 |
is designed to run under Linux (and some other *NIX variants) as a |
47 |
background process, intermittently running checks on various |
48 |
services that you specify. |
49 |
|
50 |
The actual service checks are performed by separate "plugin" |
51 |
programs which return the status of the checks to Nagios. |
52 |
|
53 |
This package provide core programs for nagios. The web interface, |
54 |
documentation, and development files are built as separate |
55 |
packages |
56 |
|
57 |
%package www |
58 |
Summary: Provides the HTML and CGI files for the Nagios web interface |
59 |
Group: Networking/WWW |
60 |
Requires: %{name} = %{epoch}:%{version}-%{release} |
61 |
Requires: nail |
62 |
Requires: traceroute |
63 |
Requires: apache-mod_php |
64 |
Epoch: %{epoch} |
65 |
|
66 |
%description www |
67 |
Nagios is a program that will monitor hosts and services on your network. It |
68 |
has the ability to email or page you when a problem arises and when a problem |
69 |
is resolved. Nagios is written in C and is designed to run under Linux (and |
70 |
some other *NIX variants) as a background process, intermittently running |
71 |
checks on various services that you specify. |
72 |
|
73 |
Several CGI programs are included with Nagios in order to allow you to view the |
74 |
current service status, problem history, notification history, and log file via |
75 |
the web. This package provides the HTML and CGI files for the Nagios web |
76 |
interface. In addition, HTML documentation is included in this package |
77 |
|
78 |
%package devel |
79 |
Group: Development/C |
80 |
Summary: Provides include files that Nagios-related applications may compile against |
81 |
Epoch: %{epoch} |
82 |
|
83 |
%description devel |
84 |
Nagios is a program that will monitor hosts and services on your network. It |
85 |
has the ability to email or page you when a problem arises and when a problem |
86 |
is resolved. Nagios is written in C and is designed to run under Linux (and |
87 |
some other *NIX variants) as a background process, intermittently running |
88 |
checks on various services that you specify. |
89 |
|
90 |
This package provides include files that Nagios-related applications may |
91 |
compile against. |
92 |
|
93 |
%prep |
94 |
%setup -q |
95 |
%autopatch -p1 |
96 |
|
97 |
%build |
98 |
%serverbuild |
99 |
|
100 |
export CFLAGS="%{optflags} -fPIC" |
101 |
export CXXFLAGS="%{optflags} -fPIC" |
102 |
export FFLAGS="%{optflags} -fPIC" |
103 |
%configure2_5x \ |
104 |
--with-httpd-conf=%{_webappconfdir} \ |
105 |
--with-checkresult-dir=/var/spool/nagios/checkresults \ |
106 |
--with-temp-dir=/tmp \ |
107 |
--exec-prefix=%{_sbindir} \ |
108 |
--bindir=%{_sbindir} \ |
109 |
--sbindir=%{_libdir}/nagios/cgi \ |
110 |
--libexecdir=%{_libdir}/nagios/plugins \ |
111 |
--datadir=%{_datadir}/nagios \ |
112 |
--sysconfdir=%{_sysconfdir}/nagios \ |
113 |
--localstatedir=/var/log/nagios \ |
114 |
--with-lockfile=/run/nagios/nagios.pid \ |
115 |
--with-mail=/bin/mail \ |
116 |
--with-nagios-user=%{nsusr} \ |
117 |
--with-nagios-group=%{nsgrp} \ |
118 |
--with-command-user=%{cmdusr} \ |
119 |
--with-command-grp=%{cmdgrp} \ |
120 |
--with-cgiurl=/nagios/cgi-bin \ |
121 |
--with-htmurl=/nagios \ |
122 |
--with-gd-lib=%{_libdir} \ |
123 |
--with-gd-inc=%{_includedir} |
124 |
|
125 |
# bug |
126 |
perl -pi -e "s|/var/log/nagios/spool/checkresults|/var/spool/nagios/checkresults|g" include/locations.h |
127 |
|
128 |
%make_build all |
129 |
|
130 |
pushd contrib |
131 |
make convertcfg |
132 |
make daemonchk.cgi |
133 |
popd |
134 |
|
135 |
%install |
136 |
make \ |
137 |
DESTDIR=%{buildroot} \ |
138 |
BINDIR=%{_sbindir} \ |
139 |
CFGDIR=%{_sysconfdir}/nagios \ |
140 |
CGIDIR=%{_libdir}/nagios/cgi \ |
141 |
COMMAND_OPTS="" \ |
142 |
HTMLDIR=%{_datadir}/nagios/www \ |
143 |
INIT_OPTS="" \ |
144 |
INSTALL=install \ |
145 |
INSTALL_OPTS="" \ |
146 |
LOGDIR=/var/log/nagios \ |
147 |
STRIP=/bin/true \ |
148 |
install \ |
149 |
install-devel \ |
150 |
install-config |
151 |
|
152 |
pushd contrib |
153 |
make \ |
154 |
DESTDIR=%{buildroot} \ |
155 |
BINDIR=%{_sbindir} \ |
156 |
CFGDIR=%{_sysconfdir}/nagios \ |
157 |
CGIDIR=%{_libdir}/nagios/cgi \ |
158 |
COMMAND_OPTS="" \ |
159 |
HTMLDIR=%{_datadir}/nagios/www \ |
160 |
INIT_OPTS="" \ |
161 |
INSTALL=install \ |
162 |
INSTALL_OPTS="" \ |
163 |
LOGDIR=/var/log/nagios \ |
164 |
install |
165 |
popd |
166 |
|
167 |
# fix strange perms |
168 |
find %{buildroot}%{_datadir}/nagios -type d | xargs chmod 755 |
169 |
find %{buildroot}%{_datadir}/nagios -type f | xargs chmod 644 |
170 |
find %{buildroot}%{_sysconfdir}/nagios -type d | xargs chmod 755 |
171 |
find %{buildroot}%{_sysconfdir}/nagios -type f | xargs chmod 644 |
172 |
chmod 755 \ |
173 |
%{buildroot}%{_libdir}/nagios/cgi/* \ |
174 |
%{buildroot}%{_sbindir}/* |
175 |
|
176 |
# fix docs |
177 |
cp sample-config/README README.sample-config |
178 |
cp sample-config/template-object/README README.template-object |
179 |
|
180 |
# install headers |
181 |
install -d -m 755 %{buildroot}%{_includedir}/nagios |
182 |
install -m 644 include/locations.h %{buildroot}%{_includedir}/nagios/ |
183 |
%multiarch_includes %{buildroot}%{_includedir}/nagios/locations.h |
184 |
|
185 |
install -d -m 755 %{buildroot}/var/spool/nagios/checkresults |
186 |
|
187 |
# add a placeholder directory for all object configuration files |
188 |
install -d -m 755 %{buildroot}%{_sysconfdir}/nagios/conf.d |
189 |
|
190 |
# transfert relevant files from sample configuration there |
191 |
for file in commands contacts timeperiods templates localhost; do |
192 |
mv %{buildroot}%{_sysconfdir}/nagios/objects/$file.cfg \ |
193 |
%{buildroot}%{_sysconfdir}/nagios/conf.d |
194 |
done |
195 |
|
196 |
# drop others |
197 |
rm -rf %{buildroot}%{_sysconfdir}/nagios/objects |
198 |
|
199 |
# adapt default configuration |
200 |
perl -pi \ |
201 |
-e 's|^check_for_updates=1|check_for_updates=0|;' \ |
202 |
-e 's|^#query_socket=|query_socket=|;' \ |
203 |
-e 's|=/var/log/nagios/rw|=/var/spool/nagios|;' \ |
204 |
%{buildroot}%{_sysconfdir}/nagios/nagios.cfg |
205 |
|
206 |
perl -pi \ |
207 |
-e 's|^physical_html_path=.*|physical_html_path=%{_datadir}/nagios/www|;' \ |
208 |
%{buildroot}%{_sysconfdir}/nagios/cgi.cfg |
209 |
|
210 |
|
211 |
# systemd |
212 |
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/nagios.service |
213 |
install -D -m 644 %{SOURCE2} %{buildroot}%{_prefix}/lib/tmpfiles.d/nagios.conf |
214 |
|
215 |
# apache configuration |
216 |
install -d -m 755 %{buildroot}%{_webappconfdir} |
217 |
cat > %{buildroot}%{_webappconfdir}/%{name}.conf <<EOF |
218 |
# Nagios Apache configuration |
219 |
|
220 |
ScriptAlias /%{name}/cgi-bin %{_libdir}/%{name}/cgi |
221 |
|
222 |
<Directory %{_libdir}/%{name}/cgi> |
223 |
Options ExecCGI |
224 |
Require all granted |
225 |
</Directory> |
226 |
|
227 |
Alias /%{name} %{_datadir}/%{name}/www |
228 |
|
229 |
<Directory %{_datadir}/%{name}> |
230 |
Require all granted |
231 |
</Directory> |
232 |
EOF |
233 |
|
234 |
# install and fix event handlers |
235 |
install -d -m 755 %{buildroot}%{_libdir}/nagios/plugins/eventhandlers |
236 |
pushd contrib/eventhandlers/ |
237 |
install -m 755 \ |
238 |
disable_active_service_checks \ |
239 |
disable_notifications \ |
240 |
enable_active_service_checks \ |
241 |
enable_notifications \ |
242 |
submit_check_result \ |
243 |
distributed-monitoring/obsessive_svc_handler \ |
244 |
distributed-monitoring/submit_check_result_via_nsca \ |
245 |
redundancy-scenario1/handle-master-host-event \ |
246 |
redundancy-scenario1/handle-master-proc-event \ |
247 |
%{buildroot}%{_libdir}/nagios/plugins/eventhandlers |
248 |
popd |
249 |
|
250 |
find %{buildroot}%{_libdir}/nagios/plugins/eventhandlers -type f | \ |
251 |
xargs perl -pi \ |
252 |
-e 's|/usr/local/nagios/var/rw/|/var/spool/nagios/|;' \ |
253 |
-e 's|/usr/local/nagios/libexec/eventhandlers|%{_libdir}/nagios/plugins/eventhandlers|g;' \ |
254 |
-e 's|/usr/local/nagios/libexec/send_nsca|%{_libdir}/nagios/plugins/send_nsca|g;' \ |
255 |
-e 's|/usr/local/nagios/test/var|/var/log/nagios|g;' \ |
256 |
-e 's|/usr/local/nagios/etc/send_nsca.cfg|%{_sysconfdir}/nagios/send_nsca.cfg|g;' \ |
257 |
-e 's|printfcmd="/bin/printf"|printfcmd="/usr/bin/printf"|;' |
258 |
|
259 |
# install the favicon.ico |
260 |
install -m 644 %{SOURCE5} %{buildroot}%{_datadir}/nagios/www |
261 |
|
262 |
# rpm filetriggers |
263 |
%transfiletriggerin -- %{_sysconfdir}/nagios/conf.d |
264 |
/usr/bin/systemctl reload-or-try-restart nagios.service |
265 |
|
266 |
%pre |
267 |
%_pre_useradd %{nsusr} /var/log/nagios /bin/sh |
268 |
%{_bindir}/gpasswd -a %{cmdusr} %{nsgrp} >/dev/null 2>&1 || : |
269 |
|
270 |
%post |
271 |
%_tmpfilescreate %{name} |
272 |
%_post_service %{name} |
273 |
|
274 |
%preun |
275 |
%_preun_service %{name} |
276 |
|
277 |
%postun |
278 |
%_postun_userdel %{nsusr} |
279 |
|
280 |
%files |
281 |
%doc Changelog INSTALLING LEGAL README.md UPGRADING |
282 |
%doc sample-config/mrtg.cfg |
283 |
%{_unitdir}/nagios.service |
284 |
%{_prefix}/lib/tmpfiles.d/nagios.conf |
285 |
%{_sbindir}/* |
286 |
%dir %{_sysconfdir}/nagios |
287 |
%dir %{_sysconfdir}/nagios/conf.d |
288 |
%config(noreplace) %{_sysconfdir}/nagios/*.cfg |
289 |
%config(noreplace) %{_sysconfdir}/nagios/conf.d/*.cfg |
290 |
%attr(-,%{nsusr},%{nsgrp}) %dir /var/log/nagios |
291 |
%attr(-,%{nsusr},%{nsgrp}) %dir /var/log/nagios/archives |
292 |
%attr(2775,%{nsusr},%{cmdgrp}) %dir /var/spool/nagios |
293 |
%attr(-,%{nsusr},%{nsgrp}) %dir /var/spool/nagios/checkresults |
294 |
%{_libdir}/nagios/plugins/eventhandlers |
295 |
|
296 |
%files www |
297 |
%config(noreplace) %{_webappconfdir}/nagios.conf |
298 |
%{_libdir}/nagios/cgi |
299 |
%{_datadir}/nagios/www |
300 |
|
301 |
%files devel |
302 |
%multiarch %{multiarch_includedir}/nagios/locations.h |
303 |
%{_includedir}/nagios |
304 |
%{_libdir}/libnagios.a |