From 4baa8fdde31cac12b358d4e68a1ca8a3e4ac8f31 Mon Sep 17 00:00:00 2001 From: Chl Date: Sun, 7 Jan 2024 15:52:20 +0100 Subject: [PATCH] nagios/check_gitea_version: proper nagios' way to separate address and hostname --- nagios/check_gitea_version.sh | 39 ++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/nagios/check_gitea_version.sh b/nagios/check_gitea_version.sh index fc97d83..f3038c8 100755 --- a/nagios/check_gitea_version.sh +++ b/nagios/check_gitea_version.sh @@ -6,14 +6,43 @@ # Stop at first uncatched error set -e -# note: some local problems with IPv4, the quickest way was to force IPv6. -LOCAL_VERSION="$( wget -6 -O - -q "https://$( hostname -f )/api/v1/version" | sed -n 's/{"version":"\([^"]\+\)"}/\1/p' )" +usage() { + cat </dev/null 2>&1; then + HOSTADDRESS="[$HOSTADDRESS]" + fi + ;; + + \?) + usage + exit 1 + ;; + esac +done + + +INSTALLED_VERSION="$( wget -O - --header="Host: $HOSTNAME" --no-check-certificate -q "https://$HOSTADDRESS/api/v1/version" | sed -n 's/{"version":"\([^"]\+\)"}/\1/p' )" UPSTREAM_VERSION="$( wget -q -O - "https://dl.gitea.io/gitea/" | egrep -- '