EEM to monitor the status of a http get

Answered Question
Mar 22nd, 2010

Hi,

I am investigating whether it is possible to get EEM to monitor a ip sla for the http status code in a http get.  See blow:

GM12060#sh ip sla monitor operational-state 5
Entry number: 5
Modification time: *13:40:50.532 UTC Mon Mar 22 2010
Number of Octets Used by this Entry: 2656
Number of operations attempted: 1
Number of operations skipped: 0
Current seconds left in Life: Forever
Operational state of entry: Active
Last time this entry was reset: Never
Connection loss occurred: FALSE
Timeout occurred: FALSE
Over thresholds occurred: FALSE
Latest RTT (milliseconds): 76
Latest operation start time: *13:40:50.536 UTC Mon Mar 22 2010
Latest operation return code: OK
Latest DNS RTT: 35
Latest TCP Connection RTT: 17
Latest HTTP time to first byte: 41
Latest HTTP Transaction RTT: 24
Latest HTTP Status: 302
Latest HTTP Message Size: 807
Latest HTTP Entity-Body size: 218

What i would like to do is get EEM to stop the SLA when the HTTP status changes to 404.

I have looked at the ip sla EEM command and it doesnt allow you to monitor this attribute.


Is this even possible?

Thanks


Kev

Correct Answer by Joe Clarke about 6 years 11 months ago

You could use a simple timer applet to parse the output of "show ip sla stat 5 details" and look for the result code:

event manager applet check-ipsla

event timer watchdog time 60

action 001 cli command "enable"

action 002 cli command "show ip sla stat 5 details"

action 003 regexp "Latest HTTP Status: 404" $_cli_result

action 004 if $_regexp_result eq 1

action 005 cli command "config t"

action 006 cli command  "no ip sla schedule 5"

action 007 cli command "end"

action 008 syslog msg "Stopping IP SLA collector 5 as latest HTTP response code was 404"

action 009 end

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
yjdabear Mon, 03/22/2010 - 09:07

Since it appears EEM applets cannot parse CLI output ("event cli pattern" only handles CLI input), an EEM script sees necessary if the approach is to react to any potential "404" pattern appearing in the "sh ip sla monitor operational-state 5" output.

Joe Clarke Mon, 03/22/2010 - 09:21

It is possible, but given that you need to execute "show ip sla monitor" you definitely do not have EEM 3.0 yet.  Therefore, you will need to do this in an EEM Tcl policy.  I can provide an example if you want.

kevinhobson2000 Tue, 03/23/2010 - 01:06

Hi Joe,

Yes i have looked it up in the feature navigator and it didnt come in untill 12.4(22).


Would this do it?

Also if you could provide me with a example script that would help thanks as i am a mere novice when it comes to tcl scripting.

Thanks

Kev

Joe Clarke Tue, 03/23/2010 - 08:58

Yes, 12.4(22)T.  That includes EEM 3.0, and would open the door for a programmatic applet (i.e. without Tcl).  You could still accomplish what you want now, but it would require Tcl.  Would you like a Tcl example, or are you considering an upgrade?

kevinhobson2000 Tue, 03/23/2010 - 11:41

Hi Joe,

I have 12.4(24T) on a test router but i couldnt see anything under the event ipsla command that did what i require.

Im thinking it will have to use an if statement.

Would this be along the right lines?

Thanks

Kev

Correct Answer
Joe Clarke Tue, 03/23/2010 - 14:24

You could use a simple timer applet to parse the output of "show ip sla stat 5 details" and look for the result code:

event manager applet check-ipsla

event timer watchdog time 60

action 001 cli command "enable"

action 002 cli command "show ip sla stat 5 details"

action 003 regexp "Latest HTTP Status: 404" $_cli_result

action 004 if $_regexp_result eq 1

action 005 cli command "config t"

action 006 cli command  "no ip sla schedule 5"

action 007 cli command "end"

action 008 syslog msg "Stopping IP SLA collector 5 as latest HTTP response code was 404"

action 009 end

Actions

This Discussion