Below script can be used to ping multiple hosts and clear fdb, and disable the script if ping loss happened. With this script, switch will ping from 172.27.77.201 ~ 172.27.77.210 and if more than 5 hosts show 100% ping loss, then it will stop the UPM profile named Test_SK.
set var 77ServerNum 201
set var i 0
while ($77ServerNum < 211) do
set var cli.out " "
ping count 10 172.27.77.$(77ServerNum)
set var split_list $TCL(split ${CLI.OUT} "\n")
set var percent $TCL(lsearch $split_list *%*)
set var lossline $TCL(lindex $split_list $percent)
set var loss $TCL(lindex $lossline 6)
if (!$MATCH($loss,100%)) then
create log message "172.27.77.$77ServerNum => Not Connected"
set var i ($i + 1)
endif
set var 77ServerNum ($77ServerNum + 1)
endwhile
if ($i <= 5) then
create log message "ping failed on $i hosts"
clear fdb vlan ToR
endif
if ($i > 5) then
disable upm profile Test_SK
endifTo execute the script periodically, upm profile and timer need to be configured on the switch. In below example, upm profile named Test_SK is configured to execute the script named pingtest and upm timer named Test_SKTimer configured to execute the profile named Test_SK every 240 seconds.
create upm profile Test_SK load script pingtest.xsf . configure upm profile Test_SK maximum execution-time 200 create upm timer Test_SKTimer configure upm timer Test_SKTimer profile Test_SK configure upm timer Test_SKTimer after 1 every 240
No comments:
Post a Comment