page count is off when printing from samba to cups

Ted Fiedler tfiedler at awiweb.com
Wed Aug 17 06:00:19 PDT 2005


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;

}




More information about the cups mailing list