Traffic Script Debug Tip

Posted: June 8th, 2009 under Tool, Tips and Tricks, Zeus ZXTM.

When you write traffic script make sure that you comment you scripts with plenty of debug information to facilitate testing.

image

Example:

$responseLocation = http.getResponseHeader(“Location”);
$body = response.get();
$responseCode = http.getResponseCode();

log.info( “Location at Zone A ZXTM is : ” . $responseLocation );
log.info( “Body is : ” . $body );

# Test for HTTP 302, Location is HTTP and body contains HTTPS
if (($responseCode == 302) && (string.startsWith($responseLocation,”http://”)) && ( string.contains($body, “a href=’https://”)) ){

# Rewrite location header
$responseLocation = string.replace($responseLocation, “http:”, “https:”);
log.info( “Location has been rewriten to : ” . $responseLocation );
http.setResponseHeader( “Location”, $responseLocation );

}

View Log

Then when you are testing your scripts SSH to the ZXTM and run the following command to view the log as events are written to it.

tail –f /usr/local/zeus/zxtm/log/errors

You can then view the log as you test to check that your script is behaving as expected.

Once complete rather than amending your script, which could potentially introduce bugs. change the logging level in the ZXTM config to not log info messages.

You simply turn this on and off as required for testing.

clip_image002

clip_image004

Happy Debugging :)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment