Options used:
destinations=destinations for jobs
router=router program
LPRng has the ability to route a job to one or more destinations in a dynamic manner. This is not the same as load balancing, as the destinations are hard coded and not able to be changed. This is accomplished by having a router filter generate a set of destinations. Here is a sample printcap entry:
t2|Test Printer 2 :sd=/var/spool/LPD/t2 :lf=log :destinations=t1@server1,t1@server2,t1@localhost :router=/usr/local/LPD/router
When a job arrives at the lpd server, the 'router' filter is invoked with the standard filter options which include the user, host, and other information obtained from the control file. STDIN is connected to a temporary copy of the control file, and the CONTROL environment variable is set to the value of the actual control file itself.
The routing filter exit status is used as follows:
0 (JSUCC) - normal processing
37 (JHOLD) - job is held
any other value - job is deleted from queue
The router filter writes to STDOUT a file specifying the destinations for the job. The destinations entries in this file file have the following format. Entry order is not important, but each destination must end with the 'end' tag.
dest (destination queue) copies (number of copies to be made) priority (priority letter) X(controlfile modifications) end
Example of router output:
In this example, two copies of the job will be sent to the t1 and t2 spool queue servers. The Class (C letter value) and job priority information will be rewritten with the indicated values.
If routing information is specified by the router filter the job will be sent to the default destination.
lpq will display job information in a slightly different format for multiple destination jobs. For example:
Printer: t2@h4 'Test Printer 2' (routed/bounce queue to 't1@h2.private')
Queue: 1 printable jobs in queue
Rank Owner/ID Class Job Files Size Time
active papowell@h4+707 A 707 /tmp/hi 3 10:04:49
- actv papowell@h4+707.1 A 707 ->t1@localhost <cpy 1/2> 3 10:04:49
- papowell@lprng2+707.2 A 707 ->t2@localhost 3 10:04:49
The routing information is displayed below the main job information. Each destination will have its transfer status displayed as it is transferred. By convention, the job identifier of the routed jobs will have a suffix of the form .N added; copies will have CN added as well. For example, papowell@lprng2+707.1C2 will be the job sent to the first destination, copy two.
Routed jobs can be held, removed, etc., just as normal jobs. In addition, the individual destination jobs can be manipulated as well. The LPC functionality has been extended to recognize destination jobids as well as the main job id for control and/or selection operations.
The optional destinations entry specifies the possible set of destinations that the job can be sent to, and is for informational purposes only. In order for lpq and lprm to find the job once it has been sent to lpd, lpq and lprm uses the list of printers in the destinations, and iterates over list looking for the job that you are interested in.