LPRng-HOWTO: 15 Oct 2001 (For LPRng-3.7.9)
Prev | Chapter 18. Accounting | Next

# 18.6. Reliable Accounting

In order to do reliable accounting, the printer must be queueried for the current value of the pagecounter at the start and end of jobs and this information stored in the accounting file. The ifhp filter can be configured to obtain the pagecounter values and to record them at the start and end of each part of a print job. We can use the `:of` filter to read the pagecounter value at the start and end of a job, and have the other file files record information as well. The `ifhp` filter will record the pagecounter information with the `-q` option. We need simply take the difference of the starting and ending pagecounter values to find the number of pages used by a job.

        start '-p100' '-q20001' '-Fo' '-kcfA100taco' '-uuser' '-hhost' '-R...
        filestart '-p101' '-q20001' '-Ff' '-kcfA100taco' '-uuser' '-hhost' '-R...
        fileend '-p1' '-q20002' '-Ff' '-kcfA100taco' '-uuser' '-hhost' '-R...
        filestart '-p102' '-q20002' '-Ff' '-kcfA100taco' '-uuser' '-hhost' '-R...
        fileend '-p3' '-q20005' '-Ff' '-kcfA100taco' '-uuser' '-hhost' '-R...
        end '-p5' '-q20005' '-Fo' '-kcfA100taco' '-uuser' '-hhost' '-R...

If for some reason the job is killed or terminates due to error conditions, the `:of` filter may not get to record the ending value for the job. This can lead to accounting files with the following entries:

        start '-p100' '-q20005' '-Fo' '-kcfA100taco' '-uuser' '-hhost' '-R...
        filestart '-p101' '-q20005' '-Ff' '-kcfA100taco' '-uuser' '-hhost' '-R...
        start '-p110' '-q20005' '-Fo' '-kcfA101taco' '-uuser' '-hhost' '-R...
        filestart '-p112' '-q20010' '-Fo' '-kcfA101taco' '-uuser' '-hhost' '-R...
        end '-p112' '-q20010' '-Fo' '-kcfA101taco' '-uuser' '-hhost' '-R...

The missing `end` is a clear indication that the user's job has been terminated. We simply use the pagecounter value determined at the start of the next job to find the numbers of pages used for this job.

Prev | Home | Next
Accessing Printer Hardware Pagecounters | Up | \LPRng accounting.pl Utility