Learn OpenScript

Best Practices for OpenScript Writing and Trouble Shooting

by Derek_Kang on ‎08-01-2012 04:55 PM (142 Views)

Introduction


OpenScript is a Perl based scripting language. It provides ultimate flexibility of load balancing to meet various needs of applications or situations otherwise not possible to meet with traditional fixed set of layer 7 features. For example, with OpenScript, you can inspect HTTP response messages and scrub off credit card numbers. You can build a sorry page and shoot it on the fly when a service is not available; no extra server is required. You can collapse hundreds of content matching rules into very few with regular expression. Not enough? You can even inject a java script into a response message based on the analysis of a HTTP request message.

Fortunately, writing an OpenScript is not much different from writing a Perl script. First, define a requirement of what you want to do with traffic flow and come up with a step-by-step logic. Then, write the logic in OpenScript and compile. Lastly, fix any problems, mostly syntax errors, found in the compilation and run it.

Perhaps, the major difference between regular Perl and OpenScript is the way how OpenScript sub routine is invoked.  An OpenScript sub routine name is the pre defined name of an event.  The sub routine is invoked when an associated event is triggered. For example, the HTTP_REQUEST sub routine is associated with a HTTP request event and is called when ADX receives a HTTP request message.

As with writing any scripts, some guidelines will help you improve the readability and the performance of the script. Also, they will greatly save your time in trouble shooting. Let’s take a look at those guide lines in details.

Download the attachment for the full content.