]> git.pld-linux.org Git - packages/rpm-build-macros.git/commitdiff
- add %nagios_nrpe
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 18 Mar 2010 10:32:31 +0000 (10:32 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm.macros -> 1.551

rpm.macros

index 8eb7214b4362e683f8151bf2c233487e39f604b7..9c21b92d516257f3f0958f8a1e3f94fe40370122 100644 (file)
@@ -1804,4 +1804,37 @@ else: \
 %undos \
 %{__sed} -i -e 's,\\r$,,'
 
+# Hook to register nagios object based plugins in Nagios NRPE daemon config.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+#  -a NAME  -- add command named NAME
+#  -d NAME  -- remove command named NAME
+#  -f FILE  -- specify plugin configuration FILE to extract command definition from
+#
+# Sample:
+# %triggerin -- nagios-nrpe
+# %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# %triggerun -- nagios-nrpe
+# %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# Requirements:
+# BuildRequires:       sed >= 4.0
+# BuildRequires:       rpmbuild(macros) >= 1.551
+%nagios_nrpe(a:d:c:f:) {\
+       %{-a:# on -a and config exists \
+       if [ "%{-a*}" -a -f /etc/nagios/nrpe.cfg ]; then \
+               if ! grep -q '^command\[%{-a*}\]' /etc/nagios/nrpe.cfg; then \
+                               sed -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> /etc/nagios/nrpe.cfg; \
+               fi; \
+       fi;} \
+       %{-d:# on package remove, -d and config exists \
+       if [ "$1" = "0" -a "%{-d*}" -a -f /etc/nagios/nrpe.cfg ]; then \
+               sed -i -e '/^[ \t]*command\[%{-d*}\]/d' /etc/nagios/nrpe.cfg; \
+       fi;} \
+}%{nil}
+
+
 # vim:ts=4 sw=4 noet ft=spec
This page took 0.05569 seconds and 4 git commands to generate.