From 72727a8332f1087eb27402967d484731f8480275 Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Fri, 12 Jan 2024 13:35:21 +0100 Subject: [PATCH] nagios-nrpe: check_phpfpm_multi expand globing of args --- nagios-nrpe/files/plugins/check_phpfpm_multi | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nagios-nrpe/files/plugins/check_phpfpm_multi b/nagios-nrpe/files/plugins/check_phpfpm_multi index b02fc7e2..e21ecf87 100644 --- a/nagios-nrpe/files/plugins/check_phpfpm_multi +++ b/nagios-nrpe/files/plugins/check_phpfpm_multi @@ -19,14 +19,21 @@ nb_ok=0 nb_unchk=0 output="" -readonly POOL_FOLDER=${1:-$(detect_pool_dir)} +# We want globbing to be expanded here +# shellcheck disable=SC2206 +readonly POOL_FOLDER=( ${1:-$(detect_pool_dir)} ) -if [[ ! -d "$POOL_FOLDER" ]]; then - echo "CRITICAL - $POOL_FOLDER does not exists" +if [ "${#POOL_FOLDER[@]}" -gt 1 ]; then + echo "CRITICAL - '${POOL_FOLDER[*]}' contains more than one directories" + exit 2 +fi; + +if [[ ! -d "${POOL_FOLDER[0]}" ]]; then + echo "CRITICAL - ${POOL_FOLDER[0]} does not exists" exit 2 fi; -readonly POOL_FILES=$(find "$POOL_FOLDER" -name "*.conf") +readonly POOL_FILES=$(find "${POOL_FOLDER[0]}" -name "*.conf") for pool_file in $POOL_FILES; do