Here You have the full script.
For every ethernet set to auto-negotiation and running, the script checks the rate and full-duplex. If something is wrong send and e-mail. I have checked it in all situations: autoneg in 100Mbps and rate at 10Mbps, 1Gbps to 100Mbps and no full-duplex. And seems that it works.
I have placed it in all my aps and scheduled it every 3 hours. To disable it just unschedule the script or put the interface not to auto-negotiation.
In x86 plattforms all the ethernets appear as running spite there is no connection. In this case the script will alert about the unplugged interfaces. You can disable the unused ethernets or avoid using this script.
Thanks to c0d3rSh3ll for the help.
# For each ethernet connected and running
:foreach i in=[/interface ethernet find running] do={
#
# If configured at 100Mbps and auto-negotiation
# =============================================
:if ([/interface ethernet get $i speed]="100Mbps" and [/interface ethernet get $i auto-negotiation]=yes) do {
/interface ethernet monitor numbers=$i once do {
# If 10Mbps or without full-duplex send and e-mail
:if ($rate="10Mbps" or $"full-duplex"=false) do {
:put ("Ethernet with wrong auto-negotiation");
/tool e-mail send to="me@mycompany.com" subject=( "Ethernet with wrong auto-negotiation in " . [/system identity get name] ) tls=yes;
:delay 10;
:log info ("Ethernet error emailed at " . [/sys cl get time] . " " . [/sys cl get date])
}
}
}
#
# If configured at 1Gbps and auto-negotiation
# ===========================================
:if ([/interface ethernet get $i speed]="1Gbps" and [/interface ethernet get $i auto-negotiation]=yes) do {
/interface ethernet monitor numbers=$i once do {
# If 100Mbps or without full-duplex send and e-mail
:if ($rate="10Mbps" or $rate="100Mbps" or $"full-duplex"=false) do {
:put ("Ethernet with wrong auto-negotiation");
/tool e-mail send to="me@mycompany.com" subject=( "Ethernet with wrong auto-negotiation in " . [/system identity get name] ) tls=yes;
:delay 10;
:log info ("Ethernet error emailed at " . [/sys cl get time] . " " . [/sys cl get date])
}
}
}
}