User guide

- 96 -
Appendix D
Sample Custom CGI Code
The custom cgi-bin checking program may be written in Java, VB, C, or Perl, for example, or
it may be a WB or shell script. Here is sample script written for the linux shell bash which
sees if an SSH daemon is running as its check criterion.
#!/bin/bash
echo “Content-type: text/plain”
echo # blank line
if ps -C sshd &>/dev/null ; then
echo “OK” # response from server goes here, see list below.
echo “SSH service available”
else
echo “NOT OK”
echo “SSH daemon not running”
fi
The following is a list of valid CGI code responses:
OK server/service is alive, no weight change
NOT OK server/service is dead
OVERLOAD set weight to 0, to quiesce (same as “WEIGHT=0”)
QUIESCE set weight to 0, to quiesce (same as “WEIGHT=0”)
WEIGHT=n set weight to integer n
WEIGHT-=n subtract integer n from the weight
WEIGHT+=n add integer n to the weight
The response must be in all capitals to be recognized. The changes in weight count as an
unsaved configuration change. It is not automatically saved. Anything not matching the
above list will cause the WebMux to believe the server is not responding properly, thus the
server will be taken out of service.
When the WebMux sends its health check, it will provide information in a query string that
can be passed to your custom health check script. For example, the actual request from the
WebMux will include the query string:
/custom?farm=<IP>:<PORT>&server=<IP>:<PORT>&alive=1&standby=0&favorite=0
&lastresort=0&weight=1
“farm” and “server” each consist of a dotted quad IP address followed by a colon and a port
number (a server port of 0 means the port is the same as what is specified on the farm IP).
“weight” is the numerical weight. The remaining items are either 0 for false or 1 for true.
You can have your script access the query string elements for further processing.