search tag # rextended check host status
evidenced errors on your script:
:global vdsdown
:local host 192.168.1.252 # better put the editable things up:local checkvds [/ping $host count=3]
:if ($checkvds = 0) do={ # $ must used for call variables:if ($vdsdown != true) do={
/log warning "Host $host is offline"; # useless ";" :set $vdsdown true # $ must not be used on set}
} else={
:if ($vdsdown != false = true) do={ # better != false instead of =true/log info "Host $host is online"; # useless ";" :set $vdsdown false # $ must not be used on set}
}
My revised version:
:local host 192.168.0.101
:global vdsdown
:global vdsstatus
# for test "warning unstable" set the count to 2
:local checkvds [/ping $host count=3]
:if ($checkvds = 0) do={
:if ($vdsstatus != "offline") do={ /log error "Host $host change status from $vdsstatus to offline" }
:set vdsstatus "offline"
:set vdsdown true
}
:if (($checkvds > 0) && ($checkvds < 3)) do={
:if ($vdsstatus != "unstable") do={ /log warning "Host $host change status from $vdsstatus to unstable" }
:set vdsstatus "unstable"
:set vdsdown false
}
:if ($checkvds = 3) do={
:if ($vdsstatus != "online") do={ /log info "Host $host change status from $vdsstatus to online" }
:set vdsstatus "online"
:set vdsdown false
}