commit bfcf5fd779b074f17f2b4653855d8906382a89c6 from: mischa date: Tue May 14 17:49:17 2024 UTC move SEEN below, exit 0 when nothing is found commit - fc76bc00dee7b1210f2c1e943a50ed6da9247fc7 commit + bfcf5fd779b074f17f2b4653855d8906382a89c6 blob - 3b7a999e09f7359f78d317625f3aaa601501eecd blob + 74c8320ea39101d5c08c2c0ed70938d128ed0a4b --- cpu.sh +++ 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"