Community discussions

MikroTik App
 
User avatar
vklpt
newbie
Topic Author
Posts: 36
Joined: Mon Feb 18, 2019 1:13 pm
Location: Izhevsk
Contact:

Yet another interface check script

Thu Sep 03, 2020 10:16 pm

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"]
Last edited by vklpt on Thu Sep 03, 2020 10:19 pm, edited 2 times in total.
 
User avatar
vklpt
newbie
Topic Author
Posts: 36
Joined: Mon Feb 18, 2019 1:13 pm
Location: Izhevsk
Contact:

Re: Yet another interface check script

Thu Sep 03, 2020 10:17 pm

Demo:
You do not have the required permissions to view the files attached to this post.