Tue Feb 03, 2015 11:11 am
This is a newer version it runs on 6.25
For this to work you have to add address list items and then these are pinged
Example:
/ip firewall address-list
add address=8.8.8.8 comment="google dns1*100" list="router ping"
The comment field is used to store the ping result as well as a friendly name
# wcsnet, copyright © 2010. all rights reserved
# script version : 1.0
:do {
:global lastping
:local content
:local checkip
:local checklaststatus
:local checknewstatus
:local checkcomment
:local difference
:log info "******************** starting - ip ping report********************"
:log info "-"
:foreach i in=[/ip firewall address-list find list="router ping" and disabled=no] 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)
}
/ip firewall address-list set $i comment="$checkcomment*$checknewstatus"
:if (difference >= 50 ) do={
: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 ********************"
} on-error={
:log error "script failure [ ip - ping ]"
}