File nrpe.spec of Package nrpe
#!BuildIgnore: post-build-checks
%define myname nrpe
%define version 2.12
%define release 20
%define nsusr nagios
%define nsgrp nagios
%define nsport 5666
# Reserve option to override port setting with:
# rpm -ba|--rebuild --define 'nsport 5666'
%{?port:%define nsport %{port}}
# Macro that print mesages to syslog at package (un)install time
%define nnmmsg logger -t %{name}/rpm
Summary: Host/service/network monitoring agent for Nagios
URL: http://www.nagios.org
Name: nagios-nrpe
Version: %{version}
Release: %{release}
License: GPL
Group: Application/System
Source0: %{myname}-%{version}.tar.bz2
Source1: %{myname}-rpmlintrc
Patch0: %{myname}-suse-init.patch
Patch1: %{myname}-config.patch
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
Prefix: /etc/init.d
Prefix: /etc/nagios
Requires: bash, grep, nagios-plugins
%if 0%{?suse_version}
PreReq: /bin/logger, sed, mktemp
%endif
%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora_version}
PreReq: /usr/bin/logger, sed, mktemp
%endif
BuildRequires: openssl openssl-devel glibc-devel libgcc gcc gcc-c++
Obsoletes: %{myname}
Provides: %{myname}
%description
Nrpe is a system daemon that will execute various Nagios plugins
locally on behalf of a remote (monitoring) host that uses the
check_nrpe plugin. Various plugins that can be executed by the
daemon are available at:
http://sourceforge.net/projects/nagiosplug
This package provides the core agent.
%package plugin
Group: Application/System
Summary: Provides nrpe plugin for Nagios
Requires: nagios-plugins
BuildRequires: nagios-plugins
%description plugin
Nrpe is a system daemon that will execute various Nagios plugins
locally on behalf of a remote (monitoring) host that uses the
check_nrpe plugin. Various plugins that can be executed by the
daemon are available at:
http://sourceforge.net/projects/nagiosplug
This package provides the nrpe plugin for Nagios-related applications.
%prep
%setup -q -n %{myname}-%{version}
%patch0
%patch1
%pre
# Create `nagios' group on the system if necessary
if grep ^nagios: /etc/group; then
: # group already exists
else
/usr/sbin/groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
fi
# Create `nagios' user on the system if necessary
if id %{nsusr} ; then
: # user already exists
else
/usr/sbin/useradd -r -d /var/log/nagios -s /bin/sh -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
fi
if grep ^nrpe /etc/services; then
: # service entry exists
else
echo -e "nrpe\t5666/tcp\t# nagios nrpe" >> /etc/services
fi
# if LSB standard /etc/init.d does not exist,
# create it as a symlink to the first match we find
if [ -d /etc/init.d -o -L /etc/init.d ]; then
: # we're done
elif [ -d /etc/rc.d/init.d ]; then
ln -s /etc/rc.d/init.d /etc/init.d
elif [ -d /usr/local/etc/rc.d ]; then
ln -s /usr/local/etc/rc.d /etc/init.d
elif [ -d /sbin/init.d ]; then
ln -s /sbin/init.d /etc/init.d
fi
%preun
if [ "$1" = 0 ]; then
/sbin/service nrpe stop > /dev/null 2>&1
/sbin/chkconfig --del nrpe
fi
%postun
if [ "$1" -ge "1" ]; then
/sbin/service nrpe condrestart >/dev/null 2>&1 || :
fi
%post
if [ -f /etc/sudoers ] ; then
if [ -z "`grep ^nagios /etc/sudoers`" ] ; then
echo "nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/" >> /etc/sudoers
fi
fi
%build
export PATH=$PATH:/usr/sbin
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
./configure \
--with-init-dir=/etc/init.d \
--with-nrpe-port=%{nsport} \
--with-nrpe-user=%{nsusr} \
--with-nrpe-group=%{nsgrp} \
--prefix=%{_prefix} \
--exec-prefix=%{_prefix}/sbin \
--bindir=%{_prefix}/sbin \
--sbindir=%{_prefix}/lib/nagios/cgi \
--libexecdir=%{_prefix}/lib/nagios/plugins \
--datadir=%{_prefix}/share/nagios \
--sysconfdir=/etc/nagios \
--localstatedir=/var/log/nagios \
--enable-command-args
make all
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/init.d
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/xinetd.d
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/nagios
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/nagios/nrpe.d
install -d -m 0755 ${RPM_BUILD_ROOT}/usr/sbin
install -d -m 0755 ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
# install templated configuration files
cp sample-config/nrpe.cfg ${RPM_BUILD_ROOT}/etc/nagios/nrpe.cfg
%if 0%{?suse_version}
cp init-script.suse ${RPM_BUILD_ROOT}/etc/init.d/nrpe
%else
cp init-script ${RPM_BUILD_ROOT}/etc/init.d/nrpe
%endif
cp src/nrpe ${RPM_BUILD_ROOT}/usr/sbin
cp src/check_nrpe ${RPM_BUILD_ROOT}/usr/lib/nagios/plugins
install -m 644 sample-config/nrpe.xinetd ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(755,root,root)
/etc/init.d/nrpe
%config(noreplace)/etc/xinetd.d/nrpe
%{_prefix}/sbin/nrpe
%dir /etc/nagios
%dir /etc/nagios/nrpe.d/
%defattr(644,root,root)
%config(noreplace) /etc/nagios/*.cfg
%defattr(644,%{nsusr},%{nsgrp})
%doc Changelog LEGAL README
%files plugin
%defattr(755,root,root)
%{_prefix}/lib/nagios/plugins
%defattr(644,%{nsusr},%{nsgrp})
%doc Changelog LEGAL README
%changelog
* Tue Apr 20 2010 Carsten Schoene <cs@linux-administrator.com> - 2.12-20
- added nrpe_local.cfg and nrpe.d directory to nrpe configuration
- activated sudo by default
* Tue Mar 11 2008 Carsten Schoene <cs@linux-administrator.com>
- version bump to 2.12
- Fix for unterminated multiline plugin (garbage) output (Krzysztof Oledzki)
* Sat Dec 29 2007 Carsten Schoene <cs@linux-administrator.com>
- version bump to 2.11
- Added lib64 library paths to configure script for 64-bit systems (John Maag)
- Added --with-ssl-lib configure script option
- Added --with-log-facility option to control syslog logging (Ryan Ordway and Brian Seklecki)
* Sun Oct 21 2007 Carsten Schoene <cs@linux-administrator.com>
- version bump to 2.10
- added entry for nrpe in /etc/services
* Thu Nov 23 2006 Carsten Schoene <cs@linux-administrator.com>
- ported this spec to SuSE 10.1
* Mon Jan 23 2006 Andreas Kasenides ank<@>cs.ucy.ac.cy
- fixed nrpe.cfg relocation to sample-config
- replaced Copyright label with License
- added --enable-command-args to enable remote arg passing (if desired can be disabled by commenting out)
* Wed Nov 12 2003 Ingimar Robertsson <iar@skyrr.is>
- Added adding of nagios group if it does not exist.
* Tue Jan 07 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
- Removed the lines which removed the nagios user and group from the system
- changed the patch release version from 3 to 1
* Mon Jan 06 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
- Removed patch files required for nrpe 1.5
- Update spec file for version 1.6 (1.6-1)
* Sat Dec 28 2002 James 'Showkilr' Peterson <showkilr@showkilr.com>
- First RPM build (1.5-1)