Where does CUPS store kB and page count accounting information?

Kurt Pfeifle k1pfeifle at gmx.net
Wed Nov 7 16:14:10 PST 2007


Paul wrote:
> Hello,
> 
> I'm having trouble finding out where CUPS stores kB and page count 
> accounting information on a per user basis.

It's not in an ASCII file.

For each job the IPP job attributes are stored separately, in the
/var/spool/cups/c* 'control' files. These files are not ASCII. To
get to the respective content of job ID 123, you need to run

  testipp /var/spool/cups/c00123

(however, testipp may not have been build and packaged by your
distro). Page counts are only present once a job has finished pro-
cessing and printed. They are in "job-media-sheets-completed"; byte
counts are in "job-k-octets".

When cupsd starts up, it evaluates the c* files and computes a count
of the completed pages for each user. While it runs, it keeps that
count up to date (and allows one job to cross the limit and complete,
even if that one job is 1000 pages!)

> The "pagelog" file stores some accounting information (including 
> number of copies and pages for each job).

Yes.

It lists, per line each printed each printed pagenumber, copies,
job-originating-host-name, date+time, page-label, user, job-id
(not in that order).

You need your own or a third party script that evaluates this file.
See

  http://savannah.nongnu.org/projects/printanalyze/

for one working example

> 1. Does CUPS total this information every time for each user before 
> enforcing page count quotas? 

Yes.

If no limit is reached yet, it prints *all* the job, however big it
is.

> It seems to be natural to assume that 
> the "totalled" information would be stored seperately?

Yes; but it doesn't do so in a *file*, only in an internal cache while
it runs.

> 2. Also, where does it store kB information per user in order to 
> enforce kB quotas?

Same as with pages.

For each page as it is printed it stores a line in the page_log.

For each job it stores all IPP attributes in the c* file in the
spool directory (but that file is not human-readable without the
help of the "testipp" utility).

> Any help would be appreciated! Thanks!

If you need more sophistication for your print accounting, you'll have
to go for PyKota:

   http://www.pykota.com/software/pykota/features

which stores everything in a database (SQlite, LDAP, Postgres or MySQL)
and can do all you may ever conceive and more.

-- 
Kurt Pfeifle
System & Network Printing Consultant ---- Linux/Unix/Windows/Samba/CUPS
Infotec Deutschland GmbH  .....................  Hedelfinger Strasse 58
A RICOH Company  ...........................  D-70327 Stuttgart/Germany




More information about the cups mailing list