move SEEN below, exit 0 when nothing is found
This commit is contained in:
parent
fc76bc00de
commit
bfcf5fd779
8
cpu.sh
8
cpu.sh
|
@ -17,17 +17,14 @@
|
||||||
THRESHOLD=90
|
THRESHOLD=90
|
||||||
TTL=10
|
TTL=10
|
||||||
GRACE=6
|
GRACE=6
|
||||||
#ps -uU _vmd | awk -v var="${THRESHOLD}" '$12 !~ /\// && $3 > var {print $12,$3}'
|
|
||||||
#
|
#
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
TIMESTAMP=$(date +%s)
|
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}')
|
OUT=$(ps -uU _vmd | awk -v var="${THRESHOLD}" '$12 !~ /\// && $3 > var {print $12}')
|
||||||
if [ -z "$OUT" ]; then
|
if [ -z "$OUT" ]; then
|
||||||
echo "No VM over the threshold overload"
|
echo "No VM over the threshold overload"
|
||||||
if ls /tmp/vm* 1> /dev/null 2>&1; then
|
rm -rf /tmp/vm*
|
||||||
rm -rf /tmp/vm*
|
exit 0;
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for VM in ${OUT}; do
|
for VM in ${OUT}; do
|
||||||
|
@ -66,6 +63,7 @@ for VM in ${OUT}; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
SEEN=$(ls -1 /tmp/vm* | awk -F'/' '{print $3}')
|
||||||
for s in ${SEEN[@]}; do
|
for s in ${SEEN[@]}; do
|
||||||
if [[ "${OUT[*]}" != *"${s}"* ]]; then
|
if [[ "${OUT[*]}" != *"${s}"* ]]; then
|
||||||
echo "${s} - remove from tracking list"
|
echo "${s} - remove from tracking list"
|
||||||
|
|
Loading…
Reference in New Issue