run /tool command from scheduler | script

Hi all,

my question is quite simple but I have not been able to figure this one out.

Just a quick overview -

  • I am using /netwatch to update a mysql DB with some parameters i am passing along from my MkTik router
    Problem#1 = the netwatch UP event command does not seem to update when HOST is UP so I would have to manually fire it. I figured out by using /tool netwatch enable 0 it would force an update. So i thought hey cool i just use Scheduler to run this command every minute to update my DB?

From scheduler that does not seem to work either, so I thought ok then lets call a script from scheduler that will run the above command? but i cant get that part to work either…

All i want is this:

RUN the following console command every minute:: (or some other way forcing the UP script (netwatch) to run) :confused:

/tool netwatch enable 0


Help is much appreciated,
Thanks

Put this in a script, and schedule it to run once a minute. It does basically the same thing netwatch does, except it doesn’t remember the last value.

:if ([:ping 1.2.3.4 count=1] = 1) do={
    :log info "UP"
} else={
    :log info "DOWN"
}

BTW, my netwatch runs both up and down scripts ok, but only on network status change.

Thank’s a lot I understand this but here is another question.

  1. This means i am getting rid of the netwatch stuff and run everything i would do inside netwatch in this script instead correct?

Then how would I run my command inside that script?

/tool fetch mode=http host=www.mypage.eu src-path=("/page.php?somevar=1&anothervar=2") dst-path="/" port=80 \ host=www.mypage.eu



BTW, my netwatch runs both up and down scripts ok, but only on network status change.

Same issue here since i need this to run every 5 min and update the DB every 5 min.

:::EDIT EDIT EDIT:::
I figured it out guys!

So for anyone wondering here is what I did. (Utilities winbox)

  1. Use the if() script that was posted. (script is called “update_DB”)
  2. Call the tool command using :tool
  3. Use Scheduler and run it every minute - works like a charm in the “on Event” box just put the name of the script you want to run , no need for /system run etc, in my case “update_DB”

Thanks a lot for the help!

If this runs ok from a command line, then this should work.

/tool fetch mode=http host=www.mypage.eu src-path=/page.php?somevar=1&anothervar=2

Thanks I’ve updated my post above /tool would not work when using inside a script i had to use : instead of /

My bad. My script would not run without an address parameter and quotes around the src-path.

/tool fetch mode=http address=1.2.3.4 host=www.mypage.eu src-path="/page.php?somevar=1&anothervar=2" dst-path=page.php