Community discussions

MikroTik App
 
thermant
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Sat Apr 21, 2007 6:17 am

Trying to customize a netwatch script. Need help. :p

Sat Aug 16, 2008 12:30 pm

Hi all,

I'm making a script (run by netwatch) to send me emails whenever the router is up/down, right? Well, there are some things that I'm unclear about, and am wondering if you guys can help. ^_^

1. I'm trying to make it so that the email would read "Router is down at dd-mm-yyyy hh:mm:ss", instead of just the "Router is down" that I have now.
Here's my current script:
source=
:log info "Main Gateway is DOWN";
/tool e-mail send from="admin@myrouter.com" server="xxx.xxx.xxx.xxx" 
body="Router is DOWN" subject="Router is DOWN" to="owner@myrouter.com"
I tried using + and &, doesn't work. Heheh... What's mikrotik's symbol for merging strings together?

2. I tried adding a flood ping before the "/tool e-mail send" line, like so:
/tool flood-ping xxx.xxx.xxx.xxx
:log info "Flood ping commenced"
Will the router do the flood ping just that once, or will it ping continuously?

3. I also want to make it so that in the log, the color of the line changes, say to red if down, green if up.
Is that possible?

4. It seems that there are quite a number of false positives generated by the script, and I'm trying to get rid of them. I read in the wiki that there's this script:
:local i 0; 
{:do {:set i ($i + 1)} while �i < 5) && ([/ping 64.233.169.99 interval=3 count=1]=0)};
:if ($i=5 && [/ip route get [find comment="Default Route"] distance]=1) do={:log info "Main Gateway down"; 
   /ip route set [find comment="Default Route"] distance=3}
If you read the 2nd line (the "do" line), there's a box after "while", right? I couldn't, for the live of me, guess what that character should be. If I copy-pasted from the forum, the line would read "while ?i < 5", and would give me an error when I tried to run it. Of course I will be modifying the script to better suit my situation, but can anyone please tell me what that character should be?

Thanks much.
 
thermant
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Sat Apr 21, 2007 6:17 am

Re: Trying to customize a netwatch script. Need help. :p

Wed Aug 27, 2008 11:57 am

One more thing, you guys...

I need to configure my proxy to cache not only stuff accessed through web browsers, but also through the various auto-patches performed by other applications that doesn't go through port 80 (http), say auto-patch for the anti virus, some online games, etc. I don't want my users to download the same thing everytime they want to patch the AV, or play games, or anything. Is this possible?

At the moment, this is what I have for my transparent proxy:
1 ;;; Proxy for Local LAN
chain=dstnat action=redirect to-ports=8080 in-interface=LOCAL dst-port=80
protocol=tcp

Is that enough? I mean, the way I see it, the "dst-port=80" part will only cache stuff that go through that port (http), right? (Sorry, mikrotik noob here).

If I want to cache other stuff that are downloaded by other applications that doesn't go through port 80, what should I add/change?

Thanks.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Trying to customize a netwatch script. Need help. :p

Wed Aug 27, 2008 12:19 pm

1. /tool e-mail send subject=( "Router is DOWN " . [ /system clock get date ] . " " . [ /system clock get time ] );
2. flood ping will execute continuously, use bw-test instead.
3. /log error "lalala" lien will be displayed in red.
4. replace ? with =($
 
thermant
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Sat Apr 21, 2007 6:17 am

Re: Trying to customize a netwatch script. Need help. :p

Mon Sep 01, 2008 12:51 pm

Yay! Thanks a lot for the answers. Will try it later.

Thanks again, mrz.

Now, can anyone answer my 2nd question? The one about port 80?

Thanks.

Who is online

Users browsing this forum: kymo2, linuxmint2 and 19 guests