1

I need to know each time a Mac print job is created/completed, plus some information about that job (what was printed, pages, copies, etc).

The best method I've come up with thus far is to use kqueue() on /var/spool/cups/ and then parse the c##### files as they're created, but I'm wondering if there's a better way.

Redwood
  • 66,744
  • 41
  • 126
  • 187

3 Answers3

1

I'd think about creating a filter that you can put into the CUPS pipeline that collects this information and stores it for you (say in a database). Then you can access the database to get the information using any standard database access mechanism. Basically the filter is just a command-line program that gets a number of parameters passed to it from CUPS and needs to read input on stdin and write it to stdout. You can find more information at http://www.cups.org/documentation.php/api-filter.html.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
  • I like this idea a lot. Any ideas on how I could tell when a job had been canceled using this route? – Redwood Sep 17 '09 at 22:14
  • I think that there are some methods to communicate with the backend. I haven't actually implemented a filter for CUPS, though I did work on some LPR filters back in the day. See the section on communicating with the backend. You'd have to be working with a backend that writes device status back to the filter, but I would think that most do so that page counting software can easily hook into it and do the right thing. – tvanfosson Sep 17 '09 at 23:14
1

Have you ever looked what the page_log file provides for you? There's a man page providing details about its format. Recent versions of CUPS will let you configure the amount of info logged in that file.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
0

Have you looked into the IPP subscription schemes supported by CUPS?

These could trigger a mailto: or an rss: notification upon certain print system events. The IPP operations related to this topic are:

  • Create-Job-Subscriptions, Create-Printer-Subscriptions, Create-Resource-Subscriptions, Create-System-Subscriptions

Details about this feature are in the CUPS Programming Manual:

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345