Sfoglia il codice sorgente

Iinitial release of fusionauth-version.sh

Michael Honkoop 6 giorni fa
parent
commit
a41463bc9d
1 ha cambiato i file con 41 aggiunte e 0 eliminazioni
  1. 41 0
      localchecks/fusionauth-version.sh

+ 41 - 0
localchecks/fusionauth-version.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Version 0.1 - initial start of this localcheck
+
+# Installation
+# This file should be place on a/the fusionauth host in /usr/lib/check_mk_agent/local
+#
+# (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.
+#
+# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/fusionauth.sh
+
+# (c) Michael Honkoop <mhonkoop@comsolve.nl>
+
+# License: GNU General Public License v2
+
+RELEASEURL="https://license.fusionauth.io/api/latest-version"
+
+FUSIONAUTH_VERSION_AVAIL=$(curl -s --connect-timeout 5 --fail-with-body $RELEASEURL)
+
+if [ -z "$FUSIONAUTH_VERSION_AVAIL" ];
+then
+    echo "1 \"FusionAuth\" - No data received from release-URL, can not determine latest release-version"
+    exit 0
+fi
+
+mapfile -t fusionauth_packages < <(rpm -qa 'fusionauth*')
+
+outdated_packages=()
+
+for package in "${fusionauth_packages[@]}"; do
+    if [[ "$package" != *"$FUSIONAUTH_VERSION_AVAIL"* ]]; then
+        outdated_packages+=("$package")
+    fi
+done
+
+if [ ${#outdated_packages[@]} -eq 0 ]; then
+    echo "0 \"FusionAuth\" - All FusionAuth packages are up to date ($FUSIONAUTH_VERSION_AVAIL)"
+else
+    echo "1 \"FusionAuth\" - Update required for: ${outdated_packages[*]}"
+fi