From 5563b4f8f2212a5be20dc343fd3a6f4744bcbac8 Mon Sep 17 00:00:00 2001 From: William Hirigoyen Date: Thu, 25 May 2023 16:01:04 +0200 Subject: [PATCH] nagios-nrpe: improve check-local output and fix completion in Debian 10 --- nagios-nrpe/files/check-local | 8 ++++++-- nagios-nrpe/files/check-local_completion | 3 +-- nagios-nrpe/tasks/check-local.yml | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nagios-nrpe/files/check-local b/nagios-nrpe/files/check-local index 73db2c66..8b045cb0 100755 --- a/nagios-nrpe/files/check-local +++ b/nagios-nrpe/files/check-local @@ -1,12 +1,16 @@ -#!/usr/bin/bash +#!/usr/bin/env bash if ! test -f /usr/lib/nagios/plugins/check_nrpe; then echo '/usr/lib/nagios/plugins/check_nrpe is missing, please install nagios-nrpe-plugin package.' exit 1 fi +if [ -r /etc/nagios/nrpe.d/evolix.cfg ]; then + command=$(grep "check_$1" /etc/nagios/nrpe.d/evolix.cfg | tail -n1 | cut -d'=' -f2-) + printf "Command:\n $command\n" +fi - +printf "NRPE daemon output:" /usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c "check_$1" diff --git a/nagios-nrpe/files/check-local_completion b/nagios-nrpe/files/check-local_completion index 040d60d4..174ae061 100644 --- a/nagios-nrpe/files/check-local_completion +++ b/nagios-nrpe/files/check-local_completion @@ -3,9 +3,8 @@ _check_local_dynamic_completion() { local cur; cur=${COMP_WORDS[COMP_CWORD]}; - check_list=$(grep 'check_' /etc/nagios/nrpe.d/evolix.cfg | grep -vE '^[[:blank:]]*#' | awk -F'[\[\]=_]' '{print $3}') COMPREPLY=(); - COMPREPLY=( $( compgen -W '$(grep check_ /etc/nagios/nrpe.d/evolix.cfg | grep -vE "^[[:blank:]]*#" | awk -F"[\[\]=_]" "{print \$3}")' -- $cur ) ); + COMPREPLY=( $( compgen -W '$(grep check_ /etc/nagios/nrpe.d/evolix.cfg | grep -vE "^[[:blank:]]*#" | awk -F"[\\\[\\\]=_]" "{print \$3}")' -- $cur ) ); } complete -F _check_local_dynamic_completion check-local diff --git a/nagios-nrpe/tasks/check-local.yml b/nagios-nrpe/tasks/check-local.yml index 6718da3f..d2adbcd1 100644 --- a/nagios-nrpe/tasks/check-local.yml +++ b/nagios-nrpe/tasks/check-local.yml @@ -1,6 +1,9 @@ --- # Install check-local utilitary # This task is for Debian >= 10 only! +- name: "Remount /usr if needed" + ansible.builtin.include_role: + name: remount-usr - name: Package nagios-nrpe-plugin is intalled ansible.builtin.apt: