WFS dynamically provisions NetScaler VPX for SAP Load Balancing

In a previous post I discussed some use cases around the automatic provisioning of load balancing on a Citrix NetScaler using Citrix Workflow Studio.

We recently completed the follow-on project of creating a Workflow Studio script to perform a “Loop” to check the SAP Status Server on a regular basis, and dynamically Enable or Disable server load balancers in the NetScaler.

Drawing on the use cases from the previous post, we decided to build one WFS script to dynamically handle everything:

  • Auto-configure new SAP services
  • Graceful shutdown of SAP services

The latest script reads the SAP Status Server every x minutes or seconds, and based on the information in the SAP Status file, determines if a load balancing service should be enabled or disabled. This is useful for when SAP Servers are marked as “Down” and the NetScaler needs to reflect this change, dynamically. When the SAP Server comes back online, WFS enables the service in the NetScaler.

The WFS program that was designed to read the SAP Status Server is based on the SAP Message Server API specification, which can be found by clicking here.

SAP Status Message file format

<server-list> = “version” <major>”.”<minor> CRLF
<sap-server-name> CRLF
<protocol-type> <host> <port> <description> CRLF

<protocol-type> <host> <port> <description> CRLF
CRLF
<sap-server-name> CRLF
<protocol-type> <host> <port> <description> CRLF

<protocol-type> <host> <port> <description> CRLF

SAP Message field to NetScaler Config Mapping

Message Field
Maps to Citrix Config
Host Service name
Protocol-type J2EE HTTP
Protocol-type J2EES HTTPS
Host Server name or ip
Port port
Description LB=x If 0 shutdown

If <>0 add service if not already exists.

WFS Use Case

Read the file http://10.217.105.139/SAPStatus.htm
Skip 1st line. (version 1.2).

Loop1:
Read the sap-server-name, create Citrix NS Service.

  Loop2:
  Read message line.
  If Description LB=0, shutdown the service.
  If Description LB<>0 && doesn’t already exists the service, add the server and service:
  Server = host
  Port = port
  Protocol = HTTP if J2EE, HTTPS if J2EES.
  Sleep 30 seconds
  End Loop2. (if line = blank).

End Loop1. (eof)

Sample SAPStatus.htm file used in this POC

version 1.2
J2EE187834720
J2EE Server1 51800 LB=2
J2EES Server1 51801 LB=2
P4 Server1 51804 LB=2
P4S Server1 51805 LB=2
IIOP Server1 51806 LB=2
IIOPS Server1 51807 LB=2
TELNET Server1 51808 LB=2

J2EE187834721
J2EE Server2 55000 LB=1
P4 Server2 55004 LB=1
IIOP Server2 55007 LB=1
TELNET Server2 55008 LB=1

J2EE187834722
J2EE Server3 56000 LB=0
P4 Server3 56004 LB=0
IIOP Server3 56007 LB=0
TELNET Server3 56008 LB=0

Where:
Server1 is the Citrix NS Service Name
J2EE indicates use the HTTP Protocol
J2EES indicates use the HTTPS Protocol also.
51800 is the port number to use on the backend
LB=2 indicates the service is up and running (LB<>0)

Get your own and try it

Download WFS here

Download NetScaler VPX here

Download the WFS Script here

Download NetScaler config file here

Download Sample SAPStatus.htm file here

If your not running XenServer yet, you should be, its free

Dynamic Load Balancing in action

Tap into the power of AppExpert!