Contribute Open Script

Sorry page generation with a script

by Derek_Kang on ‎10-16-2012 04:00 PM (71 Views)
Tested with Brocade ServerIron ADX

Yes.

Description

If no servers are available in the SLB pool, send a sorry page to a client. The sorry page is generated by a script, eliminating a need for a sorry page server.

Limitations

The maximum size of the sorry page content must be less than 1 K byte because OS_SLB::reply supports up to 1 K byte.

Required Environment

A global command ,“server l7-dont-reset-on-vip-port-fail”,  must be configured on the ADX unit.

Code

use strict;

use OS_SLB;

use OS_HTTP_REQUEST;

my $sorry_page;

sub BEGIN {

     #put your HTML body below; the content length is calculated automatically

     my $body = "We're sorry. The request service is not available.";

     my $body_len = length($body);

     my $hdr1 = "HTTP/1.1 200 OK\r\nContent-Length: ";

     my $hdr2 = "\r\nConnection: close\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n";

     $sorry_page = $hdr1.$body_len.$hdr2.$body;

     #print "$sorry_page\n";

}

sub HTTP_REQUEST {

     OS_SLB::forward(1);

}

sub SERVER_SELECTION_FAILURE() {

     OS_SLB::reply($sorry_page);

}

Comments
by alessandro.barisone on ‎10-29-2012 03:48 AM

Thanks for this add. What version of firmware have you used ?

Please could you paste the configuration steps to use this script, I' m newbie with ADX

Ale

by Derek_Kang on ‎10-29-2012 10:03 AM

12.4.00c was used to test the script.

Please, check out this link for OpenScript getting started guide, http://community.brocade.com/docs/DOC-2387