8.4. Accounting
8.4. Accounting
Regular LPD provides very little to help you with accounting. You
can specify the name of an accounting file in the af printcap attribute, but this is merely passed
as an argument to your if filter. It's up to you
to make your if filter write entries to the
accounting file, and up to you to process the accounting file
later (the traditional format is mainly useful for line printers,
and is nontrivial to parse in Perl, so there's no reason to
preserve it). Also, if you're using foomatic-rip program as your filter, you'll need
to make changes, since it depends on being given a configuration
file as the ``accounting'' file name.
CUPS provides page accounting by passing jobs through the pstops filter. This filter expects Postscript input. If you use print "raw" jobs, this is always counted as 1 page. This means that accounting will not work, if you print from Windows client with the native printer driver.
Ghostscript provides a PageCount operator that you can use to
count the number of pages in each job; basically you just tack a
few lines of postscript onto the end of the job to write an
accounting file entry; for the best example of this see the fileunix-lpr.sh in the Ghostscript source
distribution.
Note that the unix-lpr implementation of
accounting writes to a file from the Ghostscript interpreter, and
is thus incompatible with the recommended -dSAFER option. A
better solution might be to query the printer with a PJL command
after each job, or to write a postscript snippet that prints the
pagecount on stdout, where it can be captured without having to
write to a file.
The LPRng print spooler includes an HP-specific sample
implementation of accounting; I assume that it queries the
printer with PJL. This technique should work for most PJL,
Postscript, or SNMP printers with which you have two-way
communications.
If you have a networked printer that supports SNMP, you can use
the npadmin program to query a pagecount after each job. This
should work properly for all print jobs. See Section 11.10.1 for more information on npadmin.