event manager applet monitor_cdp
event syslog pattern "CDP-4-NOTIF.*CDP neighbor.*port_id"
action 1.0 cli command "enable"
action 2.0 cli command "show cdp neighbors"
action 3.0 regexp "(GigabitEthernet(?:8|11|12))" "$_cli_result" match intf_list
action 4.0 foreach intf $intf_list
action 5.0 cli command "show cdp neighbors interface $intf"
action 6.0 regexp "^(.*?)(?:$intf)(?:.*?)([A-Za-z]+[0-9]+(?:/[0-9]+)?) " "$_cli_result" match neighbor_intf
action 7.0 if "$neighbor_intf eq \"\""
action 8.0 cli command "conf t"
action 9.0 cli command "interface $intf"
action 10.0 cli command "shutdown"
action 11.0 syslog msg "Interface $intf was shut down due to CDP neighbor loss"
action 12.0 end
action 13.0 end