|
@@ -16,9 +16,11 @@
|
|
|
# - Updates status to be reported in CheckMK when prerequisites are missing.
|
|
# - Updates status to be reported in CheckMK when prerequisites are missing.
|
|
|
# Version 0.6:
|
|
# Version 0.6:
|
|
|
# - Added logic to also detect extension updates
|
|
# - Added logic to also detect extension updates
|
|
|
|
|
+# Version 0.7
|
|
|
|
|
+# - Changed updated logic completely as Directadmin's output changed
|
|
|
|
|
|
|
|
# Current active version of the script
|
|
# Current active version of the script
|
|
|
-SCRIPT_VERSION=0.6
|
|
|
|
|
|
|
+SCRIPT_VERSION=0.7
|
|
|
|
|
|
|
|
# Installation:
|
|
# Installation:
|
|
|
# This file should be placed on a/the DirectAdmin host in /usr/lib/check_mk_agent/local
|
|
# This file should be placed on a/the DirectAdmin host in /usr/lib/check_mk_agent/local
|
|
@@ -86,23 +88,17 @@ fi
|
|
|
DirectAdmin_Versions_Update=$("$DA_PATH"/build versions)
|
|
DirectAdmin_Versions_Update=$("$DA_PATH"/build versions)
|
|
|
# Define updates Array
|
|
# Define updates Array
|
|
|
updates=()
|
|
updates=()
|
|
|
|
|
+
|
|
|
# Iterate over the collected data to find possible updates
|
|
# Iterate over the collected data to find possible updates
|
|
|
-while read -r line; do
|
|
|
|
|
- if [[ "$line" =~ ^Latest\ version\ of\ (.+):\ (.+)$ ]]; then
|
|
|
|
|
- component="${BASH_REMATCH[1]}"
|
|
|
|
|
- latest="${BASH_REMATCH[2]}"
|
|
|
|
|
- elif [[ "$line" =~ ^Installed\ version\ of\ (.+):\ (.+)$ ]]; then
|
|
|
|
|
- installed="${BASH_REMATCH[2]}"
|
|
|
|
|
-
|
|
|
|
|
- # Compare versions using sort -V
|
|
|
|
|
- if [[ "$(printf '%s\n%s\n' "$installed" "$latest" | sort -V | head -n1)" != "$latest" ]]; then
|
|
|
|
|
- updates+=("$component")
|
|
|
|
|
- fi
|
|
|
|
|
- # Check for PHP extension updates
|
|
|
|
|
- elif [[ "$line" =~ ^(.+)[[:space:]]PHP[[:space:]]([0-9.]+)[[:space:]]extension[[:space:]].*[[:space:]]to[[:space>
|
|
|
|
|
|
|
+while IFS= read -r line; do
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if [[ "$line" =~ ^(.+)[[:space:]]([0-9][^[:space:]]*).*to[[:space:]]([0-9][^[:space:]]*)[[:space:]]update[[:space:]]is[[:space:]]available ]]; then
|
|
|
|
|
+
|
|
|
component="${BASH_REMATCH[1]}"
|
|
component="${BASH_REMATCH[1]}"
|
|
|
- php_version="${BASH_REMATCH[2]}"
|
|
|
|
|
- updates+=("$component PHP $php_version")
|
|
|
|
|
|
|
+ latest="${BASH_REMATCH[3]}"
|
|
|
|
|
+
|
|
|
|
|
+ updates+=("$component ($latest)")
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
done <<< "$DirectAdmin_Versions_Update"
|
|
done <<< "$DirectAdmin_Versions_Update"
|
|
@@ -112,5 +108,5 @@ if [[ ${#updates[@]} -eq 0 ]]; then
|
|
|
echo "0 \"$SERVICE Components\" - All $SERVICE Components are up to date"
|
|
echo "0 \"$SERVICE Components\" - All $SERVICE Components are up to date"
|
|
|
else
|
|
else
|
|
|
update_list=$(IFS=,; echo "${updates[*]}")
|
|
update_list=$(IFS=,; echo "${updates[*]}")
|
|
|
- echo "1 \"$SERVICE Components\" - $SERVICE Components ${update_list} have updates"
|
|
|
|
|
|
|
+ echo "1 \"$SERVICE Components\" - $SERVICE Components have updates: ${update_list}"
|
|
|
fi
|
|
fi
|