'whoami' in vrrp script

Hi,

The VRRP interfaces have an “on-master”/“on-backup” script trigger.
Is there a variable that specifies the vrrp interface that triggered the script?

Kind regards,
Ton

the idea is to be able to t.ex. “/system script run vrrphaschanged” in the ‘on master’ and ‘on backup’
then in the vrrphaschanged script have two variable that refers to which vrrp interface and to the (new-)state

For now i’ve worked around it with :global variables but that’s kind of an issue because they overwrite each other if multiple vrrp’s fail at the same time (t.ex. vlans on a trunk interface).
That too has been worked around, but clearly the idea above is more appealing and stable

It’s good idea, but currently it seems that it doesn’t exist. There’s nothing in documentation and none of obvious variable names I tried worked ($name, $interface, $“interface-name”).

use one unique global variable of type array,
create it on startup with all vrrp required like:

:global thearray [:toarray ""]
:foreach item in=[/interface vrrp find] do={
    :local iname [/interface vrrp get $item name]
    :set ($thearray->$iname) "unset"
}

and “on-master” / “on-backup” set the proper value before call the script, like:

:global thearray
:set ($thearray->"vrrp1234") "master"
/system script run vrrphaschanged

and inside vrrphaschanged you can read what vrrp is on master or on backup or unset (never run on-master or on-backup for that vrrp)

:global thearray
:foreach item,value in=$thearray do={
    :local vrname $item
    :local status $value
    :if ($status = "master") do={
        :log info "$vrname is now $status"

        # place here what you want to do if vrrp is on master status

        # you done it, set again unset for not execute again on next call
        :set ($thearray->$item) "unset"
    }
    :if ($status = "backup") do={
        :log info "$vrname is now $status"

        # place here what you want to do if vrrp is on backup status

        # you done it, set again unset for not execute again on next call
        :set ($thearray->$item) "unset"
    }
}