Thoughts on a "LoopProtect" type script..

So since the CRS3XX series switches do not really do loop protect and ive tested the storm control feature and it does not work good at all. I thought of asking the Globally hated ChatGPT to check logs for a message with “probably a loop” and then act on that message and so far it seems to disable the interface whenever the issue arises.

Thoughts ANYONE lol..

Thank you ..

:local loopMessage "probably a loop";
:local foundLogs [/log find message~"$loopMessage"];

# Loop through all found log entries
:foreach logId in=$foundLogs do={
    :local thisMessage [/log get $logId message];
    # Assume interface name follows immediately after "ether" and goes until the first space
    :local startIdx [:find $thisMessage "ether"];
    :local endIdx [:find $thisMessage " " startIdx];
    :local thisInterface "";

    # Check if "ether" is found and adjust endIdx if not found (i.e., end of message)
    if ($endIdx = -1) do={
        :set endIdx [:len $thisMessage];
    }
    :set thisInterface [:pick $thisMessage $startIdx $endIdx];

    # Check if the interface name is extracted correctly and exists
    :if ([:len [/interface find name=$thisInterface]] > 0) do={
        :log info ("Loop detected, shutting down interface: " . $thisInterface);
        /interface set [find name=$thisInterface] disabled=yes;
    }
}

Went a step beyond and added an email to it..
IMG_3687.PNG

Did you raise any supouts for bugs detected ??

No I think its pretty known that the CRS3X series with HW offload.. just dont do loop protect or storm control well.. But scripting kind of lets you do something about it yourself. I like that.. I mean the email come in like crazy but at an event I can react to the emails