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

# 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
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
BuildRequires:  heimdal-devel
%if 0%{?suse_version} > 1020
BuildRequires:  libopenssl-devel openssl
BuildRequires:  openssl-devel
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

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.

    Ethan Galstad <>

%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.

    Ethan Galstad <>

%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
Requires:       inet-daemon
Requires:       nagios-plugins

%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

Allowed monitoring commands are described in the daemon configuration

    Ethan Galstad <>

%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

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

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.

    Ethan Galstad <>

%setup -n %realname-%version
%if %{nagios3only}

%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 \
make %{?jobs:-j%jobs} all

# create missing directories
mkdir -p %buildroot/%_sysconfdir/{xinetd.d,init.d}
# install 
%{__make} install-daemon install-daemon-config install-xinetd install-plugin \
    DESTDIR="%buildroot" \
    CGICFGDIR="%_sysconfdir/nagios" \
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
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!
# 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

%post client
# enable the service
%{fillup_and_insserv -fy nrpe}
# Create user and group on the system if necessary
# default group: nagios
    getent group %nsgrp >/dev/null
    : OK group %nsgrp already present
    groupadd -r %nsgrp 2>/dev/null || :
    %nnmmsg "Added group %nsgrp for package %name"
# default user: nagios
    id %nsusr > /dev/null 2>&1
    : OK user %nsusr already present
    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"
# check if the port for nrpe is already defined in /etc/services
if grep -q %nrpeport /etc/services ; then
    : OK - port already defined
    %nnmmsg "Adding port %nrpeport to /etc/services"
	echo "nrpe            %nrpeport/tcp # nagios nrpe" >> etc/services

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

%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
if [ -f etc/init.d/inetd ]; then
  %restart_on_update inetd

rm -rf %buildroot

%dir %_defaultdocdir/%name
%doc %_defaultdocdir/%name/README.SuSE

%files doc
%dir %_defaultdocdir/%name
%doc %_defaultdocdir/%name/*

%files server

%files client
%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