Community discussions

MikroTik App
 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

PTP Link wireless monitor

Wed Aug 29, 2018 8:47 pm

Thankfully the issue of a PTP link losing wireless registration only occurs very seldom but when it does it's never at a good time and a reboot appears to solve the issue, so what we are looking for is advice on how to create a script that on a PTP link when there is NO wireless registration for say 30 mins the router will reboot!
 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: PTP Link wireless monitor

Fri Aug 31, 2018 11:57 pm

So far my thoughts are the wireless registration status is the best to monitor

/interface wireless> monitor wlan1
status: searching-for-network

/interface wireless> monitor wlan1
status: connected-to-ess

Which gives me from the PTP station side two status options "searching-for-network" or "connected-to-ess"
:global u
/interface wireless monitor wlan1 once do={
{
:set u $status
  }
:if ($u = "searching-for-network") do={
:log info "No Wireless Registration"
if i could add to the script to prevent false positives or worse reboot loops,
(1) Run the script if it finds "No Wireless Registration"
(2) wait say 5 mins and then recheck wireless status again
(3) if (A) "No Wireless Registration" is found wait another 5 mins, or (B) if status is "connected-to-ess" :log info "Wireless Registration Restored"
(4) now 10 mins has elapsed, run wireless status again if "No Wireless Registration" is found then reboot the router
/system reboot
}
Any advice or suggestions on how to solve this is most welcome!
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Sun Sep 02, 2018 2:12 pm

sure this can help you
:do {
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "Wireless Registration Restored";:quit;}
:log info "No Wireless Registration";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "Wireless Registration Restored";:quit;}
:log info "No Wireless Registration";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "Wireless Registration Restored";:quit;}
:log info "No Wireless Registration";
/system reboot;
} on-error={}
 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: PTP Link wireless monitor

Tue Sep 04, 2018 6:14 pm

@ ADahi Many thanks for your help!
In testing so far the script which I have edited is working very good,
Workflow so far
(1) Scheduler item “Wireless_Registration_Monitor” Script runs every 10mins and restarts 10mins after a reboot,
(2) If after 10 mins ( 2 x 5mins wireless status checks) = “No Wireless Registration - 10 Mins Elapsed - Rebooting Now” is activated
(3) But before rebooting “Router Rebooted Email Warning” scheduler item is enabled!
(4) Router reboots and after 5mins scheduler item sends email “Router Rebooted Email Warning” and after 30 seconds this scheduler item is disabled to prevent sending further emails alerts every 5 mins!

Station side of PTP link ( will have to edit wireless status for AP side)
:do {
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:quit;}
:log info "No Wireless Registration Wait 1 - 5 mins";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "5Min Check - Wireless Registration Restored";:quit;}
:log info "No Wireless Registration Wait 2 - 5 mins";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "10min Check - Wireless Registration Restored";:quit;}
:log info "No Wireless Registration - 10 Mins Elapsed - Rebooting Now";
/system scheduler set [find name="Router Rebooted Email Warning"] disabled=no;
:delay 5s;
/system reboot;
} on-error={}
Router Rebooted Email Warning
:local adminmail1 someone@emailaddress.com ;
:local sub1 ([/system identity get name]) 
:local sub2 ([/system clock get time]) ;
:local sub3 ([/system clock get date]) ;
:local gmailid yourgmailaccount@gmail.com ;
:local gmailuser yourgmailaccount@gmail.com ;
:local gmailpwd your password ;
:local gmailport 587 ;
:local gmailsmtp ;
:set gmailsmtp [:resolve "smtp.gmail.com"];
/tool e-mail set address=$gmailsmtp port=$gmailport start-tls=yes from=$gmailid user=$gmailuser password=$gmailpwd;
/tool e-mail send to=$adminmail1 subject="$sub3 $sub2 $sub1 No Wireless Registration - 10 Mins Elapsed - Rebooting Now" start-tls=yes;
:delay 30s
/system scheduler set [find name="Router Rebooted Email Warning"] disabled=yes;
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Tue Sep 04, 2018 8:17 pm

I'm happy to help you, and without schedule extra script, I putted the Email warning script inside main script, edit it as you need.
:do {
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:quit;}
:log info "No Wireless Registration Wait 1 - 5 mins";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "5Min Check - Wireless Registration Restored";:quit;}
:log info "No Wireless Registration Wait 2 - 5 mins";
:delay 300s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"status")="connected-to-ess" ) do={:log info "10min Check - Wireless Registration Restored";:quit;}
:log info "No Wireless Registration - 10 Mins Elapsed - Sending Email Warning before Rebooting...";

 :do {/tool e-mail
 :local adminmail1 someone@emailaddress.com ;
 :local sub1 ([/system identity get name]) 
 :local sub2 ([/system clock get time]) ;
 :local sub3 ([/system clock get date]) ;
 :local gmailid yourgmailaccount@gmail.com ;
 :local gmailuser yourgmailaccount@gmail.com ;
 :local gmailpwd your password ;
 :local gmailport 587 ;
 :local gmailsmtp ;
 :set gmailsmtp [:resolve "smtp.gmail.com"];
 set address=$gmailsmtp port=$gmailport start-tls=yes from=$gmailid user=$gmailuser password=$gmailpwd;
 send to=$adminmail1 subject="$sub3 $sub2 $sub1 No Wireless Registration - 10 Mins Elapsed - Rebooting Now" start-tls=yes;
 } on-error={:log error "Rebooted Email Warning failed"}

/system reboot;
} on-error={}

 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: PTP Link wireless monitor

Tue Sep 04, 2018 8:45 pm

@ ADahi thank you,

Just a thought, generally the station side of a PTP will not have internet access when there is no wireless registration! so a alert email could not be sent?
This is the reason why I added the email to the scheduler which runs after rebooting when wireless registration and internet access has been re-established,

However the AP side may have internet access without wireless registration so the email alert could be sent before rebooting, from this it looks like station side and AP side would have different monitoring configurations used,

As I have already have netwatch checking PTP IP address's and will alert when an IP address is down,the purpose of this script is to solve by rebooting what I call partial router lockup resulting in loss of wireless registration of a PTP and if it works without any unforeseen issues I may use it on PTMP AP's.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Tue Sep 04, 2018 9:16 pm

As I have already have netwatch checking PTP IP address's and will alert when an IP address is down,the purpose of this script is to solve by rebooting what I call partial router lockup resulting in loss of wireless registration of a PTP and if it works without any unforeseen issues I may use it on PTMP AP's.
telegram bot notification is easier than email, as i did :)
 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: PTP Link wireless monitor

Wed Sep 05, 2018 1:06 am

With the AP using the script to monitor "status" will not work,
/in wi monitor wlan1 
status: running-ap
registered-clients: 0
authenticated-clients: 0
however "registered-clients" appears to be a good option
"registered-clients: 0" (less than 1 to trigger reboot)
"registered-clients: 1" (one or more to trigger no action)

Any suggestions !
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Wed Sep 05, 2018 4:57 am

off course will not work with AP, it is for station
you have to change if condition, as you suggested
:if ( ([/interface wireless monitor wlan1 as-value once]->"registered-clients")!=0 )

do you want schedule reboot for AP?, if so i think not good idea
can you export configuration here?, may be we can fix problem from root
 
n21roadie
Forum Guru
Forum Guru
Topic Author
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: PTP Link wireless monitor

Wed Sep 05, 2018 11:53 pm

I am looking at two variations of the script

(1) AP side of a PTP will have
(a) registered-clients: 0 - which should activate the 10 min script with 2 X min checks before rebooting
(b) registered-clients: 1 - No Action

(2) PTMP AP will have
(a) registered-clients: 0 - which should activate the 10 min script with 2 X min checks before rebooting
(b) registered-clients: 1 or more - No Action

As mentioned the problem does not occur very often but when the issue does occur it's usually late in the evening and this has resulted in customers being without internet access
until the following morning before the router is rebooted,
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Wed Sep 05, 2018 11:57 pm

next post
Last edited by ADahi on Thu Sep 06, 2018 12:09 am, edited 2 times in total.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: PTP Link wireless monitor

Thu Sep 06, 2018 12:07 am

For PtP and PtMP
:do {
:if ( ([/interface wireless monitor wlan1 as-value once]->"registered-clients")!=0 ) do={:quit;}
:log info "No Wireless Registration Wait 1 - 10 mins";
:delay 600s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"registered-clients")!=0 ) do={:log info "10Min Check - no issues, reboot not required";:quit;}
:log info "No Wireless Registration Wait 2 - 10 mins";
:delay 600s;
:if ( ([/interface wireless monitor wlan1 as-value once]->"registered-clients")!=0 ) do={:log info "20min Check - no issues, reboot not required";:quit;}
:log info "No Wireless Registration - 20 Mins Elapsed - Rebooting Now";

#put mail script here if required.

/system reboot;
} on-error={}

#Mail script
 :do {/tool e-mail
 :local adminmail1 someone@emailaddress.com ;
 :local sub1 ([/system identity get name]) 
 :local sub2 ([/system clock get time]) ;
 :local sub3 ([/system clock get date]) ;
 :local gmailid yourgmailaccount@gmail.com ;
 :local gmailuser yourgmailaccount@gmail.com ;
 :local gmailpwd your password ;
 :local gmailport 587 ;
 :local gmailsmtp ;
 :set gmailsmtp [:resolve "smtp.gmail.com"];
 set address=$gmailsmtp port=$gmailport start-tls=yes from=$gmailid user=$gmailuser password=$gmailpwd;
 send to=$adminmail1 subject="$sub3 $sub2 $sub1 No Wireless Registration - 10 Mins Elapsed - Rebooting Now" start-tls=yes;
 } on-error={:log error "Rebooted Email Warning failed"}
should working 100%, with no issues
waiting testing results

Who is online

Users browsing this forum: No registered users and 20 guests