11-04-2019 08:13 AM
I am trying to write a script to monitor port states and give a bit of diagnostic info. However, I have found it necessary to exclude some ports that are regularly used. I need help determining how to filter the event log to ignore these ports. Any help will be much appreciated.
event syslog pattern "%LINK-3-UPDOWN:" maxrun 60
action 1.0 regexp "GigabitEthernet([^,]+)" "$_syslog_msg" interface
action 1.1 cli command "enable"
action 1.2 wait 15
action 1.3 cli command "show int $interface status"
action 1.4 set _status "$_cli_result"
action 1.5 cli command "show mac address-table int $interface"
action 1.6 set _log1 "$_cli_result"
action 1.7 cli command "show logging | i %LINK-3-UPDOWN:"
action 1.8 set _log2 "$_cli_result"
action 1.9 cli command "show logging"
action 2.0 puts "$_cli_result"
action 2.1 set _body "$_status $_log1 $_log2 $_cli_result"
action 2.3 mail server "$_email_server" to "$_all_to_email" from "$_email_from" subject "$_hostname Port-State Change $interface" body "$_body" source-addr
#EEM #Scripting #automation
11-04-2019 12:21 PM
What I understand your requirement here is, you looking to monitor the ports and send an email - not any action with EEM Script.
If you looking largescale, i would suggest sending all the logs sys logs server and filter based on the information you looking for.
if that is not the case give a buzz.
11-04-2019 01:20 PM
@balaji.bandi wrote:What I understand your requirement here is, you looking to monitor the ports and send an email - not any action with EEM Script.
If you looking largescale, i would suggest sending all the logs sys logs server and filter based on the information you looking for.
if that is not the case give a buzz.
It is relatively small scale about 30 devices. I would love to filter/parse at the switch level without having the overhead of a logging server. The current script works great just can't filter so i am getting devices such as printers that loose connection when idle. So port-security takes care of those and is covered by a security script i have running. So no need to monitor them.
11-16-2019 09:46 PM
Where do you want to do the filtering? You're already going some here, so you can just extend that (i.e., the filter on GigabitEthernet).
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide