You are here: Smart Control > Smart Control Classes > Server Pool Class (srvpool)

Server Pool Class (srvpool)

Parameters

The following are Server Pool parameters. Refer to Server Pool and Server Instance Commands for descriptions.

name (string)

acvq (string)

probe_maxtries (int)

probe_dto (int)

custom_actconn (int)

policy (string)

acvr (string)

probe_gto (int)

custom_hc (int)

probe_ssl (bool)

respv (int)

probe_interval (int)

probe_cto (int)

custom_delay (int)

disable (bool)

Methods

getByName(string name)

 

Description:

Fetch the server pool named ‘name’ from the configuration.

 

Returns:

On success: server pool object populated with all of its properties. On failure: An exception with a message and an error code.

 

Example:

// Fetch a server pool named ‘sp00’

$sp = srvpool::getByName("sp00");

getInstanceByName(string name)

 

Description:

Fetch the server instance named ‘name’ which is part of this server pool from the configuration.

 

Returns:

On success: server instance object populated with all of its properties.  On failure: An exception with a message and an error code.

 

Example:

// Fetch a server pool named ‘sp00’ and then fetch its server instance ‘si00’

$sp = srvpool::getByName("sp00");

$si = $sp->getInstanceByName("si00");

getInstanceList()

 

Description:

List server instances for this server pool from the configuration.

 

Returns: A map with the following keys:

si_list: list of server instance names as strings

message: a status message indicating success or failure of the operation

status: a status code: 0 indicates success, nonzero indicates failure

Example:

// Get list of server instances from server pool ‘sp00’

$sp = srvpool::getByName(“sp00”);

$list = $sp->getInstanceList();

// loop through the names in the “si_list”

for ($counter = 0; $counter < count($list["si_list"]); $counter++) {

// each name in the list is $list["si_list"][$counter]

}

getStatusDescription()

 

Description:

Get the status of this server pool as a string.

 

Returns:

A string containing the status of this server pool.

 

Example:

$sp = srvpool::getByName(“sp00”);

// print the status – accessible using ‘lastrun’ command.

echo $sp->getStatusDescription();

getStatusResp()

 

Description:

Get the status of this server pool as a numeric value.

 

Returns: A numeric value indicating the status:

0: There are no problems with this server pool.

1: There is an ‘informational’ status available, but the server pool is functional.

2: There is a problem with this server pool.

Example:

// If there is a problem with this pool, print the status (accessible using ‘lastrun’ command).

$sp = srvpool::getByName(“sp00”);

if ($sp->getStatusResp() == 2) {

         echo $sp->getStatusDescription();

}

stats(string statName)

 

Description:

Get the value of the statistic named ‘statName’.  The available statistics are the same as those displayed in the CLI when using the srvpool <name> stats command.

 

Returns:

On success, the last-measured value of this statistic. On failure, an exception describing what went wrong: invalid statistic name or no statistic specified.

 

Example:

$sp = srvpool::getByName(“sp00”);

if ($sp->stats(“TOTALPRCSD”) > 100) {

       echo “Processed more than 100 requests through sp00”;

}

delete(optional Boolean forceFlag)

 

Description:

Delete this server pool.  Can only be used on a server pool object which has been retrieved using srvpool::getByName(), and it must not have been modified since the last time that it was retrieved.  If the server pool is in use by another object in the system, the flag forceFlag must be set to ‘TRUE’ in order for it to be deleted.

 

Returns:

Map containing message string with a status code. Status code will be 0 if the deletion was successful and non-zero otherwise.

 

Example:

$sp = srvpool::getByName(“sp00”);

// Try to delete it, if it fails, force the deletion.

$value = $sp->delete();

if ($value[“status”] != 0) {

   // Print out the reason for the failure, accessible using ‘lastrun’ command

   echo “Failed to delete because: “, $value[“message”];

   $value = $sp->delete(TRUE);

}

commit()

 

Description:

Push the changes to this server pool into the permanent configuration. If this server pool object was created using getByName(), this operation is treated as a modify. If it was created using the new keyword, it is treated as an addition.

 

Returns:

Map containing message string with a status code.  Status code will be 0 if the commit was successful and non-zero otherwise.

 

Example:

// Create a new server pool, then modify it

$sp = new srvpool;

$sp->name = "newsp";

$sp->commit();

 

// If we don’t do getByName(), the commit() below would fail with ‘object already exists’ error because the system will try to add this object instead of modify it.

$sp = srvpool::getByName("newsp");

$sp->probe_maxtries = 2;

$sp->commit();