#!/bin/bash

THRESHOLD=70

while true
do
    CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8}')
    CPU_INT=${CPU_USAGE%.*}

    if [ "$CPU_INT" -gt "$THRESHOLD" ]; then
        systemctl restart slipstream
        sleep 30
    fi

    sleep 5
done
