From d6be03b24be9ab83d1a738376387ee715af783b5 Mon Sep 17 00:00:00 2001 From: Eric Loyd Date: Mon, 26 Aug 2024 16:29:10 -0400 Subject: [PATCH] Added ability to search .nagiosapikey instead of specific url --- napi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/napi b/napi index f6b5650..57dabef 100755 --- a/napi +++ b/napi @@ -295,12 +295,16 @@ do_debug 1 "Looking for url=$url in $APIkeyFile" APIKEY="$key" continue fi - if [ "$url" = "$XI_URL" ]; then +do_debug 2 "Looking for url=$url XI_URL=$XI_URL" + if [[ "$url" =~ "$XI_URL" ]]; then + XI_URL="$url" APIKEY="$key" fi done < "$APIkeyFile" fi +[ -z "$XI_URL" -o -z "$APIKEY" ] && echo "Empty URL or Key." && exit + do_api() { api_start="$1" api_command="$2" @@ -316,7 +320,7 @@ do_api() { url+="&$colName=$colVal" fi do_debug 2 "start=$1 command=$2" - do_debug 1 "Executing (tesmode=${myOptions[TestMode]}): $url" + do_debug 1 "Executing (testmode=${myOptions[TestMode]}): $url" [ -z "${myOptions[TestMode]}" ] && $curl -XGET -k "$url" }