call a URL

Dear all ,
i need to ping a addresss in cause of timeout call a url ,
how i should give my URL to be call in a script ,

Try this. If the ping works, ping returns 1. If no response, it prints 0.

:put [:ping [:resolve www.mydomain.com] count=1]

And, unless they’ve fixed it recently, if the resolve fails the whole thing bombs.

:put [:ping [:resolve nosuchbeast.com] count=1]

That will give you an error (“failure: dns name does not exist”) rather than a 1 or 0.

I can overcome that. It requires two scripts if you want failsafe. Not real clean, but usable. You can call this first script whatever you like:

:global ipFlag 0
:global newIP

:execute getip

:delay 2

if ($ipFlag = 1) do={
  :put "good"
  :put $newIP
} else={
  :put "bad"
}

This is the getip script. You can change the name, but you must also change the execute call in the script above.

:global ipFlag
:global newIP [:resolve www.google.com]
:set ipFlag 1

It takes 2 seconds to resolve or fail, but it doesn’t abort.

Hi every One ,
is there a way on netwatch when a ip status goes down or up then mikrotik call a url ?

You can include this in the script to call a URL.

/tool fetch mode=http address=1.2.3.4 src-path="/myfile.php?test=me"

You can replace the address=1.2.3.4 with address=$newIP from my previous script. I tested this with an LAMP server. I cannot find a way (yet) to check if the page was loaded in the script or read the response tho.

Thank you guy i used

/tool fetch url="www.google.com"

working good