Community discussions

MikroTik App
 
tnrclkr
newbie
Topic Author
Posts: 27
Joined: Tue Aug 25, 2015 8:36 am

Future request / Ether / CRC errors

Thu Jun 28, 2018 12:16 pm

is it possible to add warnings when ether rate goes below 100Full. When there is an error on ports its not really easy to figureout for netadmins.
 
User avatar
artz
MikroTik Support
MikroTik Support
Posts: 88
Joined: Tue Oct 17, 2017 5:51 pm
Location: Riga
Contact:

Re: Future request / Ether / CRC errors  [SOLVED]

Thu Jun 28, 2018 12:28 pm

Scripts come in handy.
Similarly you can monitor link flaps as well.
:global InformedLinkStatus 0;

#Monitor link rate
/system script
add name=ether1check owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":local ss [/in eth mo \
    ether1 as-value once];\r\
    \n:local rate (\$ss->\"rate\");\r\
    \n:if (\$rate != \"1Gbps\") do={\r\
    \n    :if ([:len [\$rate]] = 0) do={\r\
    \n        :if (InformedLinkStatus = 0) do={\r\
    \n            /tool e-mail send to=\"admin@network.com\" subject=\"Port is not linked\" body=\"\
    You need to fix the network, ether1 is not linked at all!\"\r\
    \n            :set InformedLinkStatus 1;\r\
    \n        }\r\
    \n    } else={\r\
    \n        :if (InformedLinkStatus = 0) do={\r\
    \n            /tool e-mail send to=\"admin@network.com\" subject=\"Port is not using 1Gbps\" bo\
    dy=\"You need to fix the network, ether1 is not linked at 1Gbps!\"\r\
    \n            :set InformedLinkStatus 1;\r\
    \n        }\r\
    \n    }\r\
    \n} else={\r\
    \n    :if (InformedLinkStatus = 1) do={\r\
    \n        :set InformedLinkStatus 0;\r\
    \n    }\r\
    \n}\r\
    \n"

/system scheduler
add interval=1m name=ether1checker on-event=ether1check policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=sep/22/2017 \
    start-time=08:31:31
    
#Monitor link flaps
{
    :global arrayXpush do={
        :local arrX value=[:toarray $1];
        :if ([:len $arrX] = 0) do={ :set $arrX value=[:toarray ""]; };
        :local arrXlen value=[:len $arrX];
        :local valX value=[:tostr $2];
        :if ($valX = "") do={ :return value=$arrX; };
        :local posX value=([:tostr $3]);
        :if ($posX = "") do={ :set $posX value=($arrXlen + 1); };
        :set $posX value=([:tonum $posX] + 0);
        :if ($posX < 0) do={ :set $posX value=0; };
        :if ($posX > $arrXlen) do={ :set $posX value=$arrXlen; };
        :if ($posX = 0) do={ :return value=($valX,$arrX); };
        :if ($posX = $arrXlen) do={ :return value=($arrX,$valX); };
        :return value=([:pick $arrX 0 ($posX - 1)],$valX,[:pick $arrX ($posX - 1) $arrXlen]);
};
    :global linkdownsold;
    :local linkdowns;
    :set $linkdowns [:toarray ""]; 
    :local j 0;
    :foreach i in=([/interface find]) do={
        :local tmp;
        :local tmp2;
        :set $tmp [/interface get $i link-downs];
        :set $tmp2 [:pick $linkdownsold $j];
        :set $linkdowns [$arrayXpush $linkdowns $tmp];
        :if ([/interface get $i type] = "bond") do={
            :if ($tmp > $tmp2) do={
                :put ([/interface get $i name]. " has flapped, was down ".$tmp2." times, now is ".$tmp." down times!");
            }
        }
        :set $j ($j+1);
    }
    :set $linkdownsold $linkdowns;
}
    

Who is online

Users browsing this forum: holvoetn, janisc and 26 guests