From 1842444e4ade961df7bc077ca0d0738cf9171ffe Mon Sep 17 00:00:00 2001 From: Danny de Kooker Date: Wed, 6 Sep 2023 16:03:52 +0200 Subject: [PATCH] Add Check_scripts/Linux - Disk usage monitor.sh --- Check_scripts/Linux - Disk usage monitor.sh | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Check_scripts/Linux - Disk usage monitor.sh diff --git a/Check_scripts/Linux - Disk usage monitor.sh b/Check_scripts/Linux - Disk usage monitor.sh new file mode 100644 index 0000000..65847b5 --- /dev/null +++ b/Check_scripts/Linux - Disk usage monitor.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Usage: "Linux - Disk usage monitor.sh" +# +# Description: +# This script is used from inside of Tactical RMM instances to check the Disk usage. +# This script should be deployed as a check script. +# +# Options: +# n/a +# +# Author: D. de Kooker (info@dcomputers.nl) +# Sources: https://www.activexperts.com/support/network-monitor/online/linux/ +# Changelog : +# 27-06-2022 - Initial script from source, tweaked for my environment + +#set value to percent threshold to monitor +VALUE=90 + +#parse disk usage percentages +OUTCODE=0 +declare -i OUTCODE +for line in $(df -hP | egrep '^/dev/[^loop]' | awk '{ print $1 "_:_" $5 }') + do + FILESYSTEM=$(echo "$line" | awk -F"_:_" '{ print $1 }') + DISK_USAGE=$(echo "$line" | awk -F"_:_" '{ print $2 }' | cut -d'%' -f1 ) + + if [ $DISK_USAGE -ge $VALUE ]; + then + echo -e "Disk Usage Alert: Needs Attention!" "A disk is using $DISK_USAGE% greater than threshold $VALUE%" + df -hP + OUTCODE+=1 + else + echo "Disk usage okay." + fi +done + +if [ $OUTCODE -gt 0 ]; +then + exit 1 +else + exit 0 +fi \ No newline at end of file