|
@@ -4,19 +4,23 @@
|
|
|
|
|
|
|
|
# License: GNU General Public License v2
|
|
# License: GNU General Public License v2
|
|
|
|
|
|
|
|
-# Version 0.1 (initial release)
|
|
|
|
|
-#
|
|
|
|
|
-# Version 0.2
|
|
|
|
|
-# Updated output to have updateable compontents comma-sepoarated.
|
|
|
|
|
-#
|
|
|
|
|
-# Version 0.3
|
|
|
|
|
-# Removed a duplicate routine, and added more comments
|
|
|
|
|
|
|
+# Version 0.1:
|
|
|
|
|
+# - initial release
|
|
|
|
|
+# Version 0.2:
|
|
|
|
|
+# - Updated output to have updateable compontents comma-sepoarated.
|
|
|
|
|
+# Version 0.3:
|
|
|
|
|
+# - Removed a duplicate routine, and added more comments
|
|
|
|
|
+# Version 0.4:
|
|
|
|
|
+# - Added check for DirectAdmin Core => Rediscovery is required if you had a previous version installed !
|
|
|
|
|
+
|
|
|
|
|
+# Current active version of the script
|
|
|
|
|
+SCRIPT_VERSION=0.4
|
|
|
|
|
|
|
|
# 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
|
|
|
-#
|
|
|
|
|
-# (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.
|
|
|
|
|
|
|
+#
|
|
|
|
|
+# (optional/reccomended) 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.
|
|
|
# Suggestion for this check is to run this once a day to minimize processing cost.
|
|
# Suggestion for this check is to run this once a day to minimize processing cost.
|
|
|
#
|
|
#
|
|
|
# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/direactadmin.sh
|
|
# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/direactadmin.sh
|
|
@@ -36,16 +40,46 @@ SERVICE="DirectAdmin"
|
|
|
# DO NOT CHANGE BELOW UNLESS YOU EXACTLY KNOW WHAT YOU ARE DOING #
|
|
# DO NOT CHANGE BELOW UNLESS YOU EXACTLY KNOW WHAT YOU ARE DOING #
|
|
|
#####################################################################
|
|
#####################################################################
|
|
|
|
|
|
|
|
|
|
+# Check if da command is present
|
|
|
|
|
+if ! command -v da >/dev/null 2>&1; then
|
|
|
|
|
+ echo "2 \"$SERVICE Core\" - $SERVICE executable was not found."
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Read installed DirectAdmin (core) version
|
|
|
|
|
+DA_INSTALLED=$(da version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1)
|
|
|
|
|
+
|
|
|
|
|
+# Check if a version was returned
|
|
|
|
|
+if [[ -z "$DA_INSTALLED" ]]; then
|
|
|
|
|
+ echo "2 \"$SERVICE Core\" - Unable to determine DirectAdmin Core version"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Read latest available DirectAdmin (core) version
|
|
|
|
|
+DA_AVAILABLE=$(da update --check 2>&1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1)
|
|
|
|
|
+
|
|
|
|
|
+# Check if a version was returned
|
|
|
|
|
+if [[ -z "$DA_AVAILABLE" ]]; then
|
|
|
|
|
+ echo "2 \"$SERVICE Core\" - Unable to determine available $SERVICE Core version"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Compare installed DirectAdmin version to available version
|
|
|
|
|
+if [[ "$DA_INSTALLED" = "$DA_AVAILABLE" ]]; then
|
|
|
|
|
+ echo "0 \"$SERVICE Core\" - $SERVICE Core is up to date: ($DA_INSTALLED)"
|
|
|
|
|
+elif [[ "$DA_INSTALLED" < "$DA_AVAILABLE" ]]; then
|
|
|
|
|
+ echo "1 \"$SERVICE Core\" - $SERVICE Core Update available: ($DA_AVAILABLE), Installed: ($DA_INSTALLED)"
|
|
|
|
|
+elif [[ "$DA_INSTALLED" > "$DA_AVAILABLE" ]]; then
|
|
|
|
|
+ echo "2 \"$SERVICE Core\" - $SERVICE Core installed: ($DA_INSTALLED) is higher then available: ($DA_AVAILABLE)"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
# Define global path of directAdmin
|
|
# Define global path of directAdmin
|
|
|
if [[ "$CustomBuild" -eq 1 ]]
|
|
if [[ "$CustomBuild" -eq 1 ]]
|
|
|
then
|
|
then
|
|
|
- DirAdmin_Path="/usr/local/directadmin/custombuild"
|
|
|
|
|
|
|
+ DA_PATH="/usr/local/directadmin/custombuild"
|
|
|
else
|
|
else
|
|
|
- DirAdmin_Path="/usr/local/directadmin"
|
|
|
|
|
|
|
+ DA_PATH="/usr/local/directadmin"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# store version information from DirectAdmin packages
|
|
# store version information from DirectAdmin packages
|
|
|
-DirectAdmin_Versions_Update=$("$DirAdmin_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
|
|
@@ -65,8 +99,8 @@ done <<< "$DirectAdmin_Versions_Update"
|
|
|
|
|
|
|
|
# Report findings back to CheckMK
|
|
# Report findings back to CheckMK
|
|
|
if [[ ${#updates[@]} -eq 0 ]]; then
|
|
if [[ ${#updates[@]} -eq 0 ]]; then
|
|
|
- echo "0 \"DirectAdmin\" - All DirectAdmin Versions 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\" - $SERVICE Versions ${update_list} have updates"
|
|
|
|
|
|
|
+ echo "1 \"$SERVICE Components\" - $SERVICE Components ${update_list} have updates"
|
|
|
fi
|
|
fi
|