5.4 Expression

The following statement creates a named expression:

Config: expression name expr

Define the expression name to be expr.

Named expressions can be used as load estimation functions in server statements (see section expression) and invoked from the output format string (see section Output Format String).

Config: default-expression name

Declares the default expression. The name refers to a named expression declared elsewhere in the configuration file.

The default expression is used to compute relative load of servers whose ‘server’ declaration lacks explicit ‘expression’ definition (see server-expression).

The expr in the ‘expression’ statement is an arithmetical expression, which evaluates to a floating point number. The expression consists of terms, function calls and operators. The terms are floating point numbers, variable and constant names. The names refer to constants or SNMP variables defined in the definition of the server, for which this expression is being evaluated.

The following operations are allowed in expression:

Arithmetic operations

+

Addition

-

Subtraction

*

Multiplication

/

Division

**

Power

Named expression reference

A named expression reference is a reference to an expression defined by a ‘expression’ statement elsewhere in the configuration file. The reference has the following syntax:

 
@name

where name is the name of the expression as given by the first argument of its definition (see section Expression).

Ternary conditional operator

The ternary conditional operator is used to select a value based on a condition. It has the following form:

 
cond ? expr1 : expr2

The ternary operator evaluates to expr1 if cond yields ‘true’ (i.e. returns a non-null value) and to expr2 otherwise.

The condition cond is an expression which, apart from the arithmetic operators above, can use the following comparison and logical operations: