File icinga-nrpe.spec of Package icinga-nrpe

#
# spec file for package nagios-nrpe (Version 2.12)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           icinga-nrpe
%define         realname nrpe
# to enable support for really long plugin-output (available since nagios v3)
# set the macro below to 1.
# Note: this change is incompatible to old versions, therefore disabled per 
#       default
%define         nagios3only 1
Summary:        Nagios Remote Plug-In Executor
Group:          System/Monitoring
License:        GPL v2 or later
Url:            http://www.nagios.org/
Version:        2.12
Release:        3
Source0:        %realname-%version.tar.bz2
Source1:        rcnrpe
Source2:        nagios-nrpe-rpmlintrc
Source3:        nagios-nrpe-SuSEfirewall2
Patch:          nagios-nrpe-Makefile.patch
Patch1:         nagios-nrpe-xinetd.patch
Patch2:         nagios-nrpe-buffersize.patch
BuildRequires:  nagios-plugins tcpd-devel
%if 0%{?suse_version} > 1000
BuildRequires:  krb5-devel
%else
BuildRequires:  heimdal-devel
%endif
%if 0%{?suse_version} > 1020
BuildRequires:  libopenssl-devel openssl
%else
BuildRequires:  openssl-devel
%endif
Requires:       %name-client = %version
Requires:       %name-server = %version
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# Macro that print mesages to syslog at package (un)install time
%define         nnmmsg logger -t %name/rpm
%define         nsusr icinga
%define         nsgrp icinga
%define         nrpegrp icinga
%define         nrpeusr icinga
%define         nrpeport 5666

%description
This daemon can be used to run nagios plug-ins on a remote machine for
executing local checks. This package contains the software for both
client and server.



Authors:
--------
    Ethan Galstad <nagios@nagios.org>

%package doc
License:        GPL v2 or later
Summary:        Nagios Remote Plug-In Executor documentation
Group:          Documentation/Other

%description doc
This package contains the README files, OpenOffice and PDF
documentation for the remote plugin executor (NRPE) for nagios.



Authors:
--------
    Ethan Galstad <nagios@nagios.org>

%package client
License:        GPL v2 or later
Summary:        Client part of Nagios Remote Plug-ins Executor (NRPE)
Group:          System/Monitoring
PreReq:         %insserv_prereq /bin/logger sed grep coreutils pwdutils
Requires:       bash grep 
%if 0%{?suse_version} > 1020
Recommends:     inet-daemon
Recommends:     nagios-plugins
%else
Requires:       inet-daemon
Requires:       nagios-plugins
%endif

%description client
This package contains the Nagios Remote Plug-ins Executor (NRPE) which
can execute predefined commands on the remote host.

Upon receiving a plugin request from an authorized host, it will
execute the command line associated with the command name it received
and send the program output and return code back to the check_nrpe
plugin.

Allowed monitoring commands are described in the daemon configuration
file.



Authors:
--------
    Ethan Galstad <nagios@nagios.org>

%package server
License:        GPL v2 or later
Summary:        Server part for Nagios Remote Plug-In Executor
Group:          System/Monitoring
PreReq:         %insserv_prereq /bin/logger sed grep
%if 0%{?suse_version} > 1020
Recommends:     nagios
%endif

%description server
This package contains the plug-in for the host runing the Nagios
daemon.

It is used to contact the NRPE process on remote hosts. The plugin
requests that a plugin be executed on the remote host and wait for the
NRPE process to execute the plugin and return the result.

The plugin then uses the output and return code from the plugin
execution on the remote host for its own output and return code.



Authors:
--------
    Ethan Galstad <nagios@nagios.org>

%prep
%setup -n %realname-%version
%patch
%patch1
%if %{nagios3only}
%patch2
%endif

%build
%configure \
	--sbindir=%_prefix/lib/nagios/cgi \
	--libexecdir=%_prefix/lib/nagios/plugins \
	--datadir=%_datadir/nagios \
	--sysconfdir=%_sysconfdir/nagios \
	--localstatedir=/var/log/nagios \
	--exec-prefix=%_sbindir \
    --bindir=%_sbindir \
    --with-log_facility=daemon \
    --with-kerberos-inc=%_includedir \
    --with-init-dir=%_sysconfdir/init.d \
    --with-nagios-user=%nsusr \
    --with-nagios-group=%nsgrp \
	--with-nrpe-user=%nrpeusr \
	--with-nrpe-group=%nrpegrp \
	--with-nrpe-port=%nrpeport \
    --enable-command-args \
	--enable-ssl
make %{?jobs:-j%jobs} all

%install
# create missing directories
mkdir -p %buildroot/%_sysconfdir/{xinetd.d,init.d}
#
# install 
%{__make} install-daemon install-daemon-config install-xinetd install-plugin \
    DESTDIR="%buildroot" \
    INSTALL_OPTS="" \
    COMMAND_OPTS="" \
    CGICFGDIR="%_sysconfdir/nagios" \
    NAGIOS_INSTALL_OPTS="" \
    NRPE_INSTALL_OPTS="" \
    INIT_OPTS=""
mv %buildroot/%_sysconfdir/xinetd.d/nrpe %buildroot/%_sysconfdir/xinetd.d/nagios-nrpe
install -m 755 %{SOURCE1}                %buildroot%_sysconfdir/init.d/nrpe
ln -sf ../../etc/init.d/nrpe             %buildroot%_sbindir/rcnrpe
#
# inform the user about the obsolete main package
#
mkdir -p %buildroot/%_defaultdocdir/%name
cat > %buildroot/%_defaultdocdir/%name/README.SuSE << EOF
Hi
The %name package is marked as obsolete and available only 
for upgrading older systems.
The new packages %name-client and %name-server are packaged
for their special targets: 
* %name-server should be installed on the server hosting nagios
* %name-client should be installed on the client which should be monitored
* %name-doc contains documentation and can be installed where ever you want
Have a lot of fun!
EOF
#
# install documentation
cp docs/NRPE.* %buildroot%_defaultdocdir/%name/
%if 0%{?suse_version} > 1020
#
# install SuSEfirewall2 script
install -Dm644 %{SOURCE3} %buildroot/%_sysconfdir/sysconfig/SuSEfirewall2.d/services/nrpe-service
%endif

%post client
# enable the service
%{fillup_and_insserv -fy nrpe}
# Create user and group on the system if necessary
# default group: nagios
if
    getent group %nsgrp >/dev/null
then
    : OK group %nsgrp already present
else
    groupadd -r %nsgrp 2>/dev/null || :
    %nnmmsg "Added group %nsgrp for package %name"
fi
# default user: nagios
if
    id %nsusr > /dev/null 2>&1
then
    : OK user %nsusr already present
else
    useradd  -r -o -g %nsgrp -s /bin/false -c "User for Nagios" -d /var/tmp %nsusr 2> /dev/null || :
    %nnmmsg "Added user %nsusr for package %name"
fi
# check if the port for nrpe is already defined in /etc/services
if grep -q %nrpeport /etc/services ; then
    : OK - port already defined
else
    %nnmmsg "Adding port %nrpeport to /etc/services"
	echo "nrpe            %nrpeport/tcp # nagios nrpe" >> etc/services
fi

%post server
if grep -q %nrpeport /etc/services ; then
    : OK - port already defined
else
    %nnmmsg "Adding port %nrpeport to /etc/services"
	echo "nrpe            %nrpeport/tcp # nagios nrpe" >> etc/services
fi

%postun server
%restart_on_update nagios

%preun client
%stop_on_removal nrpe

%postun client
%restart_on_update nrpe
if [ -f etc/init.d/xinetd ]; then
  %restart_on_update xinetd
fi
if [ -f etc/init.d/inetd ]; then
  %restart_on_update inetd
fi
%insserv_cleanup

%clean
rm -rf %buildroot

%files
%defattr(-,root,root)
%dir %_defaultdocdir/%name
%doc %_defaultdocdir/%name/README.SuSE

%files doc
%defattr(644,root,root,755)
%dir %_defaultdocdir/%name
%doc %_defaultdocdir/%name/*

%files server
%defattr(-,root,root)
%_prefix/lib/nagios/plugins/check_nrpe

%files client
%defattr(-,root,root)
%config(noreplace) /%_sysconfdir/nagios/nrpe.cfg
%config(noreplace) /%_sysconfdir/xinetd.d/nagios-nrpe
%if 0%{?suse_version} > 1020
%config %_sysconfdir/sysconfig/SuSEfirewall2.d/services/nrpe-service
%endif
%_sysconfdir/init.d/nrpe
%_sbindir/rcnrpe
%_sbindir/nrpe

%changelog
* Mon Dec 01 2008 lrupp@suse.de
- disable buffersize patch per default: breaks compatibility
- run try-restart only if the service is installed
* Thu Nov 27 2008 lrupp@suse.de
- Added nagios-nrpe-buffersize.patch: support long check output
  of plugins, which is possible since Nagios 3.0
* Mon Oct 13 2008 lrupp@suse.de
- added cron to Should-Start/Should-Stop, so nrpe starts even on
  curious systems
- added nagios-nrpe-SuSEfirewall2
- use --with-log_facility=daemon
* Wed Sep 10 2008 lars@linux-schulserver.de
- disable nrpe in xinetd per default
- use a more stupid way to get the port in etc/services
* Mon Jul 28 2008 lars@linux-schulserver.de
- move the Requires from the main- into the subpackage
* Tue Mar 11 2008 lars@linux-schulserver.de
- update to 2.12:
  + Fix for unterminated multiline plugin (garbage) output
  (Krzysztof Oledzki). Needed for nagios 3.0
- own the docu directory
- added rpmlintrc
* Tue Jan 29 2008 lars@linux-schulserver.de
- Update 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)
* Mon Jan 21 2008 lars@linux-schulserver.de
- start the client automatically
* Wed Jan 09 2008 lars@linux-schulserver.de
- split out the documenation to an extra package
* Thu Dec 27 2007 lars@linux-schulserver.de
- use user nagios and group nagios to run as daemon (client)
- try to add the nrpeport to /etc/services if not done already
* Wed Dec 26 2007 lars@linux-schulserver.de
- back to nagios* again as all pathnames are now identical
* Tue Nov 27 2007 lars@linux-schulserver.de
- rename to nagios3*
- use new libexecdir
* Fri Nov 23 2007 lars@linux-schulserver.de
- require krb5 for suse_version < 1000; otherwise heimdal
* Thu Oct 25 2007 tsieden@suse.de
- Moved PDF docs to docs/ subdirectory, added OpenOffice source document
- A critical result is now returned for child processed that die due to a signal (Klas Lindfors)
- Fixed bug with --with-nrpe-group configure script option (Graham Collinson)
- Fixed bug with check_disk thresholds in sample config file (Patric Wust)
- Added NRPE_PROGRAMVERSION and NRPE_MULTILINESUPPORT environment variables
  for scripts that need to detect NRPE version and capabilities (Gerhard Lausser)
- Added asprintf() support for systems that are missing it (Samba team)
* Mon May 21 2007 tsieden@suse.de
- fix build (Requires libopenssl and openssl for 10.3 and beyond)
* Wed May 16 2007 tsieden@suse.de
- update to version 2.8.1
  * Fixed configure script error with user-specified NRPE group
  * Added support for multiline plugin output (limited to 1KB at the moment) (Matthias Flacke)
  * Changes to sample config files
  * Added ';' as an additional prohibited metachar for command arguments
  * Updated documentation and added easier installation commands
* Mon Mar 12 2007 tsieden@suse.de
- update to version 2.7.1
  * Changed C++ style comment to C style to fix compilation errors on AIX
  (Ryan McGarry)
  * Patches for detection SSL header and library locations
  (Andrew Boyce-Lewis)
  * NRPE daemon will now partially ignore non-fatal configuration file
  errors and attempt to startup (Andrew Boyce-Lewis)
* Tue Jan 30 2007 tsieden@suse.de
- update to version 2.6
  * Added -u option to check_nrpe to return UNKNOWN states on socket
  timeouts (Bjoern Beutel)
  * Added connection_timeout variable to NRPE daemon to catch dead
  client connections (Ton Voon)
  * Added graceful timeout to check_nrpe to ensure connection to
  NRPE daemon is properly closed (Mark Plaksin)
* Sat Jul 01 2006 stark@suse.de
- update to version 2.5.2
  * number of bugfixes
  * Added optional command line prefix
  * Added ability to reload config file with SIGHUP
* Fri Jan 27 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Tue Jan 24 2006 stark@suse.de
- added patch to fix config parser regression
* Mon Jan 23 2006 stark@suse.de
- update to version 2.2
- enabled TCP wrapper support
* Wed Jan 18 2006 stark@suse.de
- added -fstack-protector
- added service handling for update and removal
* Tue Jan 17 2006 stark@suse.de
- added init script (#143288)
- fixed xinet configuration (#143288)
* Tue Nov 18 2003 stark@suse.de
- update to 2.0 final
- don't build as root
* Mon Sep 15 2003 stark@suse.de
- require inet-daemon (#30752)
- use port number in xinet config (#30754)
* Thu Jul 24 2003 stark@suse.de
- update to 2.0b5
* Mon Jul 21 2003 stark@suse.de
- update to 2.0b4
  * minor fixes
* Thu Jun 19 2003 stark@suse.de
- added nagios-plugins to neededforbuild (fixing directory
  ownerships)
* Tue May 20 2003 stark@suse.de
- update to 2.0b3
  * Added support for passing arguments to command
  * NRPE daemon can no longer be run as root user/group
  * Added native SSL support (Derrick Bennett)
* Wed Feb 05 2003 stark@suse.de
- update to 1.8
  * Daemon now closes stdio/out/err properly
  * Makefile changes
  * Mode command line option bug fix in daemon
  * Fixed incorrect command line options in check_nrpe plugin
* Thu Jan 16 2003 stark@suse.de
- added /etc/xinetd.d/nagios-nrpe
- moved nrpe to /usr/bin
* Mon Jan 13 2003 stark@suse.de
- update to 1.7
  * Syntax changes (-H option specifies host name in check_nrpe,
    -c option specifies config file in nrpe)
  * Added command_timeout directive to config file to allow user
  to specify timeout for executing plugins
* Thu Sep 26 2002 stark@suse.de
- initial package
openSUSE Build Service is sponsored by