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..
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
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 ]
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!
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…