From bfcf5fd779b074f17f2b4653855d8906382a89c6 Mon Sep 17 00:00:00 2001 From: mischa Date: Tue, 14 May 2024 19:49:17 +0200 Subject: [PATCH] move SEEN below, exit 0 when nothing is found --- cpu.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cpu.sh b/cpu.sh index 3b7a999..74c8320 100755 --- a/cpu.sh +++ b/cpu.sh @@ -17,17 +17,14 @@ THRESHOLD=90 TTL=10 GRACE=6 -#ps -uU _vmd | awk -v var="${THRESHOLD}" '$12 !~ /\// && $3 > var {print $12,$3}' # HOSTNAME=$(hostname) TIMESTAMP=$(date +%s) -SEEN=$(ls -1 /tmp/vm* | awk -F'/' '{print $3}') OUT=$(ps -uU _vmd | awk -v var="${THRESHOLD}" '$12 !~ /\// && $3 > var {print $12}') if [ -z "$OUT" ]; then echo "No VM over the threshold overload" - if ls /tmp/vm* 1> /dev/null 2>&1; then - rm -rf /tmp/vm* - fi + rm -rf /tmp/vm* + exit 0; fi for VM in ${OUT}; do @@ -66,6 +63,7 @@ for VM in ${OUT}; do fi done +SEEN=$(ls -1 /tmp/vm* | awk -F'/' '{print $3}') for s in ${SEEN[@]}; do if [[ "${OUT[*]}" != *"${s}"* ]]; then echo "${s} - remove from tracking list"