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?
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