Community discussions

MikroTik App
 
randallr
Member Candidate
Member Candidate
Topic Author
Posts: 104
Joined: Fri Oct 13, 2006 1:01 am
Location: Texas

Script to check Port Speed "Rate"

Sun Jan 01, 2012 8:13 pm

When a switch can't maintain 100mbps it drops a port to 10mbps.
I'm trying to do a script that can email me if a Port is at 10mbps.

The "Speed" shows what's configured when "Auto-Negotiate" is disabled
The "Rate" shows what the Port is currently operating at.

"Rate" is shown on winbox screen, but not from cli in the Value-List, and I cannot figure out how to script it.

Thanks for any help!
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Script to check Port Speed "Rate"

Mon Jan 02, 2012 10:09 am

use this :
/interface ethernet monitor <interface> 
here is sapmle output:
[admin@hs] > interface ethernet monitor ether1 
            status: link-ok
  auto-negotiation: done
              rate: 1Gbps
       full-duplex: yes
          phy-regs: ...
 
randallr
Member Candidate
Member Candidate
Topic Author
Posts: 104
Joined: Fri Oct 13, 2006 1:01 am
Location: Texas

Re: Script to check Port Speed "Rate"

Mon Jan 02, 2012 5:41 pm

Thanks for the reply.
My lack of scripting experience is now my problem-
I started with a simple script to check a single interface and create a log entry if true, but it doesn't work.


/int eth monitor ether2 once do={
:if ($"rate" = "10Mbps")
:log info "Ether2 is 10Mbps"
}

It doesn't execute from the Winbox screen, but from the Terminal, it brings up 'do: ' prompt, and execute correctly if I press enter.

Thanks!
 
randallr
Member Candidate
Member Candidate
Topic Author
Posts: 104
Joined: Fri Oct 13, 2006 1:01 am
Location: Texas

Re: Script to check Port Speed "Rate"

Mon Jan 02, 2012 6:56 pm

Nevermind- I figured it out....
 
fsjis1
just joined
Posts: 6
Joined: Tue Mar 08, 2016 11:21 pm

Re: Script to check Port Speed "Rate"

Fri Jan 27, 2017 11:34 pm

What did you figure out? Looking to do something similar. Thanks
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Script to check Port Speed "Rate"

Sun Jan 29, 2017 8:18 am

Just some examples:
/interface ethernet monitor ether2 once do={
 :if ($"status" != "link-ok") do={ :log info "ether2 is WITHOUT LINK"};
 :if ($"auto-negotiation" != "done") do={ :log info "ether2 auto-negotiation NOT WORKING"};
 :if ($"rate" != "100Mbps") do={ :log info "ether2 is NOT 100Mbps"};
 :if ($"full-duplex" = "no") do={ :log info "ether2 is NOT Full-Duplex"};
}
I'm Italian, not English. Sorry for my imperfect grammar.
 
rftnon
newbie
Posts: 29
Joined: Fri Feb 28, 2014 6:34 pm

Re: Script to check Port Speed "Rate"

Sun Feb 12, 2017 8:26 pm

Thanks ...
This is useful and good ...

Who is online

Users browsing this forum: No registered users and 18 guests