Hmm.. kali ini mimin bakal share tips & trik cara gimana saat link intermittent maka dilakukan tindakan, di sini mimin disable peer yg ngarah ke sono. Bisa sobat kembangkan sendiri yah. Ok langsung aja bikin scheduler
:global intermit
:global melar
:global limitnotif
:local avgRtt;
:local pin
:local pout
:local target 124.195.38.1
/tool flood-ping $target count=10 do={
:if ($sent = 10) do={
:set avgRtt $"avg-rtt"
:set pout $sent
:set pin $received
}
}
:local ploss (100 - (($pin * 100) / $pout))
:local LogErrorMsg ("Ping average for host%0A$target = ".[:tostr $avgRtt]."ms%0Apacket loss = ".[:tostr $ploss]."%")
:local LogWarnMsg ("Ping average for host%0A$target = ".[:tostr $avgRtt]."ms%0Apacket loss = ".[:tostr $ploss]."%")
:local LogError ("Ping average for $target = ".[:tostr $avgRtt]."ms - packet loss: ".[:tostr $ploss]."%")
:local LogWarn ("Ping average for $target = ".[:tostr $avgRtt]."ms - packet loss: ".[:tostr $ploss]."%")
:if ($avgRtt > 20) do={
:set melar ($melar +1)
:log error "$LogError"
} else={
:log warning "$LogWarn"
:set melar 0
}
# jika packetloss diatas 10% maka
:if ([:tostr $ploss] > 10) do={
:set intermit ($intermit +1)
:set limitnotif ($limitnotif +1)
} else={
:set intermit 0
}
# jika intermitent terus
:if ($intermit >=10) do={
:local pesan "$LogErrorMsg"
/routing bgp peer set [find name~"INIX" disabled=no] disabled=yes
/ip firewall mangle set [find comment="backup_conn" disabled=yes] disabled=no
:if ($limitnotif = 2) do={
/tool fetch url="https://api.telegram.org/bot380921546:AAGn69QpFDuLSOQd3E3JtI5nhfKDkdKMW/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
}
}
# jika tidak intermitent
:if ($intermit = 0) do={
:if ($limitnotif >=10) do={
:set limitnotif 0
}
:if ($limitnotif =0) do={
:set limitnotif ($limitnotif +1)
}
/routing bgp peer set [find name~"INIX" disabled=yes] disabled=no
/ip firewall mangle set [find comment="backup_conn" disabled=no] disabled=yes
:local pesan "$LogWarnMsg"
:if ($limitnotif =2) do={
/tool fetch url="https://api.telegram.org/bot380921546:AAGn69QpFDuLSOQd3E3JtI5nhfKDkdKMW/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
}
}
0 comments:
Post a Comment