cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9797
Views
3
Helpful
1
Comments
ashirkar
Level 7
Level 7

 

Introduction:

This document created from discussion, in this discussion user is looking for EEM script that will generate syslog Message and send mail alert when IP SLA Tracking condition goes down.

 

In this document, I will show you how to configure a simple EEM script sending mail when IP SLA track goes down.This script can be used in various scenarios like if you want a track specific routes which is flapping frequently in your network and want to have email alerts as soon as it goes unreachable.

 

Topology Diagram:

 

R1 and R2 are directly connected and running OSPF as IGP between them. All interfaces configured as per diagram.

 

On R1, we will be tracking R2's Loopback IP address 192.168.1.2 using IP SLA and create EEM Applet script so that if track on R1 goes down it will send email alerts.

 

ipsla.jpg

 

Basic Configuration:-

 

R1R2

hostname R1

!

ip cef

!

interface Loopback0

ip address 192.168.1.1 255.255.255.255

ip ospf 100 area 0

!

interface FastEthernet1/0

ip address 10.1.1.1 255.255.255.252

ip ospf 100 area 0

speed auto

duplex auto

!

interface FastEthernet1/1

ip address 1.1.1.1 255.255.255.252

ip ospf 100 area 0

speed auto

duplex auto

!

router ospf 100

hostname R2

!

ip cef

!

interface Loopback0

ip address 192.168.1.2 255.255.255.255

ip ospf 100 area 0

!

interface FastEthernet0/0

ip address 10.1.1.2 255.255.255.252

ip ospf 100 area 0

duplex auto

speed auto

!

router ospf 100

 

IP SLA config and EEM script:

 

R1(config)#ip sla 1

R1(config-ip-sla)# icmp-echo 192.168.1.2

R1(config-ip-sla-echo)# frequency 5

R1(config-ip-sla-echo)#exit

R1(config)#ip sla schedule 1 life forever start-time now

R1(config)#

R1(config)#track 1 ip sla 1 reachability

R1(config-track)#delay down 2 up 2

R1(config-track)#exit

 

event manager applet track_SLA_1

 

event track 1 state down

 

action 1.0 syslog msg "IPSLA collector 1 timed out"

 

action 2.0 mail from "user@example.com" to "user@example.com" subject "IPSLA Collector 1is down" body "IPSLA Collector 1 has timed out" server "1.1.1.2"

 

Verification:

 

1) Let’s verify track: track is up now

 

R1#sh track 1

Track 1

  IP SLA 1 reachability

  Reachability is Up

    5 changes, last change 00:00:25

  Delay up 2 secs, down 2 secs

  Latest operation return code: OK

  Latest RTT (millisecs) 76

  Tracked by:

    EEM applet track_SLA_1

 

To trigger EEM script our track should go down. Removing OSPF advertisement from R2 and also turning dubug to verify on R1.

 

R2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R2(config)#int lo 0

R2(config-if)#no ip ospf 100 area 0

R2(config-if)#end

R2#

 

R1#debug event manager action cli

Debug EEM action cli debugging is on

R1#

*Sep 30 03:26:24.686: %TRACKING-5-STATE: 1 ip sla 1 reachability Up->Down

R1#

*Sep 30 03:26:24.762: %HA_EM-6-LOG: track_SLA_1: IPSLA collector 1 timed out

R1#

*Sep 30 03:26:45.794: %HA_EM-3-FMPD_SMTP: Error occurred when sending mail to SMTP server: 1.1.1.2 : timeout error

R1#

 

As you can see while sending, I’m getting error because, I don’t have SMTP server but if you have it will work for you.

 

Comments
roger perkin
Level 2
Level 2

Ashish,

This is great, however I tried to implement it on a 3750 switch and did not have the option in the EEM applet for

event track?

Is there another way on the 3750 to do this?

Many Thanks

Roger

http://www.rogerperkin.co.uk/ccie

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco