Whole document tree 18.7. \LPRng accounting.pl UtilityThe LPRng accounting.pl utility provides the basic framework for using the :as=|, :ae=|, and pagecounter information written to the accounting file to do reliable accounting, and may be found in the LPRng distribution UTILS directory. Usually this is modified according to local site needs and installed in the filter directory. The utility maintains the accounting file by inserting a START record at the start of a job and an END record at the end of the job. It is assumed that the last END record in the file marks the last place that accounting was completed. The following shows the printcap entry for using the accounting.pl utility. The start and end options are used to specify that the utility is being called at the job start or end. printer :af=acct :as=|/usr/local/libexec/filters/accounting.pl start :ae=|/usr/local/libexec/filters/accounting.pl end At the start of each job the utilty writes a START record into the accounting file. This record can contain information suitable for use by local site. The exit code and information written to the utility STDOUT is used by the lpd server to determine if the job is to be printed. This allows job quotas to be implemented in a simple way by having the accounting.pl utility query a database with the user quotas and reject the job if the user's quota is exceeded. At the end of the job, the utilitity will read the accounting file and use the recorded information to update the accounting information. In order to make this reliable, the following steps are taken.
Administrators can use this script as a starting point for more advanced accounting. For example, rather than just recording the information, at the job start the script can query either a local database or a remote server to see if the user has permissions to access the printer. At the end of the job or when an END line is written to the accounting file, the local database or remote accounting server can be updated. |