Parent proxy

my friends,
i have MT2.9.6 and i have 1.1.1.1 as my gateway and dns and 2.2.2.1 as my parent proxy. i want to write a script to check for me if my web-proxy can access the internet throw this parent proxy or not. example: sometimes i can ping my parent proxy but the internet on this parent proxy is down so my web-proxy stop serving requests throw this parent-proxy, so i want to write a script to check for me if my webproxy can resolve web pages or not if it can’t i want the script to change my parent proxy to another parent-proxy.
best regards

Just an idea - untested:

If you can write the necessary redirect rules to force traffic originating on the router itself to at least one internet test site you can download resources from to flow through the local proxy, you could write a script like this:

# set some parameters
:local server [:resolve "www.google.com"];
:local url "/index.html";
:local fileName "proxyTest";
:local firstProxy 1.1.1.1
:local secondProxy 2.2.2.2

# try to fetch the file
/tool fetch mode=http address=$server src-path=$url dst-path=$fileName;

# get a hold on the file
:local filePointer [/file find name=$fileName];
# check if it exists
:if ($filePointer != "") do={
# it does. all is well, parent proxy is alive
# delete the test download
    /file remove $filePointer;
} else={
# file could not be fetched. re-configure proxy
# first get current parent-proxy
	:local current [/ip proxy get parent-proxy];
# now flip them
	:if ($current = $firstProxy) do={
		/ip proxy set parent-proxy=$secondProxy;
	} else={
		/ip proxy set parent-proxy=$firstProxy;
	}
}

and schedule it to run every now and then. I don’t use the proxy so I’m not very familiar with what those redirect rules would look like, though.

HTH,

Felix

10x bro but i think there is an error in this script when i remove this command

try to fetch the file

/tool fetch mode=http address=$server src-path=$url dst-path=$fileName;
it run when i put it is stop run. i have MT 2.9.6
best regards

The fetch command is not available in ver 2.9.6. Upgrade to the latest version to use fetch.

done. and working great best regards.