forked from NagiosEnterprises/nagioscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nagios.spec
315 lines (226 loc) · 9.72 KB
/
nagios.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# Upstream: Ethan Galstad <nagios$nagios,org>
# Modified version from original dag spec
### FIXME: TODO: Add sysv script based on template. (remove cmd-file on start-up)
%define logmsg logger -t %{name}/rpm
%define logdir %{_localstatedir}/log/nagios
# Setup some debugging options in case we build with --with debug
%if %{defined _with_debug}
%define mycflags -O0 -pg -ggdb3
%else
%define mycflags %{nil}
%endif
### Allow newer compiler to suppress warnings
%if 0%{?el6}
%define myXcflags -Wno-unused-result
%else
%define myXcflags %{nil}
%endif
### Specify systemd for specific operating systems
%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} && 0%{?suse_version} >=1210)
Summary: Open Source host, service and network monitoring program
Name: nagios
Version: 4.4.6
Release: 2%{?dist}
License: GPL
Group: Applications/System
URL: https://www.nagios.org/
Packager: Daniel Wittenberg <[email protected]>
Vendor: Nagios Enterprises (https://www.nagios.org)
Source0: https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-%{version}/nagios-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gd-devel > 1.8
BuildRequires: zlib-devel
BuildRequires: libpng-devel
BuildRequires: libjpeg-devel
BuildRequires: doxygen
BuildRequires: gperf
%if %{use_systemd}
Requires: systemd
BuildRequires: systemd
%else
Requires: initscripts >= 8.36
Requires(postun): initscripts
Requires(post): chkconfig
Requires(preun): chkconfig
%endif
Obsoletes: nagios-www <= %{version}
Requires: httpd,php
%description
Nagios is an application, system and network monitoring application.
It can escalate problems by email, pager or any other medium. It is
also useful for incident or SLA reporting.
Nagios is written in C and is designed as a background process,
intermittently running checks on various services that you specify.
The actual service checks are performed by separate "plugin" programs
which return the status of the checks to Nagios. The plugins are
located in the nagios-plugins package.
%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
This package contains the header files, static libraries and development
documentation for %{name}. If you are a NEB-module author or wish to
write addons for Nagios using Nagios' own API's, you should install
this package.
%package contrib
Summary: Files from the contrib directory
Group: Applications/System
Requires: %{name} = %{version}-%{release}
%description contrib
This package contains all the files from the contrib directory
%prep
%setup -q
### /usr/local/nagios is hardcoded in many places
%{__perl} -pi.orig -e 's|/usr/local/nagios/var/rw|%{_localstatedir}/nagios/rw|g;' contrib/eventhandlers/submit_check_result
### The initdir passed to ./configure must be in line with where `make` will `install-init`
%if %{use_systemd}
%define with_initdir %{_unitdir}
%else
%define with_initdir %{_initrddir}
%endif
%build
CFLAGS="%{mycflags} %{myXcflags}" LDFLAGS="$CFLAGS" %configure \
--datadir="%{_datadir}/nagios" \
--libexecdir="%{_libdir}/nagios/plugins" \
--localstatedir="%{_localstatedir}/nagios" \
--with-checkresult-dir="%{_localstatedir}/nagios/spool/checkresults" \
--sbindir="%{_libdir}/nagios/cgi" \
--sysconfdir="%{_sysconfdir}/nagios" \
--with-cgibindir="%{_libdir}/nagios/cgi" \
--with-cgiurl="/nagios/cgi-bin" \
--with-command-user="apache" \
--with-command-group="apache" \
--with-gd-lib="%{_libdir}" \
--with-gd-inc="%{_includedir}" \
--with-htmurl="/nagios" \
--with-initdir="%{with_initdir}" \
--with-lockfile="%{_localstatedir}/nagios/nagios.pid" \
--with-mail="/bin/mail" \
--with-nagios-user="nagios" \
--with-nagios-group="nagios" \
--with-perlcache \
--with-template-objects \
--with-template-extinfo \
--enable-event-broker
find . -type f -name Makefile -exec /usr/bin/perl -p -i -e "s/-mtune=generic/-march=nocona/g" Makefile {} \; -print
%{__make} %{?_smp_mflags} all
### Build our documentation
%{__make} dox
### Apparently contrib does not obey configure !
%{__make} %{?_smp_mflags} -C contrib
%install
export PATH=%{_bindir}:/bin:\$PATH
%{__rm} -rf %{buildroot}
%{__make} install-unstripped install-init install-commandmode install-config \
DESTDIR="%{buildroot}" \
INSTALL_OPTS="" \
COMMAND_OPTS="" \
INIT_OPTS=""
%{__install} -d -m 0755 %{buildroot}%{_includedir}/nagios/
%{__install} -p -m 0644 include/*.h %{buildroot}%{_includedir}/nagios/
%{__mkdir} -p -m 0755 %{buildroot}/%{_includedir}/nagios/lib
%{__install} -m 0644 lib/*.h %{buildroot}/%{_includedir}/nagios/lib
%{__install} -Dp -m 0644 sample-config/httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/nagios.conf
### FIX log-paths
%{__perl} -pi -e '
s|log_file.*|log_file=%{logdir}/nagios.log|;
s|log_archive_path=.*|log_archive_path=%{logdir}/archives|;
s|debug_file=.*|debug_file=%{logdir}/nagios.debug|;
' %{buildroot}%{_sysconfdir}/nagios/nagios.cfg
### make logdirs
%{__mkdir_p} %{buildroot}%{logdir}/
%{__mkdir_p} %{buildroot}%{logdir}/archives/
### Install logos
%{__mkdir_p} %{buildroot}%{_datadir}/nagios/images/logos
### Install documentation
%{__mkdir_p} %{buildroot}%{_datadir}/nagios/documentation
%{__cp} -a Documentation/html/* %{buildroot}%{_datadir}/nagios/documentation
%{__install} -d -m 0755 %{buildroot}/%{_sysconfdir}/sysconfig/
%{__install} -m 0644 nagios.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/nagios
### Apparently contrib wants to do embedded-perl stuff as well and does not obey configure !
%{__make} install -C contrib \
DESTDIR="%{buildroot}" \
INSTALL_OPTS=""
### Install libnagios
%{__install} -m 0644 lib/libnagios.a %{buildroot}%{_libdir}/libnagios.a
%{__install} -d -m 0755 %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__cp} -afpv contrib/eventhandlers/* %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__mv} contrib/README contrib/README.contrib
CGI=`find contrib/ -name '*.cgi' -type f |sed s/'contrib\/'//g`
CGI=`for i in $CGI; do echo -n "$i|"; done |sed s/\|$//`
find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | grep -E -ve "($CGI)" > cgi.files
find %{buildroot}/%{_libdir}/nagios/cgi -type f -print | sed s!'%{buildroot}'!!g | grep -E "($CGI)" > contrib.files
%pre
if ! /usr/bin/id nagios &>/dev/null; then
/usr/sbin/useradd -r -d %{logdir} -s /bin/sh -c "nagios" nagios || \
%logmsg "Unexpected error adding user \"nagios\". Aborting installation."
fi
if ! /usr/bin/getent group nagiocmd &>/dev/null; then
/usr/sbin/groupadd nagiocmd &>/dev/null || \
%logmsg "Unexpected error adding group \"nagiocmd\". Aborting installation."
fi
%post
/sbin/chkconfig --add nagios
if /usr/bin/id apache &>/dev/null; then
if ! /usr/bin/id -Gn apache 2>/dev/null | grep -q nagios ; then
/usr/sbin/usermod -a -G nagios,nagiocmd apache &>/dev/null
fi
else
%logmsg "User \"apache\" does not exist and is not added to group \"nagios\". Sending commands to Nagios from the command CGI is not possible."
fi
%preun
if [ $1 -eq 0 ]; then
/sbin/service nagios stop &>/dev/null || :
/sbin/chkconfig --del nagios
fi
%postun
# groups and users are not supposed to be removed here
# See https://fedoraproject.org/wiki/Packaging:UsersAndGroups?rd=Packaging/UsersAndGroups
/sbin/service nagios condrestart &>/dev/null || :
%clean
%{__rm} -rf %{buildroot}
%files -f cgi.files
%defattr(-, root, root, 0755)
%doc Changelog INSTALLING LEGAL LICENSE README.md THANKS UPGRADING
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/httpd/conf.d/nagios.conf
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/nagios
%attr(0755,root,root) %{_bindir}/nagios
%attr(0755,root,root) %{_bindir}/nagiostats
%attr(0755,root,root) %{_libdir}/nagios/plugins/
%attr(0755,root,root) %{_datadir}/nagios/
%attr(0755,nagios,nagios) %dir %{_sysconfdir}/nagios/
%attr(0644,nagios,nagios) %config(noreplace) %{_sysconfdir}/nagios/*.cfg
%attr(0755,nagios,nagios) %{_sysconfdir}/nagios/objects/
%attr(0644,nagios,nagios) %config(noreplace) %{_sysconfdir}/nagios/objects/*.cfg
%attr(0755,nagios,nagios) %dir %{_localstatedir}/nagios/
%attr(0755,nagios,nagios) %{_localstatedir}/nagios/
%attr(0755,nagios,nagios) %{logdir}/
%attr(0755,nagios,apache) %{_localstatedir}/nagios/rw/
%attr(0644,root,root) %{_libdir}/libnagios.a
%if %{use_systemd}
%attr(0644,root,root) %{_unitdir}/nagios.service
%else
%attr(0755,root,root) %config %{_initrddir}/nagios
%endif
%files devel
%attr(0755,root,root) %{_includedir}/nagios/
%files contrib -f contrib.files
%doc contrib/README.contrib
%attr(0755,root,root) %{_bindir}/convertcfg
%attr(0755,root,root) %{_libdir}/nagios/plugins/eventhandlers/
%changelog
* Wed Jan 16 2019 Jake Omann <[email protected]> 4.4.3
- Updated configure to use --with-cgibindir since cgis are no longer placed in sbindir
* Wed Jun 20 2018 Bryan Heden <[email protected]> 4.4.1
- Updated for systemd inclusion - (Karsten Weiss and Fr3dY #535, #537)
* Fri Nov 15 2013 Eric Stanley <[email protected]> 4.0.1-1
- Corrected permissions on plugins directory (bug #494 - patch by Karsten Weiss)
- Corrected doc directive (bug #494 - patch by Karsten Weiss)
- Added configuration directive for *.cfg files (bug #494 - patch by Karsten Weiss)
* Wed Sep 18 2013 Daniel Wittenberg <[email protected]> 4.0.0rc2-1
- Fix find command - Florin Andrei, bug #489
- Remove compiler warning option that breaks older builds, bug #488
* Fri Mar 15 2013 Daniel Wittenberg <[email protected]> 3.99.96-1
- Major updates for version 4.0
- New spec file, new RC script, new sysconfig