#!/bin/bash

sleep 60 &&
while true
do
    error=`dmesg | grep Houston | tail -1`
    uptime=`cat /proc/uptime | tr '.' ' ' | awk {'print $1'}`
    errortime=`echo $error | tr '[' ' ' | tr ']' ' ' | tr '.' ' ' |awk {'print $1'}`

    if [ `expr $errortime + 5` -gt $uptime ]; then
    	ethall=`ifconfig | grep kvm | tr ':' ' ' | awk {'print $1'}`
        for eth in ${ethall[@]}
        do
            /usr/sbin/tc qdisc del dev $eth root 2>/dev/null
            sleep 0.0005
            /usr/sbin/tc qdisc del dev $eth ingress 2>/dev/null
            sleep 0.0005
        done
        /usr/bin/systemctl restart limit
        sleep 5
    fi
    sleep 1
done
