|
@@ -1,6 +1,10 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Version 0.1 - initial start of this localcheck
|
|
# Version 0.1 - initial start of this localcheck
|
|
|
|
|
+# Version 0.2 - refined, and commented code further
|
|
|
|
|
+
|
|
|
|
|
+# Current active version of the script
|
|
|
|
|
+SCRIPT_VERSION=0.2
|
|
|
|
|
|
|
|
# Installation
|
|
# Installation
|
|
|
# This file should be place on a/the fusionauth host in /usr/lib/check_mk_agent/local
|
|
# This file should be place on a/the fusionauth host in /usr/lib/check_mk_agent/local
|
|
@@ -8,23 +12,64 @@
|
|
|
# (optional) if you want the check to run on a different schedule (like once per hour) put it in a subdirectory of above path
|
|
# (optional) if you want the check to run on a different schedule (like once per hour) put it in a subdirectory of above path
|
|
|
# named to the number of seconds of the interval wanted, so 3600/ for once an hour, 86400 for once per day.
|
|
# named to the number of seconds of the interval wanted, so 3600/ for once an hour, 86400 for once per day.
|
|
|
#
|
|
#
|
|
|
-# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/fusionauth.sh
|
|
|
|
|
|
|
+# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/fusionauth-version.sh
|
|
|
|
|
|
|
|
# (c) Michael Honkoop <mhonkoop@comsolve.nl>
|
|
# (c) Michael Honkoop <mhonkoop@comsolve.nl>
|
|
|
|
|
|
|
|
# License: GNU General Public License v2
|
|
# License: GNU General Public License v2
|
|
|
|
|
|
|
|
|
|
+######################
|
|
|
|
|
+# Configurable Parameters
|
|
|
|
|
+######################
|
|
|
|
|
+
|
|
|
|
|
+# url to check releases against
|
|
|
RELEASEURL="https://license.fusionauth.io/api/latest-version"
|
|
RELEASEURL="https://license.fusionauth.io/api/latest-version"
|
|
|
|
|
|
|
|
-FUSIONAUTH_VERSION_AVAIL=$(curl -s --connect-timeout 5 --fail-with-body $RELEASEURL)
|
|
|
|
|
|
|
+# Service name
|
|
|
|
|
+SERVICE="FusionAuth"
|
|
|
|
|
+
|
|
|
|
|
+######################
|
|
|
|
|
+# The code below should not be changed, unless you know EXACTLY what you are doing.
|
|
|
|
|
+# All configureable parameters are above this section.
|
|
|
|
|
+######################
|
|
|
|
|
+
|
|
|
|
|
+# Check if curl package is present on the system (required for this check)
|
|
|
|
|
+if ! command -v curl >/dev/null 2>&1; then
|
|
|
|
|
+ echo "2 \"$SERVICE\" - $SERVICE localcheck requires curl package to be installed"
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Get currently installed package information of FusionAuth
|
|
|
|
|
+mapfile -t fusionauth_packages < <(rpm -qa 'fusionauth*')
|
|
|
|
|
+
|
|
|
|
|
+# Check if package-manager returned packages, if none found report it
|
|
|
|
|
+if [ "${#fusionauth_packages[@]}" -eq 0 ]; then
|
|
|
|
|
+ echo "2 \"$SERVICE\" - No $SERVICE packages found on this host"
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Get latest avaiable version information.
|
|
|
|
|
+FUSIONAUTH_VERSION_AVAIL=$(curl -fsS --connect-timeout 5 --max-time 10 "$RELEASEURL")
|
|
|
|
|
+curl_rc=$?
|
|
|
|
|
|
|
|
|
|
+# Validate return-code from curl
|
|
|
|
|
+if [ "$curl_rc" -ne 0 ]; then
|
|
|
|
|
+ echo "3 \"$SERVICE\" - Unable to query release URL (curl exit code $curl_rc)"
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Check if the query did return something, if not report it
|
|
|
if [ -z "$FUSIONAUTH_VERSION_AVAIL" ];
|
|
if [ -z "$FUSIONAUTH_VERSION_AVAIL" ];
|
|
|
then
|
|
then
|
|
|
- echo "1 \"FusionAuth\" - No data received from release-URL, can not determine latest release-version"
|
|
|
|
|
|
|
+ echo "3 \"$SERVICE\" - No data received from release URL, can not determine latest release-version"
|
|
|
exit 0
|
|
exit 0
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-mapfile -t fusionauth_packages < <(rpm -qa 'fusionauth*')
|
|
|
|
|
|
|
+# Validate that the query returned a version
|
|
|
|
|
+if [[ ! "$FUSIONAUTH_VERSION_AVAIL" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
|
|
+ echo "3 \"$SERVICE\" - Unexpected response from release URL: $FUSIONAUTH_VERSION_AVAIL"
|
|
|
|
|
+ exit 0
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
outdated_packages=()
|
|
outdated_packages=()
|
|
|
|
|
|
|
@@ -34,8 +79,8 @@ for package in "${fusionauth_packages[@]}"; do
|
|
|
fi
|
|
fi
|
|
|
done
|
|
done
|
|
|
|
|
|
|
|
-if [ ${#outdated_packages[@]} -eq 0 ]; then
|
|
|
|
|
- echo "0 \"FusionAuth\" - All FusionAuth packages are up to date ($FUSIONAUTH_VERSION_AVAIL)"
|
|
|
|
|
|
|
+if [ "${#outdated_packages[@]}" -eq 0 ]; then
|
|
|
|
|
+ echo "0 \"$SERVICE\" - All $SERVICE packages are up to date ($FUSIONAUTH_VERSION_AVAIL)"
|
|
|
else
|
|
else
|
|
|
- echo "1 \"FusionAuth\" - Latest version Available ($FUSIONAUTH_VERSION_AVAIL), Update required for: ${outdated_packages[*]}"
|
|
|
|
|
|
|
+ echo "1 \"$SERVICE\" - Latest version Available ($FUSIONAUTH_VERSION_AVAIL), Update required for: ${outdated_packages[*]}"
|
|
|
fi
|
|
fi
|