SLB |
|
Simple Load Balancer |
Sergey Poznyakoff |
SLB User Manual (split by node): | ? |
The slb
configuration can be quite complex, therefore it is
important to verify that it behaves as expected before actually
implementing it in production. Three command line options are provided
for that purpose.
The ‘--dry-run’ (or ‘-n’) option instructs the program to start in foreground mode and print to the standard output what would have otherwise been printed to the output file. Additional debugging information is displayed on the standard error.
The ‘--eval’ option initiates expression evaluation mode. In
this mode slb
evaluates the expression whose name is
supplied as argument to the option. Actual values of the variables
and constants used in the expression are supplied in the command
line in form of variable assignments. The result is printed to the
standard output. For example, if the configuration file contains
expression load "(la1/100 + usr/1024)/2"; |
then the command
slb --eval=load la1=30 usr=800 |
will print ‘.540625’.
If the expression contains calls to ‘d()’ (derivative), you will need several evaluations to compute its value. The minimal number of evaluations equals the order of the highest derivative computed by the expression, plus 1. Thus, computing the following expression:
expression load "sqrt(k * d(out)**2 + m * la1**2)"; |
requires at least two evaluations. To supply several values to a single variable, separate them with commas, e.g.: ‘out=16000,20000’. This will run first evaluation with ‘out=16000’ and the second one with ‘out=20000’. For example:
$ slb --eval=load k=1.5 m=3 out=16000,20000 la1=0.4 16.3446 |
Notice, that you don't need to supply the same number of values for each variable. If a variable is assigned a single value, this value will be used in all evaluations.
A more elaborate test facility is enabled by the ‘--test’
option. This option instructs slb
to read SNMP variables
and their values from a file and act as if they were returned by SNMP.
The output is directed to the standard output, unless the
‘--output-file’ option is also given.
The input file name is taken from the first non-option argument. If it is ‘-’ (a dash) or if no arguments are given, the standard input will be read:
slb --test input.slb |
The input file consists of sections separated by exactly one empty
line. A section contains assignments to SNMP variables in the style
of snmpset
(2). Such assignments form several server groups, each
group being preceded by a single word on a line, followed by a
semicolon. This word indicates the ID of the server to which
the data in the group belong. For example:
srv01: UCD-SNMP-MIB::laLoadFloat.1 F 0.080000 IF-MIB::ifOutUcastPkts.3 c 346120120 srv02: UCD-SNMP-MIB::laLoadFloat.1 F 0.020000 IF-MIB::ifOutUcastPkts.3 c 2357911693 |
This section supplies data for two servers, named ‘srv01’ and ‘srv02’.
SLB User Manual (split by node): | ? |
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.