I was just sending this out in case you were interested in how we did our
name:pagecount accounting. As you can see just a few simple lines after
#changes start here
Again this gives us a file for each spool in /var/spool/lpd that reads in
the format :
user:pagecount
# we now update the accounting information
($start_time) = /D=(\d+)/;
s/D=(\d+)/S=$1/;
$count = $end_counter - $start_counter;
$elapsed = $time - $start_time;
# you should put your make update record stuff here
s/^START/END 't=$elapsed' $count 's=$start_counter'
'q=$end_counter' 'D=$time'/;
$out = $_ . "\n" . $out;
$end_counter = $start_counter;
$time = $start_time;
# changes start here - MDL - 8/14/01
$phys_acct_dir = "/var/spool/lpd";
$phys_acct_file = $opt{P} . "acct";
if ($count >= 0) {
open(phys_acct_h, ">>$phys_acct_dir/$phys_acct_file");
print phys_acct_h (' ' x (4 - (length $count))) . $count .
".00 $opt{H}:$opt{n}\n";
close(phys_acct_h);
}
Thanks,
Phil
On Fri, 24 Aug 2001, User Papowell wrote:
> > From [EMAIL PROTECTED] Fri Aug 17 03:06:00 2001
> > Date: Fri, 17 Aug 2001 10:06:07 +0100
> > From: Ian Lee <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Re: LPRng: Accounting..fill in the WHATS THIS...
> >
> > Thanks for that.
> >
> > I'm writing a parser to print a summary of the accounting file in the
> > form:-
> > userName -> totalPagecount
> > as this is for page use monitering rather than full blown accounting
> > (next year I think!).
> > I'd like to be sure that I'm getting the right pagecount for the right
> > user (even after uncompleted jobs) & the example in the howto is
> > different from this.
> >
> > Here's a section of my file numbered for convenience.
> > I noticed in this small example that
> >
> > (line 1) START -> 'D=997869440' (odd looking date)
> >
> > is the same as
> >
> > (line 9) END -> 'S=997869440' (System 'name' stuff...)
> >
> > and the same for matching fields in lines 4 & 10.
> >
> > Do these fields START D= and END S= *always* match for a job? They
> > *appear* to in my file but that's only 53 lines long so far so I can't
> > be sure. The END -> p= 'pages (sides) used' count is correct for the
> > jobs in this example (I sent/cancelled them!).
> > Also, does anyone have a longer (1000+ lines) accounting file in the
> > same format that I can use for a more realistic test?
> > Regards
> > Ian
>
> The D value is the output (value?) of the unix 'time()' system call.
> i.e. long date = time((void *)0);
> printf( "D=%ld\n", date );
>
> -----------------------------------------------------------------------------
> YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
> The address you post from MUST be your subscription address
>
> If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
> or lprng-digest-requests) with the word 'help' in the body. For the impatient,
> to subscribe to a list with name LIST, send mail to [EMAIL PROTECTED]
> with: | example:
> subscribe LIST <mailaddr> | subscribe lprng-digest [EMAIL PROTECTED]
> unsubscribe LIST <mailaddr> | unsubscribe lprng [EMAIL PROTECTED]
>
> If you have major problems, send email to [EMAIL PROTECTED] with the word
> LPRNGLIST in the SUBJECT line.
> -----------------------------------------------------------------------------
>
-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body. For the impatient,
to subscribe to a list with name LIST, send mail to [EMAIL PROTECTED]
with: | example:
subscribe LIST <mailaddr> | subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr> | unsubscribe lprng [EMAIL PROTECTED]
If you have major problems, send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------