On Mon, 4 Jun 2001, Robert Fausey wrote:

 > Is there a way to create a system log file in addition to a log file for
 > each queue?  I have /var/local/LPRng/spool/lpd/%P/log but this is for each
 > queue, I would like one so I could monitor all the queues from one central
 > location.

You can include a lines similar to this for each of your printer types
in your printcap file:

        :ifhp=model=hp4050,of_options=pagecount waitend 
accounting=/auto/global/lprng/libexec/filters/acc.pl

where acc.pl is something like the attachment.  You'll need to
customize for your site.  (We have some strange reasons why we have
accounting info duplicating to two different files.)

-Dan

-- 
Daniel E. Singer, System Administrator
Dept. of Computer Science, Duke University, Durham NC 27708 USA
[EMAIL PROTECTED], www.cs.duke.edu/~des, (919)660-6577
#!/usr/local/bin/perl
#  @(#)  /auto/global/lprng/libexec/filters/SCCS/s.acc.pl  1.1  2001/02/02  13:21:23
#
# acc.pl, 11/2000, D.Singer
# derived from:
#
# Patrick Powell Sun Sep  3 11:23:22 PDT 1995
# LPRng
#= File:                                                                   =
#=   accounting.sh                                                         =
#=                                                                         =
#= Synopsis:                                                               = 
#This program is called at the completion of printing a job by the OF
#filter.  The accounting file will hold information about the
#completion of a job.  The accounting file will have the following
#format:
#
#start -qpid -kcontrolfile -nlogin -hhost -Pprinter \
#     -ppagecounter -Fformt -Ttime
#end  -bpages -qpid -kcontrolfile -nlogin -hhost -Pprinter \
#     -ppagecounter -Ffmt -Ttime
#
#The accounting program will be called with the following parameters
#
#program -bpages -qpid -kcontrolfile \
#       -nlogin -hhost -Pprinter -ppagecounter -Fformt '-Ttime' accoutingfile

#$file1 = "/var/spool/lprng/PRINTER_ACCOUNTING_LOG";
$file1 = "/var/spool/lpd/ACCT_LOG";
#$file2 = "/auto/global/lprng/log/acct_log";
$file2 = "/auto/global/lprng/log/acct_log";

$debugfile = "/auto/global/lprng/log/acct_log.debug";
$debug = 0;

$pages = "";
$pid = "";
$controlfile = "";
$login = "";
$host = "";
$printer = "";
$pagecounter = "";
$format = "";
$time = "";
$accountingfile = "";
$mode = "";
$zoption = "";

foreach ( @ARGV ) {
        if (($mode eq "") and (/^start$/ or /^end$/)) {
                $mode = $_;
        }
        elsif (/^-b/) {
                $pages = substr($_,2) if ($pages eq "");
        }
        elsif (/^-h/) {
                if ($host eq "") {
                        $host = substr($_,2);
                        $host =~ s/\.cs\.duke\.edu$//;
                }
        }
        elsif (/^-k/) {
                $controlfile = substr($_,2) if ($controlfile eq "");
        }
        elsif (/^-n/) {
                $login = substr($_,2) if ($login eq "");
        }
        elsif (/^-p/) {
                $pagecounter = substr($_,2) if ($pagecounter eq "");
        }
        elsif (/^-q/) {
                $pid = substr($_,2) if ($pid eq "");
        }
        elsif (/^-t/) {
                $time = substr($_,2) if ($time eq "");
        }
        elsif (/^-F/) {
                $format = substr($_,2) if ($format eq "");
        }
        elsif (/^-P/) {
                $printer = substr($_,2) if ($printer eq "");
        }
        elsif (/^-Z/) {
                $zoption = substr($_,2) if ($zoption eq "");
        }
        elsif (/^-/) {
        }
        else {
                $accountingfile = $_;
                #last;
        }
}

$line = 
"ifhp|$login|$pid|$host|$printer|$format|$zoption|$pagecounter|$pages|$time\n";

if ($mode eq "start") {
        exit 0;
}

if ($debug) {
        open FH, ">>$debugfile" or die "cannot open \"$debugfile\".";
        print FH "\n";
        foreach ( @ARGV ) {
                print FH "$_\n";
        }
        print FH "mode = $mode\n";
        print FH "accountingfile = $accountingfile\n";
        close FH;
        #exit 0;
}
#elsif ($mode eq "start") {
#       exit 0;
#}

if ($file1 ne "") {
        open FH, ">>$file1" or die "cannot open \"$file1\".";
        print FH $line;
        close FH;
}

if ($file2 ne "") {
        open FH, ">>$file2" or die "cannot open \"$file2\".";
        print FH $line;
        close FH;
}

exit 0;

Reply via email to