Hello, I think it can be adjusted like that:In this adjusted version, the lastStatus variable is introduced to store the previous status. Before sending a notification, the script checks if the current status is different from the last status. If they are the same, no notification is sent.
Code:
:local emailTo "123@gmail.com":local emailSubject "Link Down - Unreachable Gateway Detected":local emailBody "An unreachable gateway has been detected.":local DeviceName [/system identity get name]:local commentFilters ("Default Route ISP1", "Default Route ISP2"):foreach commentFilter in=$commentFilters do={ :local unreachableGateways [:toarray [/routing route find where unreachable and comment=$commentFilter]] :local lastStatus ("") :if ([:len $unreachableGateways] > 0) do={ :local currentStatus ("Link Down - An unreachable gateway has been detected " . $commentFilter) :if ([:typeof $lastStatus] = "nil" || $lastStatus != $currentStatus) do={ :log warning $currentStatus /tool e-mail send to=$emailTo subject="[$DeviceName] $emailSubject $commentFilter" body="$emailBody" } :set lastStatus $currentStatus } else={ :set lastStatus "" }}
Statistics: Posted by mikefox — Wed Dec 13, 2023 9:41 am