I use this
My warring log I set to action email so I get mailed for warning log entries
The address list entry should look like this
add address=10.0.0.175 comment=wcsnet-ps1*100 list=“router ping”
:global scriptemail
:global lastping
:local content
:local checkip
:local checklaststatus
:local checknewstatus
:local checkcomment
:local difference
:local list
:local alerts 0
:log info “******************** starting - ip ping report********************”
:log info “-”
:foreach i in=[/ip firewall address-list find] do={
:set list ([/ip firewall address-list get $i list] )
:if ($list = “router ping”) do={
:set checkip ([/ip firewall address-list get $i address] )
:set content ([/ip firewall address-list get $i comment] )
:if ([:find $content “*”] != “”) do={
:local pos1 [:find $content “*”]
:local pos2 [:len $content]
:set checklaststatus ([:pick $content ($pos1+1) $pos2])
:set checkcomment ([:pick $content 0 ($pos1)])
:local perc ([/ping $checkip count=10] * 10)
:set checknewstatus “$perc”
:set difference (checknewstatus - $checklaststatus)
:if ($difference < 0) do={
:set difference ($difference * -1)
} else={
:set difference ($difference * 1)
}
:if (difference >= 50 ) do={
/ip firewall address-list set $i comment=“$checkcomment*$checknewstatus”
:set alerts ($alerts + 1)
:log warning “$[/system identity get name] connectively test state changed [ $checkcomment ] $checklaststatus → $checknewstatus state difference: $difference”
}
}
}
}
:set lastping “$[/system clock get date] $[/system clock get time]”
:log info “******************** ending - ip ping report ********************”