3.5 Server Definition

Server definitions are principal part of any slb configurations. They define remote servers for which slb is to compute the load table. A server definition is a block statement which begins as:

 
server id {

The id argument specifies server ID, an arbitrary string of characters uniquely identifying this server. This ID will be used by log messages concerning this server. It can also be referred to in the output format definition (see section Output Configuration).

As usual, the definition ends with a closing ‘}’.

Statements inside the ‘server’ block supply configuration parameters for this server. Two parameters are mandatory for each server: its IP address and SNMP community:

 
  host ip;
  community string;

The ip argument can be either the IP address of the server in dotted-quad notation, or its host name. For example:

 
  host 192.168.10.6;
  community "public";

The most important part of a server definition is its load estimation function. It is basically an arithmetic expression of arbitrary complexity, with SNMP variables serving as its terms (see section Expression). It is defined using the ‘expression’ statement.

To begin with, suppose you want to use 1-minute load average as relative load. Let's name it ‘la1’. Then, the expression is very simple and can be defined as:

 
  expression "la1";

Now, ‘la1’ is a variable name, which should be bound to the corresponding SNMP variable. This binding is declared with the ‘variable’ statement:

 
  variable la1 "UCD-SNMP-MIB::laLoadFloat.1";

The ‘variable’ statement has two arguments. The first one is the name of a variable used in the expression and the second one is the SNMP OID which is bound to this variable. This OID is added to the list of OIDs queried during each poll of this server. When a SNMP reply is received, all instances of that variable in the expression are replaced with the value of the corresponding SNMP variable. Once all variables have been thus resolved, the expression is evaluated and its result is taken as the relative load for the given server.

Let's take a more complex example. Suppose you define the relative load to be a function of outgoing data transfer rate through the main network interface and the load average of the server. Data transfer rate is defined as first derivative of data transfer through the interface with respect to time. Let ‘out’ be the outgoing data transfer, ‘la1’ be the server's 1-minute load average, ‘k’ and ‘m’ be two server-dependent constants (weight coefficients). Given that, we define relative load as

 
  expression "sqrt(k * d(out)**2 + m * la1**2)";

The ‘**’ operator raises its left operand to the power given by its second operand. The two constructs ‘d(…)’ and ‘sqrt(…)’ are function calls. The ‘d()’ function computes first derivative of its argument with respect to time. The ‘sqrt()’ function computes the square root of its argument.

Now, let's define variable bindings:

 
  variable out "IF-MIB::ifOutOctets.3";
  variable la1 "UCD-SNMP-MIB::laLoadFloat.1";

The constantsk’ and ‘m’ are defined using the following statements:

 
  constant k 1.5;
  constant m 1.8;

The ‘constant’ statement is similar to ‘variable’, except that its second argument must be a floating-point number. Of course, in this particular example, the two constants could have been placed directly in the expression text, as in:

 
  expression "sqrt(1.5 * d(out)**2 + 1.8 * la1**2)";

However, defining them on a per-server basis is useful when the same expression is used for several different servers, as explained in the following section.

To conclude, here is our sample server definition:

 
server srv01 {
  host 192.168.10.6;
  community "public";
  expression "sqrt(k * d(out)**2 + m * la1**2)";
  variable out "IF-MIB::ifOutOctets.3";
  variable la1 "UCD-SNMP-MIB::laLoadFloat.1";
  constant k 1.5;
  constant m 1.8;
}