Page 1 of 1

Yet another interface check script

Posted: Thu Sep 03, 2020 10:16 pm
by vklpt
https://github.com/vikilpet/mikrotik-interface-check
Advantages:
- Can be used for one or more interfaces.
- Any type of interface.
- Ping several addresses (relying on one is too unreliable).
- You can run it as often as you like - it can detect fail relatively fast.
- Easy setup - you only need to set a couple of variables.

Bonus: function to replace substrings:
global funReplace do={
    local s $1
    while ( [typeof [find $s $2 -1]] != "nil" ) do={
        local start [find $s $2 -1]
        set s ( \
            [pick $s 0 [$start - 1] ] \
            . $3 \
            . [ \
                pick $s \
                ($start + [len $2]) \
                [len $s] \
            ] \
        )
    }
    return $s
}
Test:
put [$funReplace "inter=%int% and mark=con_%int%" "%int%" "ETHER1"]

Re: Yet another interface check script

Posted: Thu Sep 03, 2020 10:17 pm
by vklpt
Demo: