File nagios-nrpe.spec of Package nagios-nrpe

#
# spec file for package nagios-nrpe (Version 2.12)
#
# Copyright (c) 2010 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:           nagios-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 0
Summary:        Nagios Remote Plug-In Executor
Group:          System/Monitoring
License:        GPL v2 or later
Url:            http://www.nagios.org/
Version:        2.12
Release:        3.<RELEASE3>
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
PreReq:         netcfg
%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 nagios
%define         nsgrp nagios
%define         nrpegrp nagios
%define         nrpeusr nagios
%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