Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

ACE TCL Probe Timestamp of HTTP Page

A unique and specific requirement came my way a while back that I'd like to share. Although Cisco ACE is going EOL, they are not gone yet, so i guess some may find this useful. I was asked could an ACE probe a HTTP page for it's timestamp and fail the probe if the timestamp of said file had changed.

The fundemental requirement was that if the timestamp of this one file kept changing then the application had an issue and therefore the ACE VIP should be taken out of service or perhaps HTTP traffic was to be diverted to a maintenance page.

The ACE platform is not able to probe the timestamp of a webpage directly, so we had to use a custom script on the webserver to get this information a feed it back to ACE when requested. In this example we are using PHP, but most server-side languages should be able to generate the requested informaion.

The first and most important thing when writing code is to write up some pseudo code. This will give you an guide line to following when actually writing the required code.

1. write server side code to get timestamp from specific file and return value in specific format

2. write standard ACE TCL code, including debug settings

3. define variables and defaults if required

4. create http request to rserver and get output from custom server-side script

5. format outputted timestamp to tcl readable integer for calculation

6. store the lastest iteration of the retrived timestamp in a variable to be used the next time the TCL script is run (this is for comparison)

7. calculate difference in timestamps from previous iteration to this current iteration

8. if difference is 0 (no changes), if it greater than 0. thats a change to the monitor application file and therefore an error so probe is failed

From here the determine probe failure thresholds and values at the probe configuration directly on the ACE CLI. This script can be used a guide line on how to create your own custom scripted probe or you can use this one itself. As with all code, there is room for improvement here, with more check and balances unique to your requirement. This is not the finalised code that was implemented due to intellectiual property considerations.

time.php (server-side script)


// set timezone


// get file timestamp and output is specific format

echo date('omd His', filectime('file.php'));




# Created by: Stephen Stack (

# Created on: 1 Aug 2013



# debug procedure

# set the EXIT_MSG environment variable to help debug

# also print the debug message when debug flag is on


proc set_exit_msg { msg } {

    global debug ip port EXIT_MSG

    set EXIT_MSG $msg

    if { [ info exists ip ] && [ info exists port ] } {

        set EXIT_MSG "[ info script ]:$ip:$port: $EXIT_MSG "


    if { [ info exists debug ] && $debug } {

        puts $EXIT_MSG



set ip $scriptprobe_env(realIP)

set port $scriptprobe_env(realPort)

# If port is zero then use well known HTTP port 80

if { $port == 0} {

    set port 80


# check if debug flag is set

set debug [ lindex $argv 0 ]

if { $debug == "" } {

    set debug 0


# from

set sock [ socket $ip $port ] ;# open tcp socket

fconfigure $sock -translation crlf -blocking 1 -buffering line

puts -nonewline $sock "GET /time.php HTTP/1.0\n\n"

while {[gets $sock line] != -1} {

    lappend hlist $line

  #puts $line


# Read string back from server

set_exit_msg "receiving response"

set serverTimestamp [lindex $hlist end]

# timestamp to be presented in format 20130407 112013 - yyyymmdd HHmmss

set newTime [clock scan $serverTimestamp]

set_exit_msg "Server Timestamp : $newTime"

close $sock

#sets gset storedTime if not already set - 1st script iteration

if { ![ info exists storedTime ] } {

    gset storedTime $newTime


# calc differnece in times

set difference [expr {$newTime - $storedTime}]

set storedTime $newTime

# Indicate probe success with exit code 30001

# below is for testing only - actual logic to be defined

# set_exit_msg "probe success: diff: $difference Counter:$counter"

if { $difference == 0 } {

    set_exit_msg "probe success: diff: $difference"

    exit 30001

} else {

    set_exit_msg "probe fail : diff: $difference"

    exit 30002