%define nsusr nagios
%define nsgrp nagios
%define cmdgrp nagioscmd
%define localstatedir /var/log/nagios
%define serverdir %(/usr/sbin/apxs -q htdocsdir 2>/dev/null)
# embedded Perl stuff, specify
# --define 'EMBPERL 1'
# in the rpm command-line to enable it
%{!?EMBPERL: %define EMBPERL 0}
Name: nagios
Version: 3.2.3
Release: 1mamba
Summary: An Open Source host, service and network monitoring program
Group: Network/Monitoring
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@...>
URL: http://www.nagios.org/
Source0: http://surfnet.dl.sourceforge.net/sourceforge/nagios/nagios-%{version}.tar.gz
#Source1: http://cesnet.dl.sourceforge.net/sourceforge/nagios/imagepak-base.tar.gz
Source2: nagios-1.2-cfg.tar.bz2
Patch0: %{name}-1.2-daemon_init.patch
Patch1: %{name}-1.2-cfg_in.patch
Patch2: nagios-3.0.4-cfg_in.patch
License: GPL
Requires: apache >= 2.0.48, debianutils
## AUTOBUILDREQ-BEGIN
BuildRequires: apache
BuildRequires: debianutils
BuildRequires: glibc-devel
BuildRequires: libgd-devel
BuildRequires: libglib-devel
BuildRequires: libjpeg-devel
BuildRequires: libltdl-devel
BuildRequires: libpng-devel
BuildRequires: libz-devel
BuildRequires: perl-devel
## AUTOBUILDREQ-END
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
NAGIOS (Nagios Ain't Gonna Insist On Sainthood) 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.
This package provide core programs for nagios. The web interface,
documentation, and development files are built as separate packages
%package www
Group: Network/Monitoring
Summary: Provides the HTML and CGI files for the Nagios web interface
Requires: %{name} = %{version}
Requires: apache >= 2.0.48
%description www
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.
Several CGI programs are included with Nagios in order to allow you to view the
current service status, problem history, notification history, and log file via
the web. This package provides the HTML and CGI files for the Nagios web
interface. In addition, HTML documentation is included in this package
%package devel
Group: Development/Libraries
Summary: Provides include files that Nagios-related applications may compile against
Requires: %{name} = %{version}
%description devel
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.
This package provides include files that Nagios-related applications may
compile against.
%prep
%setup -q
#%patch0 -p1
%patch2 -p1
# -a 1
%build
# allow configure to find traceroute
PATH=$PATH:/usr/sbin
%configure \
--bindir=%{_sbindir} \
--sbindir=%{_libdir}/nagios/cgi \
--datadir=%{_datadir}/nagios \
--sysconfdir=%{_sysconfdir}/nagios \
--with-init-dir=%{_initrddir} \
--with-cgiurl=/nagios/cgi-bin \
--with-htmurl=/nagios \
--with-lockfile=/var/lock/subsys/nagios \
--with-nagios-user=%{nsusr} --with-nagios-grp=%{nsgrp} \
%if %{EMBPERL}
--enable-embedded-perl \
%endif
--with-template-objects \
--with-template-extinfo
# --htmldir=%{serverdir}/nagios \
%make all
cd sample-config
sed -i "\
s,\(resource_file=\).*,\1%{_sysconfdir}/nagios/private/resource.cfg," \
nagios.cfg
sed -i "\
s,\(\$USER1\$=\).*,\1%{_libdir}/nagios/plugins,
s,\(#\$USER2\$=\).*,\1%{_libdir}/nagios/eventhandlers," \
resource.cfg
cd ..
# make daemonchk.cgi and event handlers
cd contrib
%make daemonchk.cgi \
traceroute.cgi \
%if %{EMBPERL}
mini_epn \
%endif
convertcfg
cd eventhandlers
for f in `find . -type f`; do
sed -i "\
s,/usr/local/nagios/etc,%{_sysconfdir}/nagios/,
s,/usr/local/nagios/libexec,%{_libdir}/nagios,
s,/usr/local/nagios/test/var,%{_localstatedir},
s,/usr/local/nagios/var/rw,/var/log/nagios/rw," $f
done
%install
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
install -d -m 0755 %{buildroot}%{_sysconfdir}/nagios/
install -d -m 0755 %{buildroot}%{_sysconfdir}/nagios/private/
install -d -m 0755 %{buildroot}%{_includedir}/nagios/
install -d -m 0755 %{buildroot}%{_datadir}/nagios/
install -d -m 0755 %{buildroot}%{_sysconfdir}/httpd/
install -d -m 0775 %{buildroot}%{_libdir}/nagios/cgi/
install -d -m 0775 %{buildroot}%{_libdir}/nagios/eventhandlers/
install -d -m 0755 %{buildroot}%{localstatedir}/
install -d -m 0755 %{buildroot}%{localstatedir}/archives/
install -d -m 0750 %{buildroot}%{localstatedir}/rw
install -d -m 2770 %{buildroot}/var/spool/nagios/
make install \
DESTDIR=%{buildroot} \
HTMLDIR=%{serverdir}/nagios \
INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS=""
# install the init script
make install-init \
DESTDIR=%{buildroot} INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS=""
# installs and configures permissions on the directory for holding
# the external command file
#make install-commandmode \
# DESTDIR=%{buildroot} INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS=""
# install templated configuration files
cd sample-config
install -m 664 nagios.cfg %{buildroot}%{_sysconfdir}/nagios/
install -m 664 cgi.cfg %{buildroot}%{_sysconfdir}/nagios/
install -m 664 mrtg.cfg %{buildroot}%{_sysconfdir}/nagios/mrtg.cfg.sample
[ -f resource.cfg ] && install -c -m 664 resource.cfg \
%{buildroot}%{_sysconfdir}/nagios/private/
# install httpd configuration in httpd config subdir
install -m 0644 httpd.conf \
%{buildroot}%{_sysconfdir}/httpd/nagios.conf
sed -i -e '/^<Directory.*>/a\
AllowOverride AuthConfig' %{buildroot}%{_sysconfdir}/httpd/nagios.conf
cd template-object
flist='contacts localhost printer switch templates windows'
for f in $flist; do
install -m 664 $f.cfg %{buildroot}%{_sysconfdir}/nagios/$f.cfg.sample
done
# add configuration files modified for the QiLinux distribution
tar xjf %{SOURCE2} -C %{buildroot}%{_sysconfdir}/nagios
flist='commands timeperiods'
for f in $flist; do
install -m 664 $f.cfg %{buildroot}%{_sysconfdir}/nagios/
done
cd ../..
# install headers for development package
install -m 0644 %{_builddir}/%{name}-%{version}/include/*.h \
%{buildroot}%{_includedir}/nagios
# install CGIs
cd contrib
# note: the above command fails, so we put the fixed list of Makefile commands
# make INSTALL=install INSTALL_OPTS="" COMMAND_OPTS="" \
# CGIDIR=%{buildroot}%{_libdir}/nagios/cgi install daemonchk.cgi
for f in 'traceroute.cgi'; do
install -m 0775 $f %{buildroot}%{_libdir}/nagios/cgi
done
install -m 0775 convertcfg %{buildroot}%{_libdir}/nagios/
%if %{EMBPERL}
install -m 0775 mini_epn %{buildroot}%{_bindir}
%endif
cd ..
cat > %{buildroot}%{_libdir}/nagios/cgi/.htaccess << _EOF
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/private/htpasswd.users
require valid-user
_EOF
# install event handlers
cd contrib/eventhandlers
for f in `find . -type f`; do
install -m 0755 $f %{buildroot}%{_libdir}/nagios/eventhandlers && rm $f
done
cp -pr %{_builddir}/%{name}-%{version}/html/ssi \
%{buildroot}%{_datadir}/nagios/
%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
%pre
# create `nagios' user and group on the system if necessary
groupadd %{nsgrp} -g 65008 &>/dev/null || :
useradd -c "Nagios netkork monitoring" -d /var/log/nagios -s /bin/sh \
-u 65008 -g %{nsgrp} %{nsusr} &> /dev/null || :
exit 0
%postun
# update
if [ $1 -eq 1 ]; then
chkconfig nagios
[ $? -eq 0 ] && %{_initrddir}/nagios restart
fi
exit 0
%preun
# erase
if [ $1 = 0 ]; then
%{_initrddir}/nagios stop &>/dev/null
chkconfig --del nagios
userdel %{nsusr} &>/dev/null
groupdel %{nsgrp} &>/dev/null
fi
exit 0
%post www
# new install
if [ $1 -eq 1 ]; then
# find apache user
wwwusr=`sed -n 's/^User \(.*\)/\1/p' /etc/httpd/httpd.conf`
# find apache primary group
wwwgrp=`/bin/id -gn $wwwusr 2>/dev/null`
# add apache user to %{nsgrp} so sending commands to nagios
# from the command CGI is possible
usermod -G %{nsgrp} $wwwusr >/dev/null 2>&1
# update apache configuration file (/etc/httpd/httpd.conf)
if [ `grep -c "Include \/etc\/httpd\/nagios.conf" \
/etc/httpd/httpd.conf ` -eq 0 ]; then
cat >> /etc/httpd/httpd.conf << _EOF
#
# Nagios (Host and Network Monitor) alias and permissions
#
Include /etc/httpd/nagios.conf
_EOF
else
sed -i 's,.*\(Include \/etc\/httpd\/nagios.conf*\),\1,' \
/etc/httpd/httpd.conf
fi
RANDOM_PASSWD=`/usr/bin/mkpasswd -l 10 -s 0`
htpasswd -bc /etc/nagios/private/htpasswd.users nagiosadmin $RANDOM_PASSWD
[ -e /var/lock/subsys/httpd ] &&
%{_initrddir}/httpd reload
fi
exit 0
%preun www
# erase
if [ $1 = 0 ]; then
if [ -f /etc/httpd/httpd.conf ]; then
sed -i 's,\(^Include \/etc\/httpd\/nagios.conf*\),#\1,' \
/etc/httpd/httpd.conf
[ -e /var/lock/subsys/httpd ] &&
%{_initrddir}/httpd reload
fi
fi
exit 0
%files
%defattr(-,root,root)
%dir %{_sysconfdir}/nagios/
%attr(644,root,root) %{_sysconfdir}/nagios/*.cfg.sample
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/nagios/*.cfg
%attr(640,root,%{nsgrp}) %config(noreplace) %{_sysconfdir}/nagios/private/resource.cfg
%attr(775,%{nsusr},%{nsgrp}) %{_sbindir}/nagios
%if %{EMBPERL}
%{_sbindir}/mini_epn
%endif
%{_sbindir}/nagiostats
%{_initrddir}/nagios
%dir %{_libdir}/nagios/
%{_libdir}/nagios/convertcfg
%dir %{_libdir}/nagios/eventhandlers/
%{_libdir}/nagios/eventhandlers/*
%attr(755,%{nsusr},%{nsgrp}) %dir %{localstatedir}
%attr(755,%{nsusr},%{nsgrp}) %dir %{localstatedir}/archives
%attr(750,%{nsusr},%{nsgrp}) %dir %{localstatedir}/rw
%files www
%defattr(755,root,root)
%dir %{serverdir}/nagios
%{serverdir}/nagios/*
%dir %{_libdir}/nagios/cgi
%{_libdir}/nagios/cgi/*
%attr(644,root,root) %{_libdir}/nagios/cgi/.htaccess
%attr(2770,%{nsusr},%{nsgrp}) %dir /var/spool/nagios
%defattr(-,root,root)
%dir %{_datadir}/nagios/
%{_datadir}/nagios/*
%config(noreplace) %{_sysconfdir}/httpd/nagios.conf
%files devel
%defattr(-,root,root)
%dir %{_includedir}/nagios
%{_includedir}/nagios/*.h
%changelog
* Wed Nov 03 2010 Automatic Build System <autodist@...> 3.2.3-1mamba
- automatic update by autodist
* Wed May 12 2010 Automatic Build System <autodist@...> 3.2.1-1mamba
- automatic update by autodist
* Wed Aug 19 2009 Automatic Build System <autodist@...> 3.2.0-1mamba
- automatic update by autodist
* Mon Jul 13 2009 Automatic Build System <autodist@...> 3.1.2-1mamba
- automatic update by autodist
* Mon Mar 02 2009 Silvan Calarco <silvan.calarco@...> 3.1.0-1mamba
- automatic update by autodist
* Wed Dec 24 2008 Silvan Calarco <silvan.calarco@...> 3.0.6-1mamba
- automatic update by autodist
* Fri Oct 24 2008 gil <puntogil@...> 3.0.4-1mamba
- update to 3.0.4
* Tue Oct 11 2005 Davide Madrisan <davide.madrisan@...> 1.2-7qilnx
- remove exec permissions from /etc/httpd/nagios.conf
* Wed Dec 15 2004 Davide Madrisan <davide.madrisan@...> 1.2-6qilnx
- do create the directory /var/log/nagios/archives needed to backup logs
* Tue Jul 13 2004 Davide Madrisan <davide.madrisan@...> 1.2-5qilnx
- added support for the nrpe extra plugin
* Wed Jul 07 2004 Davide Madrisan <davide.madrisan@...> 1.2-4qilnx
- added some default entries in the services.cfg file
- added support for hosts and services icons
* Tue Jul 06 2004 Davide Madrisan <davide.madrisan@...> 1.2-3qilnx
- fixed paths in the eventhandlers scripts
* Fri Jul 02 2004 Davide Madrisan <davide.madrisan@...> 1.2-2qilnx
- specfile fixes
- added nagios-1.2-daemon_init patch
* Tue Jun 29 2004 Davide Madrisan <davide.madrisan@...> 1.2-1qilnx
- first build