SDB:Printer Accounting
情况
您希望获取统计信息,了解哪些用户在哪些打印机上打印了多少内容。
本文适用于 Linux 下 CUPS 版本高达 2.x,以及那里的传统过滤系统和后端。
如今的无驱动程序打印工作流程则大不相同。
流程
默认情况下,CUPS 提供软件配额和软件页面记录,请参阅 http://www.cups.org/documentation.php/doc-1.3/accounting.html,其中说明
Page logging is only available for drivers that provide page accounting information, typically all PostScript and CUPS raster devices. Raw queues and queues using third-party solutions... do not have useful page accounting information available.
CUPS 软件页面记录将其尽力而为/最佳猜测的结果存储在 /var/log/cups/page_log 中 - 有关其文件格式,请参阅 http://www.cups.org/documentation.php/doc-1.3/ref-page_log.html,对于 CUPS 1.4(即自 openSUSE 11.3 以来)请参阅 http://www.cups.org/documentation.php/doc-1.4/ref-page_log.html
但是软件记账并不能真正可靠。例如,请参阅 http://otrs.librelogiciel.com/otrs/public.pl?Action=&ID=24,其中说明
Symptom: You use software accounting but the number of pages ... is incorrect. Problem: This is probably because the Page Description Language generated by your printer driver is not recognized... This often happens with custom made drivers...
特别是通过类似以下方式以“原始”模式打印
cat printer_specific_data | lp -d queue_name -o raw
任何用户都可以绕过所有 CUPS 过滤,因此在“原始”模式下打印时,任何软件记账程序都无法运行。
因此,对于“打印页数的真实计数”(这实际上意味着什么,请参见下文),需要硬件记账,而这 - 只要我知道() - 通常只能通过 SNMP 实现,用于维护内部可靠工作页面计数器的商业网络打印机。
关于“可靠工作的页面计数器”实际可能意味着什么,请参阅 cups.general 论坛中的“socket backend pagecounting off by one”邮件主题:http://www.cups.org/newsgroups.php?gcups.general+T+Q%22socket+backend+pagecounting+off+by+one%22,其中一位 CUPS 用户报告
I've done some little tests of the SNMP page counting in the 1.4.4 socket backend ... see CUPS 1.4.4 socket.c ... when printing N pages, N - 1 pages are ... recorded. I think that the reason is that ... printers take some time for the page count to stabilise. If I do place an experimental 'sleep(10)' ... in socket.c, the page count is correct. Naturally, I wouldn't want to add a useless delay in the socket backend, but some of us do want reliable, actual, per-job page counts. I've found that even when these printers report themselves idle ... the page count is still not stable.
简而言之:一些打印机在打印作业完成后需要几秒钟才能使它们的内部页面计数器稳定到正确的值。
但是,“页数”并不等同于“纸张张数”,因此在双面打印模式下,页数是纸张张数的两倍。例如,请参阅 http://otrs.librelogiciel.com/otrs/public.pl?Action=&ID=32,其中说明
Symptom: Hardware accounting seems to be incorrect when you print in Duplex mode. Problem: The printers' internal page counters doesn't really count the sheets of paper, nor their sides, but instead the number of times a particular sheet passes through the paper path. This means that if you print an odd number of pages in Duplex mode, the last sheet will be counted as 2 pages anyway, despite the last page being blank.
此外,即使是内部可靠工作的页面计数器也会计算所有页面或所有纸张张数(具体取决于特定打印机的页面计数器实现方式),而不会计算“只有上面有墨水的页面”。例如,请参阅 http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1299582054834+28353475&threadId=347346,其中说明
The printer does indeed count a duplex page as 2 even if there is not any printing on it. This is due to the fact that all of the rollers still have to spin and this cuases wear on the consumables. In theory you can actually wear out your toner cartridges/drums etc by simply running enough blank pages through the units. Granted, the page count would greatly exceed the published life expectations but its possible. Unfortuantely, there is no counter to differentiate between toner on the page or not.
有关更多详细信息,您可以查看 http://www.pykota.com/
请注意,PyKota 可能需要许多其他软件才能使其按您希望的方式工作。通常,openSUSE 不提供所有这些其他软件的软件包,因此您可能会遇到一些关于打印机设置的新问题:“设置可靠工作的打印机记账解决方案”。
在大多数情况下,默认的 CUPS 软件记账应该足以至少获得关于通常的 Linux 用户在哪些打印机上打印了多少内容的合理概述(不包括知道如何制作特定于打印机的数据并以“原始”模式打印的专家)。
相反,当有用户从 Windows 打印到您的 Linux 打印服务器时,默认的 CUPS 软件记账实际上没有用。从 Windows 打印到 Linux 的常用方法是在 Windows 客户端机器上运行 Windows 打印机驱动程序。驱动程序生成特定于打印机的数据,然后在 Linux 打印服务器上以“原始”模式打印。在这种情况下,默认的 CUPS 软件记账无法计算页面数。对于每个“原始”打印作业,/var/log/cups/page_log 中可能没有条目,或者最多只有一个条目,但页面计数值可能只是一个虚拟值“1”,无论实际打印了多少页。