From c4e68e7c683d47db2e66fe191f65e80c99a3635e Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 6 Jan 2024 07:30:52 +0100 Subject: [PATCH] require nagios-plugins install a default nrpe command configuration for nagios [release 2.15-2mamba;Wed May 07 2014] --- README.md | 3 + nagios-commands-nrpe.cfg | 4 + ...s-nrpe-2.13-include_nrpe_d_directory.patch | 10 ++ nagios-nrpe-2.13-initscript_add_reload.patch | 29 ++++ ...s-nrpe-2.13-initscript_extra_options.patch | 23 +++ ...os-nrpe-2.13-initscript_return_codes.patch | 49 ++++++ nagios-nrpe-2.13-relocate_pid_file.patch | 11 ++ nagios-nrpe.spec | 139 ++++++++++++++++++ nagios-nrpe.sysconfig | 1 + 9 files changed, 269 insertions(+) create mode 100644 nagios-commands-nrpe.cfg create mode 100644 nagios-nrpe-2.13-include_nrpe_d_directory.patch create mode 100644 nagios-nrpe-2.13-initscript_add_reload.patch create mode 100644 nagios-nrpe-2.13-initscript_extra_options.patch create mode 100644 nagios-nrpe-2.13-initscript_return_codes.patch create mode 100644 nagios-nrpe-2.13-relocate_pid_file.patch create mode 100644 nagios-nrpe.spec create mode 100644 nagios-nrpe.sysconfig diff --git a/README.md b/README.md index c80a623..0260693 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # nagios-nrpe +Nrpe runs as a background process on the remote host and processes command execution requests from the check_nrpe plugin on the Nagios 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. + diff --git a/nagios-commands-nrpe.cfg b/nagios-commands-nrpe.cfg new file mode 100644 index 0000000..ae64b5e --- /dev/null +++ b/nagios-commands-nrpe.cfg @@ -0,0 +1,4 @@ +define command{ + command_name check_nrpe + command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c $ARG1$ +} diff --git a/nagios-nrpe-2.13-include_nrpe_d_directory.patch b/nagios-nrpe-2.13-include_nrpe_d_directory.patch new file mode 100644 index 0000000..6f7ec8a --- /dev/null +++ b/nagios-nrpe-2.13-include_nrpe_d_directory.patch @@ -0,0 +1,10 @@ +--- nrpe-2.13/sample-config/nrpe.cfg.in 2011-11-04 19:57:41.000000000 +0100 ++++ nrpe-2.13/sample-config/nrpe.cfg.in.include_nrpe_d_directory 2012-10-23 23:00:15.000000000 +0200 +@@ -173,6 +173,7 @@ + + #include_dir= + #include_dir= ++include_dir=/etc/nrpe.d/ + + + diff --git a/nagios-nrpe-2.13-initscript_add_reload.patch b/nagios-nrpe-2.13-initscript_add_reload.patch new file mode 100644 index 0000000..d1c16c2 --- /dev/null +++ b/nagios-nrpe-2.13-initscript_add_reload.patch @@ -0,0 +1,29 @@ +--- nrpe-2.13/init-script.in 2003-01-08 02:11:36.000000000 +0100 ++++ nrpe-2.13/init-script.in.openmamba 2012-10-23 22:48:40.000000000 +0200 +@@ -9,7 +9,7 @@ + # description: nrpe is a daemon for a remote nagios server, \ + # running nagios plugins on this host. + # processname: nrpe +-# config: /usr/local/nagios/etc/nrpe.cfg ++# config: /etc/nagios/nrpe.cfg + + + # Source function library +@@ -51,11 +51,16 @@ + $0 stop + $0 start + ;; ++ reload) ++ echo -n "Reloading nrpe: " ++ killproc nrpe -HUP ++ echo ++ ;; + status) + status nrpe + ;; + *) +- echo "Usage: nrpe {start|stop|restart|status}" ++ echo "Usage: nrpe {start|stop|restart|reload|status}" + exit 1 + esac + diff --git a/nagios-nrpe-2.13-initscript_extra_options.patch b/nagios-nrpe-2.13-initscript_extra_options.patch new file mode 100644 index 0000000..fbaab23 --- /dev/null +++ b/nagios-nrpe-2.13-initscript_extra_options.patch @@ -0,0 +1,23 @@ +--- nrpe-2.13/init-script.in 2012-10-23 22:51:11.000000000 +0200 ++++ nrpe-2.13/init-script.in.sysconfig 2012-10-23 22:55:13.000000000 +0200 +@@ -24,6 +24,11 @@ + # Source networking configuration. + . /etc/sysconfig/network + ++# Extra configuration options ++if [ -f /etc/sysconfig/nrpe ]; then ++ . /etc/sysconfig/nrpe ++fi ++ + # Check that networking is up. + [ ${NETWORKING} = "no" ] && exit 0 + +@@ -36,7 +41,7 @@ + start) + # Start daemons. + echo -n "Starting nrpe: " +- daemon $NrpeBin -c $NrpeCfg -d ++ daemon $NrpeBin -c $NrpeCfg -d $NRPE_OPTS + echo + touch $LockFile + ;; diff --git a/nagios-nrpe-2.13-initscript_return_codes.patch b/nagios-nrpe-2.13-initscript_return_codes.patch new file mode 100644 index 0000000..00ced1f --- /dev/null +++ b/nagios-nrpe-2.13-initscript_return_codes.patch @@ -0,0 +1,49 @@ +--- nrpe-2.13/init-script.in 2012-10-23 23:01:45.000000000 +0200 ++++ nrpe-2.13/init-script.in.retcodes 2012-10-23 23:04:51.000000000 +0200 +@@ -36,21 +36,25 @@ + NrpeCfg=@sysconfdir@/nrpe.cfg + LockFile=/var/lock/subsys/nrpe + ++RETVAL=0 ++ + # See how we were called. + case "$1" in + start) + # Start daemons. + echo -n "Starting nrpe: " + daemon $NrpeBin -c $NrpeCfg -d $NRPE_OPTS ++ RETVAL=$? + echo +- touch $LockFile ++ [ $RETVAL = 0 ] && touch $LockFile + ;; + stop) + # Stop daemons. + echo -n "Shutting down nrpe: " + killproc nrpe ++ RETVAL=$? + echo +- rm -f $LockFile ++ [ $RETVAL = 0 ] && rm -f $LockFile + ;; + restart) + $0 stop +@@ -59,14 +63,16 @@ + reload) + echo -n "Reloading nrpe: " + killproc nrpe -HUP ++ RETVAL=$? + echo + ;; + status) + status nrpe ++ RETVAL=$? + ;; + *) + echo "Usage: nrpe {start|stop|restart|reload|status}" +- exit 1 ++ RETVAL=2 + esac + +-exit 0 ++exit $RETVAL diff --git a/nagios-nrpe-2.13-relocate_pid_file.patch b/nagios-nrpe-2.13-relocate_pid_file.patch new file mode 100644 index 0000000..18e3c07 --- /dev/null +++ b/nagios-nrpe-2.13-relocate_pid_file.patch @@ -0,0 +1,11 @@ +--- nrpe-2.13/sample-config/nrpe.cfg.in 2012-10-23 23:06:18.000000000 +0200 ++++ nrpe-2.13/sample-config/nrpe.cfg.in.pid 2012-10-23 23:23:11.000000000 +0200 +@@ -23,7 +23,7 @@ + # number. The file is only written if the NRPE daemon is started by the root + # user and is running in standalone mode. + +-pid_file=/var/run/nrpe.pid ++pid_file=/var/run/nrpe/nrpe.pid + + + diff --git a/nagios-nrpe.spec b/nagios-nrpe.spec new file mode 100644 index 0000000..d46fc20 --- /dev/null +++ b/nagios-nrpe.spec @@ -0,0 +1,139 @@ +%define nrpeport 5666 +%define nrpeuser nrpe +%define nrpegroup nrpe + +Name: nagios-nrpe +Version: 2.15 +Release: 2mamba +Summary: Nagios Remote Plugin Executor (NRPE) +Group: Network/Monitoring +Vendor: openmamba +Distribution: openmamba +Packager: Davide Madrisan +URL: http://www.nagios.org +Source0: http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-%{version}/nrpe-%{version}.tar.gz +Source1: nagios-nrpe.sysconfig +Source2: nagios-commands-nrpe.cfg +Patch0: %{name}-2.13-initscript_add_reload.patch +Patch1: %{name}-2.13-initscript_extra_options.patch +Patch2: %{name}-2.13-include_nrpe_d_directory.patch +Patch3: %{name}-2.13-initscript_return_codes.patch +Patch4: %{name}-2.13-relocate_pid_file.patch +License: GPL +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: initscripts +BuildRequires: libopenssl-devel +## AUTOBUILDREQ-END +Requires: initscripts +Provides: nrpe = %{?epoch:%epoch:}%{version}-%{release} +Requires: nagios-plugins +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +Nrpe runs as a background process on the remote host and processes command execution requests from the check_nrpe plugin on the Nagios 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. + +%package -n nagios-plugins-nrpe +Summary: Nagios Remote Plugin Executor Plugin +Group: Network/Monitoring + +%description -n nagios-plugins-nrpe +The check_nrpe plugin is run on the Nagios host and 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. + +%prep +%setup -q -n nrpe-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 + +%build +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \ +%configure \ + --with-init-dir=%{_initrddir} \ + --with-nrpe-port=%{nrpeport} \ + --with-nrpe-user=%{nrpeuser} \ + --with-nrpe-group=%{nrpegroup} \ + --bindir=%{_sbindir} \ + --libdir=/doesnt/matter/ \ + --libexecdir=%{_libdir}/nagios/plugins \ + --datadir=%{_datadir}/nagios \ + --sysconfdir=%{_sysconfdir}/nagios \ + --localstatedir=%{_localstatedir}/log/nagios \ + --enable-command-args + +%make + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +install -D -p -m 0755 init-script %{buildroot}/%{_initrddir}/nrpe +install -D -p -m 0644 sample-config/nrpe.cfg %{buildroot}/%{_sysconfdir}/nagios/nrpe.cfg +install -D -p -m 0755 src/nrpe %{buildroot}%{_sbindir}/nrpe +install -D -p -m 0755 src/check_nrpe %{buildroot}%{_libdir}/nagios/plugins/check_nrpe +install -D -p -m 0644 %{S:1} %{buildroot}/%{_sysconfdir}/sysconfig/nrpe + +install -d %{buildroot}%{_sysconfdir}/nrpe.d +install -d %{buildroot}%{_localstatedir}/run/nrpe + +install -D -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/nagios/conf.d/commands-nrpe.cfg + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%pre +getent group %{nrpegroup} >/dev/null || groupadd -r %{nrpegroup} +getent passwd %{nrpeuser} >/dev/null || \ + %{_sbindir}/useradd -c "Nagios NRPE user" -d %{_localstatedir}/run/nrpe \ + -r -g %{nrpegroup} -s /sbin/nologin %{nrpeuser} 2>/dev/null +exit 0 + +%preun +if [ $1 = 0 ]; then + /sbin/service nrpe stop >/dev/null 2>&1 + /sbin/chkconfig --del nrpe +fi +exit 0 + +%post +/sbin/chkconfig --add nrpe +exit 0 + +%postun +if [ "$1" -ge "1" ]; then + /sbin/service nrpe condrestart >/dev/null 2>&1 +fi +exit 0 + +%files +%defattr(-,root,root) +%{_sbindir}/nrpe +%{_initrddir}/nrpe +%config(noreplace) %{_sysconfdir}/nagios/nrpe.cfg +%config(noreplace) %{_sysconfdir}/sysconfig/nrpe +%dir %{_sysconfdir}/nagios +%dir %{_sysconfdir}/nrpe.d +%dir %attr(775, %{nrpeuser}, %{nrpegroup}) %{_localstatedir}/run/nrpe +%doc LEGAL README README.SSL SECURITY docs/NRPE.pdf + +%files -n nagios-plugins-nrpe +%defattr(-,root,root,-) +%{_sysconfdir}/nagios/conf.d/commands-nrpe.cfg +%{_libdir}/nagios/plugins/check_nrpe + +%changelog +* Wed May 07 2014 Silvan Calarco 2.15-2mamba +- require nagios-plugins +- install a default nrpe command configuration for nagios + +* Sun Jan 12 2014 Davide Madrisan 2.15-1mamba +- update to 2.15 + +* Thu Jan 03 2013 Automatic Build System 2.14-1mamba +- automatic version update by autodist + +* Tue Oct 23 2012 Davide Madrisan 2.13-1mamba +- package created by autospec diff --git a/nagios-nrpe.sysconfig b/nagios-nrpe.sysconfig new file mode 100644 index 0000000..d5619bf --- /dev/null +++ b/nagios-nrpe.sysconfig @@ -0,0 +1 @@ +NRPE_OPTS=