move SEEN below, exit 0 when nothing is found

This commit is contained in:
mischa 2024-05-14 19:49:17 +02:00
parent fc76bc00de
commit bfcf5fd779
1 changed files with 3 additions and 5 deletions

8
cpu.sh
View File

@ -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"