cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2759
Views
0
Helpful
3
Replies

EEM Monitor Port Status but exclude Certain ports

J8339
Level 1
Level 1

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

3 Replies 3

balaji.bandi
Hall of Fame
Hall of Fame

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.

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help


@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.

Joe Clarke
Cisco Employee
Cisco Employee

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).