Community discussions

MikroTik App
 
SA0BJW
newbie
Topic Author
Posts: 33
Joined: Sun Jul 07, 2013 12:51 am

Script to generate ISP fault complaint.

Tue Nov 10, 2015 11:12 pm

Hi..

Got a problem with my ISP and my connection (optical fiber, 1000/100 Mbit).

My internet access breaks down almost every evening.. The connection can be lost for some minutes up to an hour..
The big problem is that the ISP is a lazy a-hole.. :-( and does nothing to solve the problem.

They blame my equipment, although all of my neighbors have the same problem.

So I want to write a script to generate an automatic fault complain to my ISP:s email. (Will mail myself and do a manual forward to ISP later.)

This is what I have in mind..

2 Scripts, one when the connection breaks down (identifyed by pinging 8.8.8.8 by netwatch) that collects some information, and the other one when the line is restored..

Script_DOWN!

Check WAN_IP
Check WAN_DEFGATEWAY
Check TIME_DOWN
PING WAN_DEFGATEWAY



Script_UP!

Check Router_up_time
If Router_up_time <60 min (To prevent false mail if router restarted recently)
Check TIME_UP
Calculate TOTAL_TIME=TIME_UP - TIME_DOWN
IF TOTAL_TIME <10 min (To prevent mail in case of short disruptions)
Create Email to "support@isp.org" (or my own mail for manual forward);
Print "Fault complaint to ISP"
Print "My IP adress; WAN_IP
Print "My MAC address"; XX:XX:XX:XX:XX:XX (They always want to know it, I don´t know why..)
Print "My def gateway; WAN_DEFGATEWAY
Print "Def gateway answer on ping" ; Yes/No (Good to know!, sorts out local problems.)
Print "Down Time"; TIME_DOWN
Print "Up Time"; TIME_UP
Print "Total downtime"; TOTAL_TIME
Send Mail;
EndIf
EndIf

END


Is this even possible?
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 282
Joined: Tue Feb 10, 2015 3:21 pm

Re: Script to generate ISP fault complaint.

Wed Nov 11, 2015 9:31 am

You can use this as an example,

Here is down script - will start count timeout in seconds:
{
:global work true
:global timeout 0
:while ($work=true) do={
:set $timeout ($timeout +1);
:delay 1s;
}
}


Up script, will stop down script loop by changing $work state, and read timeout value, if uptime is more then 60m, will start some action...

{
:set $work false;
:if ([/system resource get uptime]>00:60:00) do={
log info "Link UP, total timout: $timeout seconds";}
}

Use get command to take all necessary information:
[/ip address get [/ip address find interface=ether1] address ]

Use tool email command to send mail
http://wiki.mikrotik.com/wiki/Manual:Tools/email

You can attach all necessary information in email body,subject or also attach file.
 
SA0BJW
newbie
Topic Author
Posts: 33
Joined: Sun Jul 07, 2013 12:51 am

Re: Script to generate ISP fault complaint.

Wed Nov 11, 2015 7:26 pm

Hi!

Thanx a lot!!

I´m a newbie on scripting i Mikrotik, but this will help me a lot!
 
SA0BJW
newbie
Topic Author
Posts: 33
Joined: Sun Jul 07, 2013 12:51 am

Re: Script to generate ISP fault complaint.

Wed Nov 18, 2015 12:16 am

Tonight I had a disconnect of my connection, and my (yours) script did a great job! My ISP has a fault complaint waiting for them tomorrow! This will help me a lot! All my down:s are now automatically mailed to the ISP, and when it´s time to pay the bill they have to give me a discount!

Thank you for helping me!
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Wed Nov 18, 2015 4:55 pm

Great idea. What if they catch your ping packets elsewhere and send the responses back to you even the gateway is not reachable? What if they drop all your pings even the gateway is reachable? What it says about the Internet accessibility when gateway is reachable? Just ideas for further improvements....