[cups] CUPS basic accounting [solved]
sawbona at xsmail.com
sawbona at xsmail.com
Sat Mar 21 08:05:05 PDT 2020
On 20 Mar 2020 at 19:13, Helge Blischke wrote:
> ... suggest to use a Perl or Python script ...
I've been able to configure the CUPS output to the
/var/log/cups/page_log file.
Took me a good while to find out what syntax to apply to the
/etc/cups/cupsd.conf file and with some testing figured it out.
[code]
groucho at devuan:/etc/cups$ cat cupsd.conf
LogLevel warn
MaxLogSize 1m
--- snip ---
# -----
# added by groucho 20200321 for page_log file format
# see https://eltallerdelbit.com/cups-linux/
# -----
# default values
# %p printer name -> not needed here
# %u user name
# %j job ID
# %T date time (change to reduced format somewhere else?)
# %P current page number
# %C number of copies for current page
# %{job-billing} -> not needed here
# %{job-originating-host-name}
# %{job-name}
# %{media} not needed here
# %{sides} not needed here
# %{job-impressions-completed} number of pages (sides) printed -> not
needed here
# %{job-media-sheets-completed} number of sheets printed.
# -----
PageLogFormat %u %j %T %P %C %{job-originating-host-name} %{job-name}
# -----
--- snip ---
[/code]
I have left my comments as a guide in case anyone else comes across
this issue.
The above configuration puts out this in the page_log file:
[code]
groucho at devuan:~$ cat /var/log/cups/page_log
--- snip ---
groucho 287 [21/Mar/2020:11:55:06 -0300] 1 1 localhost
z:\home\groucho\Desktop\vie_2802s.jpg
--- snip ---
groucho at devuan:~$
[/code]
And this awk stanza ...
[code]
awk '/groucho/{pages += $6} END {print pages}' /var/log/cups/page_log
[/code]
... run against it will tally the number of pages printed.
Thanks to all that pitched in.
Cheers,
G.
More information about the cups
mailing list