2020-01-18
CUPS's page log, its use of SNMP, and (probably) why CUPS PPDs turn that off
One of CUPS's (also) many features is that it can
(try to) log reports of how many pages got printed to what printer
by who; this is set by the PageLog
directive in cups-files.conf. We set this
in our CUPS configuration because it's a useful aid for debugging
and broadly tracking usage, probably as do many people who run CUPS
as a central print server. I've recently been exploring some of the
things involved in this logging, due to discovering that our CUPS
server wasn't reporting some print jobs to our page log in a pattern
that's not clear to us.
In order to generate the page log, CUPS generally needs to know how many total pages the printer had printed before the job and then after it. In the old days, CUPS had various arcane ways of extracting this information from printers, traditionally involving Postscript queries. In the modern world, it turns out that CUPS tries to get page usage information from the printer using SNMP queries (using SNMP MIBs that are apparently standard between printer companies, or at least standard enough); in CUPS terminology, this is querying printers for 'supply levels'. In theory this has some implications if you have firewalls between your printers and your print server and the firewalls might be blocking SNMP.
In practice, if you look at modern CUPS PPDs, you will find that a certain number of them have an interesting line in them:
*cupsSNMPSupplies: False
As covered in the documentation, this turns off making SNMP queries to find out supply information, including the page count.
As it turns out, there is probably a good reason for this setting, because how CUPS does SNMP queries appears to have a little issue in practice that makes them not work. What I've observed in testing is that CUPS doesn't poll the printer to make sure it's finished producing output before getting the 'after printout' SNMP page usage numbers. At least some printers will accept the print job well before they actually have finished producing all of the pages (or even any of them), and of course they haven't updated their 'total pages printed' count at that point. The practical effect is that CUPS makes two back to back SNMP queries, gets the same page count from both, and doesn't record anything to your page log.
(Discovering this made the mystery for some of our printers not why we didn't have page logs, but why we had them for some jobs under some circumstances. Clearly CUPS has some additional sources of page count information that are sometimes available and sometimes not.)
PS: I'm not sure this CUPS and printer behavior can be said to be either side's fault; it seems more like a case of mismatched assumptions. Presumably there are some printers where it does work and produces useful per-job page count information.