page count is off when printing from samba to cups

Helge Blischke h.blischke at srz.de
Wed Aug 17 06:44:37 PDT 2005


Ted Fiedler wrote:
> 
> I am trying to do some simple page accounting, when printing from Linux or  HTTP printing I get an accurate page count using the script below or even when manually counting lines in the page log. When my suers print via samba all print jobs are seen as only one page. Is there any way around this? Is this a Cups issue or a Samba issue?
> 
> #!/usr/bin/perl
> # YRMODA
> # 050512 TF - changed while(<>) to while(<PAGELOG>)
> # 050517 TF - changed formatting of output (printf)
> # 050627 TF - Fixed number of pages output
> # 050817 TF - Added Job and Page totals foreach queue
> #
> use warnings;
> use strict;
> #use diagnostics;
> 
> my ( %q_u, $job, $page );
> 
> open PAGELOG, "< /var/log/cups/page_log" or
>     die "unable to open pagelog for read: $!\n";
> 
> while (<PAGELOG>)
> {
>     my( $queue, $user, $jobid, @rest ) = split;
>     defined $jobid or next;
> 
>     $q_u{$queue}{$user}{'jobids'}{$jobid}++;
>     $q_u{$queue}{$user}{'npages'}++;
> }
> 
> close PAGELOG;
> 
> for my $queue ( sort keys %q_u )
> {
>     print "\n[$queue]\n";
>     my $total_pages  = 0;
>     my $total_jobs   = 0;
>     my ( $job, $page );
>     for my $user ( sort keys %{ $q_u{$queue} } )
>     {
>         my $nj       = keys %{ $q_u{$queue}{$user}{'jobids'} };
>         my $np       =         $q_u{$queue}{$user}{'npages'};
> 
>         $job      = ( $nj > 1 ) ? "jobs"  : "job";
>         $page     = ( $np > 1 ) ? "pages" : "page";
>         $total_pages = $total_pages + $np;
>         $total_jobs  = $total_jobs  + $nj;
>         printf "%10s %3d %4s %3d %5s\n", $user, $nj, $job, $np, $page;
>     }
> 
>     # adjust verbage for readablity
>     $job      = ( $total_jobs  > 1 ) ? "jobs"  : "job";
>     $page     = ( $total_pages > 1 ) ? "pages" : "page";
> 
>     # Print Totals for each queue
>     my $t     = "Total";
>     printf "-----------------------------\n";
>     printf "%10s %3d %4s %3d %5s\n", $t, $total_jobs, $job, $total_pages, $page;
> 
> }

You may try out the following:

(1) if set, discard the "raw" from SAMBA's CUPS options.
(2) look into your mime.types file. If files starting with HP PJL commands are
    tagged as "application/vnd.cups-raw", add this definition to the spce of 
    application/Postscript to ensure that these jobs go through the pstops filter
    which generates the page log entries.
(3) if necessary, modify your Winxx printers from "optimize for speed" to "optimize for
    portability".

good luck

Helge

-- 
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de




More information about the cups mailing list