5.7 Output Configuration

The statement discussed in this section configure formatting of the server load table on output.

Config: head number

Print at most number entries from the top of the table, i.e. the number of the less loaded server entries.

Config: tail number

Print at most number entries from the bottom of the table, i.e. the number of the most loaded server entries.

Config: output-file string

Send output to the channel, identified by string. Unless string starts with a pipe sign, it is taken as a literal name of the file. If this file does not exist, it is created. If it exists, it is truncated. The file name can refer to a regular file, symbolic link or named pipe.

If string starts with a ‘|’ (pipe), the rest of the string is taken as the name of an external program and its command line arguments. The program is started before slb enters its main loop and the formatted load table is piped on its standard input.

Config: begin-output-message string

Defines the text to be output before the actual load table contents. The string is taken literally. For example, if you want it to appear on a line by itself, put ‘\n’ at the end of it (see backslash-interpretation).

Config: end-output-message string

Defines the text to be output after the actual load table contents. The string is taken literally.

Config: output-format string

Defines format for outputting load table entries. See the subsection below (see section Output Format String), for a description of available format specifications.

5.7.1 Output Format String

The format string is composed of zero or more directives: ordinary characters (not ‘%’), which are copied unchanged to the output; and conversion specifications, each of which is replaced with the result of a corresponding conversion. Each conversion specification is introduced by the character ‘%’, and ends with a conversion specifier. In between there may be (in this order) zero or more flags, an optional minimum field width and an optional precision.

Flags

0

The value should be zero padded. This affects all floating-point conversions, i.e. ‘w’ and ‘{...}’, for which the resulting value is padded on the left with zeros rather than blanks. If the ‘0’ and ‘-’ flags both appear, the ‘0’ flag is ignored. If a precision is given with a floating-point conversion, the ‘0’ flag is ignored. For other conversions, the behavior is undefined.

-

The converted value is to be left adjusted on the field boundary. (The default is right justification.) Normally, the converted value is padded on the right with blanks, rather than on the left with blanks or zeros. A ‘-’ overrides a ‘0’ if both are given.

' ' (a space)

A blank should be left before a positive number (or empty string) produced by conversion.

The field width

An optional decimal digit string (with non-zero first digit) specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left (or right, if the ‘-’ flag has been given).

In no case does a nonexistent or small field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result.

The precision

An optional precision, in the form of a period (‘.’) followed by an optional decimal digit string. If the precision is given as just ‘.’, or the precision is negative, the precision is taken to be zero. This gives the number of digits to appear after the radix character for floating-point conversions or the maximum number of characters to be printed from a string, for string conversions.

The conversion specifier

A character or a sequence of characters that specifies the type of conversion to be applied. The conversion specifiers are replaced in the resulting output string as described in the table below:

i

The server identifier.

h

The server hostname, as set by the host configuration directive.

w

Computed relative load.

{var}

The value of the variable var.

{@expr-name}

The result of evaluating expression expr-name in the context of the current server.

(macro)

Expansion of the macro.

%

The percent character.