1 # Hook to register nagios object based plugins in Nagios NRPE daemon config.
3 # Author: Elan Ruusamäe <glen@pld-linux.org>
6 # -a NAME -- add command named NAME
7 # -d NAME -- remove command named NAME
8 # -f FILE -- specify plugin configuration FILE to extract command definition from
11 # %triggerin -- nagios-nrpe
12 # %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
14 # %triggerun -- nagios-nrpe
15 # %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
19 # Requires: sed >= 4.0
20 # BuildRequires: rpmbuild(macros) >= 1.685
21 %nagios_nrpe(a:d:c:f:) {\
22 if %{__grep} -q '^include_dir=/etc/nagios/nrpe.d' /etc/nagios/nrpe.cfg && [ -d /etc/nagios/nrpe.d ]; then \
23 file=/etc/nagios/nrpe.d/%{-a*}%{-d*}.cfg; \
25 file=/etc/nagios/nrpe.cfg; \
27 m=$(test -f $file && md5sum < $file); \
28 %{-a:# on -a and config exists \
29 if [ -f /etc/nagios/nrpe.cfg ]; then \
30 if [ ! -f $file ] || ! %{__grep} -q '^command\[%{-a*}\]' $file; then \
31 %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> $file; \
34 %{-d:# on package remove, -d and config exists \
35 if [ "$1" = "0" -a -f $file ]; then \
36 %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' $file; \
38 if [ "$m" != "$(md5sum < $file)" ]; then \
39 %service -q nrpe restart; \