why [10.0.0.2] ?
Simply write the IP
using url "mode" and "http-method" are useless (https url = https mode, ? on ulr = get mode, post is unnecessary)
This is based on another script I have revised, send only one messages when status change.
:local host 10.0.0.2
:global hoststatus
# for test "warning unstable" set the count to 9
:local checkhost [/ping $host count=10]
:if ($checkhost = 0) do={
:if ($hoststatus != "offline") do={
/log error "Host $host change status from $hoststatus to offline"
/tool fetch keep-result=no \
url="https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat-id>&text=Komputer-Offline"
/tool wol interface=ether12DAPO mac=xx:xx:xx:xx:xx:xx
}
:set hoststatus "offline"
}
:if (($checkhost > 0) && ($checkhost < 10)) do={
:if ($hoststatus != "unstable") do={
/log warning "Host $host change status from $hoststatus to unstable"
/tool fetch keep-result=no \
url="https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat-id>&text=Connection-Unstabe"
}
:set hoststatus "unstable"
}
:if ($checkhost = 10) do={
:if ($hoststatus != "online") do={
/log info "Host $host change status from $hoststatus to online"
/tool fetch keep-result=no \
url="https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat-id>&text=Komputer-Online"
}
:set hoststatus "online"
}