1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
4 | <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> |
---|
5 | <TITLE> LPRng-HOWTO: Accounting</TITLE> |
---|
6 | <LINK HREF="LPRng-HOWTO-16.html" REL=next> |
---|
7 | <LINK HREF="LPRng-HOWTO-14.html" REL=previous> |
---|
8 | <LINK HREF="LPRng-HOWTO.html#toc15" REL=contents> |
---|
9 | </HEAD> |
---|
10 | <BODY> |
---|
11 | <A HREF="LPRng-HOWTO-16.html">Next</A> |
---|
12 | <A HREF="LPRng-HOWTO-14.html">Previous</A> |
---|
13 | <A HREF="LPRng-HOWTO.html#toc15">Contents</A> |
---|
14 | <HR> |
---|
15 | <H2><A NAME="accountingref"></A> <A NAME="s15">15. Accounting</A></H2> |
---|
16 | |
---|
17 | <P>The LPRng method for doing accounting is based on experiences in a |
---|
18 | Academic environment, where avoiding printing accounting procedures |
---|
19 | has long been practiced. While the LPRng procedures are not bombproof, |
---|
20 | they do provide a wide range of facilities, with various degrees |
---|
21 | of trust built into them. |
---|
22 | <H2><A NAME="ss15.1">15.1 Printer Accounting Reality Check</A> |
---|
23 | </H2> |
---|
24 | |
---|
25 | <P>The following was written |
---|
26 | by Patrick Powell |
---|
27 | <CODE><papowell@astart.com></CODE> |
---|
28 | in response to the expressions of frustration |
---|
29 | that are periodically vented in the |
---|
30 | <CODE> |
---|
31 | <A HREF="LPRng-HOWTO-1.html#maillist">lprng@lprng.org</A></CODE> |
---|
32 | mailing list. |
---|
33 | While this addresses the use of a particular set of printer filters, |
---|
34 | i.e. - the |
---|
35 | <A HREF="LPRng-HOWTO-13.html#ifhp">ifhp</A> |
---|
36 | set, |
---|
37 | the comments are appropriate to other issues. |
---|
38 | <P>In Academic institutions, avoiding printing accounting has been |
---|
39 | regarded as a challenge, an ongoing game of fat cat and poor starving |
---|
40 | mouse, between the Administration and the downtrodden, poor, over charged |
---|
41 | student. The following is a lighthearted ramble down the dark lane of |
---|
42 | printing accounting. |
---|
43 | <P>We will disregard the fact that if most students put as much effort |
---|
44 | into their studies as in finding ways to avoid accounting procedures |
---|
45 | then they would be Rhodes Scholar material, but I digress... |
---|
46 | <P>The accounting procedures put into the LPRng and the hpif filters may |
---|
47 | appear to be extraordinarily complex, but believe me, they are not. |
---|
48 | Firstly, we make the assumption that the printer has some sort of |
---|
49 | non-volatile page counter mechanism that is reliable and impervious to |
---|
50 | power on/off cycles. Without this mechanism the enterprising student |
---|
51 | ummm... user will simply turn off the printer. Software that prescans |
---|
52 | jobs for line counts and pages is notoriously unreliable, given even |
---|
53 | the most modest efforts of users to hide these procedures. The cost |
---|
54 | of running a PostScript simulator simply to do accounting has its |
---|
55 | flaws; without ensuring that the simulator has all of the interesting |
---|
56 | security loopholes closed, such as opening files, etc., it can become |
---|
57 | a trap door to hell for the system administrator. |
---|
58 | <P>Secondly, we must make the assumption that the student... uhhh... |
---|
59 | user will not be able to tinker with the page counter mechanism, i.e.- |
---|
60 | they will not be able to roll back the odometer on the printer, FOR THE |
---|
61 | DURATION OF A SINGLE JOB. I will digress and point out that a student |
---|
62 | actually did this for a challenge; it only took him a couple of weeks |
---|
63 | of study and a fully equipped microcontroller lab, and two (2) laser |
---|
64 | printers which he ruined in the experiment. HP was not amused when we |
---|
65 | sent them back under warranty, claiming that this our 'normal lab usage.' |
---|
66 | <P>Lastly, you should not mind a small amount of pilferage, or a few |
---|
67 | pages here and there being charged to the wrong account. |
---|
68 | <P><B>How Does It Work?</B> |
---|
69 | <P>The <CODE>ifhp</CODE> filter records the page |
---|
70 | counter value at the start and end of each part of a print job. Each |
---|
71 | record has the form: |
---|
72 | <BLOCKQUOTE><CODE> |
---|
73 | <PRE> |
---|
74 | start -ppagecounter -Ff -kjob -uuser -hhost -R... |
---|
75 | end -ppages -qpagecounter -Ff -kjob -uuser -hhost -R... |
---|
76 | </PRE> |
---|
77 | </CODE></BLOCKQUOTE> |
---|
78 | <P>When we use the OF filter and/or banners, we will see the |
---|
79 | individual jobs bracketed by the OF filter records: |
---|
80 | <BLOCKQUOTE><CODE> |
---|
81 | <PRE> |
---|
82 | start -p100 -Fo -kcfA100taco -uuser -hhost -R... |
---|
83 | start -p101 -Ff -kcfA100taco -uuser -hhost -R... |
---|
84 | end -p1 -q102 -Ff -kcfA100taco -uuser -hhost -R... |
---|
85 | start -p102 -Ff -kcfA100taco -uuser -hhost -R... |
---|
86 | end -p3 -q105 -Ff -kcfA100taco -uuser -hhost -R... |
---|
87 | end -p5 -q105 -Fo -kcfA100taco -uuser -hhost -R... |
---|
88 | </PRE> |
---|
89 | </CODE></BLOCKQUOTE> |
---|
90 | <P>It should be clear from the above that all we need to do is to add up |
---|
91 | the values for the -Fo (OF) filter lines and we are done. |
---|
92 | <P>Unfortunately, this is too simplistic. If for some reason the job is |
---|
93 | killed or terminates due to error conditions, the OF filter may not |
---|
94 | get to finish its work. Thus, we may see the following: |
---|
95 | <BLOCKQUOTE><CODE> |
---|
96 | <PRE> |
---|
97 | start -p100 -Fo -kcfA100taco -uuser -hhost -R... |
---|
98 | start -p101 -Ff -kcfA100taco -uuser -hhost -R... |
---|
99 | start -p110 -Fo -kcfA101taco -uuser -hhost -R... |
---|
100 | </PRE> |
---|
101 | </CODE></BLOCKQUOTE> |
---|
102 | <P>This is a clear indication that the user's job has been terminated. In |
---|
103 | this case we need to use the differences between pagecounters of the start |
---|
104 | records to do accounting. |
---|
105 | <P>There is a caveat to all of this; that is the problem of the last dead |
---|
106 | job in the list. If the last line in the accounting file is: |
---|
107 | <BLOCKQUOTE><CODE> |
---|
108 | <PRE> |
---|
109 | start -p110 -Fo -kcfA101taco -uuser -hhost -R... |
---|
110 | </PRE> |
---|
111 | </CODE></BLOCKQUOTE> |
---|
112 | |
---|
113 | is the last job finished or did it abort? |
---|
114 | <P><B>Who Used Up 2000 Pages of Paper Today?</B> |
---|
115 | <P>Now we move on to the problem of real time accounting. Due to limited |
---|
116 | budgets, etc., many institutions would like to strictly enforce limits |
---|
117 | on paper use by students. As jobs are printed their accounts should be |
---|
118 | docked for the amount of paper use. One way to do this is to have an |
---|
119 | external accounting procedure update a shared database. The <CODE>ifhp</CODE> filter |
---|
120 | has provision for a shell script to be called at the end of print job; |
---|
121 | this is done by both the OF and IF filter. Thus, we can blithely |
---|
122 | assume that there is a central database carefully getting updates |
---|
123 | from the LPRng software, probably from dozens of different printers, |
---|
124 | and updating the accounting information. |
---|
125 | <P>The first question to be asked is simple: is this worth it? |
---|
126 | Perhaps doing accounting as a batch job once an hour/four times |
---|
127 | a day/once a day is cheaper than building an running such a database. |
---|
128 | If it costs $5K/year for the database software, you might just consider |
---|
129 | ignoring the 10,000 pages that get lost in the shuffle and use |
---|
130 | a simple set of awk/sed/perl scripts to update a database once |
---|
131 | an hour. |
---|
132 | <P><B>BAD JOBS - Who Do We Bill?</B> |
---|
133 | <P>We inevitably run into an interesting question: |
---|
134 | what happens if a job does not complete correctly? |
---|
135 | <P>If you use the completion of the OF filter as a success status, I have |
---|
136 | to point out that many students... ummm... users soon find ways to send |
---|
137 | jobs to the printer that will cause it to lock up after their output |
---|
138 | has been printed. These jobs require power cycling of the printer and |
---|
139 | restarting the filter; a bit extreme, perhaps, but it has happened. |
---|
140 | <P>I suggest that you simply adopt a 'bill to last user of record' |
---|
141 | attitude, using the pagecount information as follows: |
---|
142 | <BLOCKQUOTE><CODE> |
---|
143 | <PRE> |
---|
144 | start OF -- starting point for THIS job |
---|
145 | start IF -- nice information, but not useful |
---|
146 | start IF -- |
---|
147 | end OF -- ending point for this job - can record information |
---|
148 | start OF -- |
---|
149 | if no end OF for previous job, then treat as end OF and |
---|
150 | update accounting. |
---|
151 | </PRE> |
---|
152 | </CODE></BLOCKQUOTE> |
---|
153 | <P>Now somebody is sure to complain that they got charged for a bunch of |
---|
154 | pages that they did not use. This is inevitable; always carry a |
---|
155 | can of oil for the squeaky wheels. I might make the observation that |
---|
156 | once is accident, twice is coincidence, but three times is malice; |
---|
157 | be wary of the constant complainer and check out not only him or her but |
---|
158 | also their co-workers. |
---|
159 | <P><B>How Do We Update the Database?</B> |
---|
160 | <P>I suggest that database update be done as follows: |
---|
161 | <P>You maintain a 'last page reported' counter for each printer in the |
---|
162 | database. When a successful job reports in, check to see that<BR> |
---|
163 | pagecount + joblength == newpagecount; |
---|
164 | <P>If this is not the case, then you have had a some unsuccessful jobs. |
---|
165 | In this case I strongly recommend that you have a means to request the |
---|
166 | accounting reporting program to go back through the accounting file and |
---|
167 | find the last report for the page counter value and try to backtrack |
---|
168 | through the accounting files. The accounting file is one of the first |
---|
169 | things to be attacked by students... Ummm... users. It should NOT be |
---|
170 | kept on an NFS exported or mounted file system. It should be |
---|
171 | carefully pruned and copied, perhaps on an hourly basis. |
---|
172 | <P>Now some administrators have fallen in love with network based printers; |
---|
173 | do not believe ANYTHING that comes over a network connection without |
---|
174 | some form of authentication; PGP has some very nice Public Key |
---|
175 | mechanisms for handling this. This is a major weakness in using a |
---|
176 | database for keeping track of accounting - a weak authentication |
---|
177 | mechanism may lead to denial of service attacks by students flooding |
---|
178 | the database with bogus print usage reports; suddenly NOBODY can print |
---|
179 | and the administrator is driven to turning off accounting. |
---|
180 | <P>Good luck. I am never surprised when I encounter yet another wrinkle in |
---|
181 | this area. |
---|
182 | <P>Patrick ("You call me a Bean Counter? Guido, break this kid's fingers<BR> |
---|
183 | with an adding machine!") Powell |
---|
184 | <H2><A NAME="ss15.2">15.2 How HP Printers Implement Page Counters</A> |
---|
185 | </H2> |
---|
186 | |
---|
187 | <P>The following is from |
---|
188 | <A HREF="http://www.hp.com/cposupport/printers/support_doc/bpl02119.html">http://www.hp.com/cposupport/printers/support_doc/bpl02119.html</A><P><B>HP LaserJet Printer Family - Page Count</B> |
---|
189 | <P>Description Of The Page Count Feature On HP LaserJet 4 Family |
---|
190 | Printers |
---|
191 | <P>All HP LaserJet 4/5/6 family printers have a page count feature |
---|
192 | built into the firmware. However, this feature works differently |
---|
193 | depending on which HP LaserJet printer is being used. The following |
---|
194 | is a description of how the page count feature works for each |
---|
195 | printer within the HP LaserJet 4/5/6 printer families. |
---|
196 | <BLOCKQUOTE><CODE> |
---|
197 | <PRE> |
---|
198 | HP LaserJet 4/4M printers |
---|
199 | HP LaserJet 4 Plus/4M Plus printers |
---|
200 | HP LaserJet 4P/4MP printers |
---|
201 | HP LaserJet 4Si/4Si MX printers |
---|
202 | HP LaserJet 4ML printers |
---|
203 | HP LaserJet 5P/5MP printers |
---|
204 | HP LaserJet 6P/6MP printers |
---|
205 | </PRE> |
---|
206 | </CODE></BLOCKQUOTE> |
---|
207 | <P>All of the above printers use the same method for keeping track of |
---|
208 | the number of copies. There are really two different page count |
---|
209 | values: Primary and Secondary values. Every time a page is printed, |
---|
210 | whether it is an internal job (such as a self-test) or a standard |
---|
211 | print job, the Secondary page count increases by one. This value |
---|
212 | is stored in standard RAM. Once the Secondary page count value |
---|
213 | reaches 10, the Primary page count will increase by 10. The Primary |
---|
214 | page count value is stored in a type of memory called NVRAM |
---|
215 | (Non-Volatile RAM). This is important, since NVRAM is not cleared |
---|
216 | when the printer is powered off. Standard RAM, on the other hand, |
---|
217 | is cleared when the printer is turned off or reset. Thus, the |
---|
218 | Primary page count only increases in increments of 10. |
---|
219 | <P>Example |
---|
220 | <P>You have a brand new HP LaserJet 6P printer and you print a self-test |
---|
221 | page. When you look on the test page for the Page Count value, you |
---|
222 | will see that it says 1. Next, you decide to print a two page letter |
---|
223 | and, after that, another self-test. The page count value now says |
---|
224 | 4. Internally, the printers Secondary page count (stored in RAM) |
---|
225 | has the value of 4 while the Primary page count (stored in NVRAM) |
---|
226 | still has the value of 0. Now, you turn the printer off, then back |
---|
227 | on, and print another self-test. The page count value again says |
---|
228 | 1 since the previous value of 4, stored in RAM, was cleared when |
---|
229 | the printer was powered off. Finally, print a ten page document |
---|
230 | and then turn the printer off. Upon turning the printer back on |
---|
231 | and printing out another self test, you see that the page count |
---|
232 | value is 11. Internally, the Secondary page count value is back |
---|
233 | at 1 while the Primary page count value (stored in NVRAM) is 10. |
---|
234 | Added together, you end up with the resulting value seen on the |
---|
235 | self-test page. |
---|
236 | <P>HP LaserJet 4L/5L/6L Printers |
---|
237 | <P>The reason that the page count method for the HP LaserJet 4L/5L/6L |
---|
238 | printers differ from that of the other printers is that the HP |
---|
239 | LaserJet 4L/5L/6L printers do not have any NVRAM available. Thus, |
---|
240 | no way exists for the printer to retain a page count value once |
---|
241 | the printer is powered off. The HP LaserJet 4L/5L/6L printers have |
---|
242 | only a single page count value that increases in increments of one |
---|
243 | until the printer is powered off. At that point, the page count |
---|
244 | value is reset and begins from 0 once again. |
---|
245 | <P> |
---|
246 | <H2><A NAME="accountingserver"></A> <A NAME="ss15.3">15.3 Accounting Printcap Options</A> |
---|
247 | </H2> |
---|
248 | |
---|
249 | <P>The accounting facilities are controlled and enabled by the following |
---|
250 | entries in the printcap file. The default value is indicated. |
---|
251 | <P> |
---|
252 | <CENTER><TABLE BORDER><TR><TD> |
---|
253 | <BR> |
---|
254 | Tag</TD><TD>Default Value</TD><TD>Purpose</TD></TR><TR><TD> |
---|
255 | af</TD><TD>NULL</TD><TD>accounting file name</TD></TR><TR><TD> |
---|
256 | as</TD><TD>"jobstart $H $n $P $k $b $t"</TD><TD>accounting info for job start</TD></TR><TR><TD> |
---|
257 | ae</TD><TD>"jobend $H $n $P $k $b $t"</TD><TD>accounting info for job end</TD></TR><TR><TD> |
---|
258 | accounting_server</TD><TD>NULL</TD></TR><TR><TD> |
---|
259 | achk</TD><TD>FALSE</TD></TR><TR><TD> |
---|
260 | la</TD><TD>TRUE</TD><TD>do accounting for 'local' printer</TD></TR><TR><TD> |
---|
261 | ar</TD><TD>FALSE</TD><TD>do accounting for 'remote' transfers</TD></TR><TR><TD> |
---|
262 | |
---|
263 | </TD></TR></TABLE></CENTER> |
---|
264 | <P> |
---|
265 | <H2><A NAME="ss15.4">15.4 Accounting File</A> |
---|
266 | </H2> |
---|
267 | |
---|
268 | <P>The most common method of accounting is to record the start and end |
---|
269 | times of a job and its size to the accounting file. A typical entry |
---|
270 | for the printcap defaults are shown below. |
---|
271 | <BLOCKQUOTE><CODE> |
---|
272 | <PRE> |
---|
273 | jobstart '-Htaco.astart.com' '-nroot' '-Pps' '-kcfA938taco.astart.com' \ |
---|
274 | '-b1093' '-tNov 5 19:39:59' |
---|
275 | start '-p12942' '-kcfA938taco.astart.com' '-nroot' '-htaco.astart.com' '-Pps' \ |
---|
276 | '-c0' '-Fo' '-tSun Nov 5 19:39:25 1995' |
---|
277 | start '-p12944' '-kcfA938taco.astart.com' '-nroot' '-htaco.astart.com' '-Pps' \ |
---|
278 | '-c0' '-Ff' '-tSun Nov 5 19:39:27 1995' |
---|
279 | end '-p12944' '-kcfA938taco.astart.com' '-nroot' '-htaco.astart.com' '-Pps' \ |
---|
280 | '-b3' '-c0' '-Ff' '-tSun Nov 5 19:39:58 1995' |
---|
281 | end '-p12942' '-kcfA938taco.astart.com' '-nroot' '-htaco.astart.com' '-Pps' \ |
---|
282 | '-b2' '-c0' '-Fo' '-tSun Nov 5 19:39:59 1995' |
---|
283 | jobend '-Htaco.astart.com' '-nroot' '-Pps' '-kcfA938taco.astart.com' \ |
---|
284 | '-b1093' '-tNov 5 19:39:59' |
---|
285 | </PRE> |
---|
286 | </CODE></BLOCKQUOTE> |
---|
287 | <P>The <CODE>jobstart</CODE> and <CODE>jobend</CODE> lines are added by the LPD server, as |
---|
288 | specified by the <CODE>as</CODE> and <CODE>ae</CODE> printcap options; |
---|
289 | the -b (byte count) indicates the numbers of bytes in the job. |
---|
290 | <P>The <CODE>start</CODE> and <CODE>end</CODE> |
---|
291 | lines are produced by the filters; |
---|
292 | the of filter has an -Fo, and the if filter a -Ff entry. |
---|
293 | The filters in the LPRng distribution produce the |
---|
294 | indicated output format by default. |
---|
295 | The -p value is the current value of a page counter device (if any), |
---|
296 | and the -b value indicates the total number of pages used. |
---|
297 | <P>It should be clear that a simple AWK or Perl script will be able to |
---|
298 | process an accounting file and update accounting information for |
---|
299 | accounting purposes; the usual problems with truncation, time stamps, |
---|
300 | etc., are left as an exercise for the system administrator. |
---|
301 | However, |
---|
302 | for those who are exercise challenged, |
---|
303 | the LPRng distribution |
---|
304 | <CODE>.../LPRng/UTILS/accounting.pl</CODE> |
---|
305 | file is a template that can be used to process the accounting information. |
---|
306 | The printcap for using this file should resemble: |
---|
307 | <BLOCKQUOTE><CODE> |
---|
308 | <PRE> |
---|
309 | pr: |
---|
310 | :as=|/.../accounting.pl START |
---|
311 | :ae=|/.../accounting.pl END |
---|
312 | :if=/.../ifhp |
---|
313 | :of=/.../ofhp |
---|
314 | # set this to the printing device |
---|
315 | :lp=prdevice |
---|
316 | :sd=/.../%P |
---|
317 | </PRE> |
---|
318 | </CODE></BLOCKQUOTE> |
---|
319 | <P>Note that the accounting file must exist and will not be created by the |
---|
320 | <CODE>lpd</CODE> server. |
---|
321 | The accounting file should be periodically truncated. |
---|
322 | <H2><A NAME="ss15.5">15.5 Accounting Using an Accounting Server</A> |
---|
323 | </H2> |
---|
324 | |
---|
325 | <P>To accommodate even more aggressive and centralized accounting, |
---|
326 | a method to make a connection to a print server and send information |
---|
327 | to the server has been provided as well. |
---|
328 | If <CODE>achk</CODE> option is set, |
---|
329 | it is assumed that the <CODE>af</CODE> entry specifies a connection to |
---|
330 | server on a remote host. |
---|
331 | The <CODE>lpd</CODE> server will send the <CODE>as</CODE> string to the server, |
---|
332 | and then wait for a single line of text from the remote server. |
---|
333 | If the first word on the return line is |
---|
334 | <CODE>accept</CODE> or <CODE>hold</CODE>, |
---|
335 | the job will be either accepted for printing or held. |
---|
336 | Any other value will cause the job to be deleted. |
---|
337 | <P>At the end of the job the <CODE>ae</CODE> string will be sent to the server. |
---|
338 | No response is expected. Example: |
---|
339 | <P> |
---|
340 | <BLOCKQUOTE><CODE> |
---|
341 | <PRE> |
---|
342 | :af=accounting.site.com%2300,tcp |
---|
343 | :achk |
---|
344 | :as=starting |
---|
345 | :ae=ending |
---|
346 | </PRE> |
---|
347 | </CODE></BLOCKQUOTE> |
---|
348 | <P>The port that the connection originates from will be in the range |
---|
349 | set by the configuration or printcap |
---|
350 | <CODE> |
---|
351 | <A HREF="LPRng-HOWTO-18.html#originateport">originate_port</A></CODE> |
---|
352 | option. |
---|
353 | <H2><A NAME="ss15.6">15.6 Using Filters For Accounting</A> |
---|
354 | </H2> |
---|
355 | |
---|
356 | <P>Some sites have expressed interest in using a central accounting |
---|
357 | mechanism to check that users have permissions. This can be done by |
---|
358 | using the an alternative form of the as (accounting start) and ae |
---|
359 | (accounting end) printcap tags. If the as and ae are filter |
---|
360 | specifications, then a filter is invoked. If the as (accounting |
---|
361 | start) filter returns a non-zero exit status, then its value |
---|
362 | is used to handle the job as indicated by |
---|
363 | the |
---|
364 | <A HREF="LPRng-HOWTO-12.html#termination">Abnormal Termination</A> |
---|
365 | codes for filters. |
---|
366 | At the end of the job the :ae: filter will be invoked in a similar manner, |
---|
367 | but its exit status is ignored. |
---|
368 | <P>When using an accounting filter, |
---|
369 | the STDIN is attached (read/write) to the accounting file or remote host |
---|
370 | specified by the <CODE>af</CODE> printcap option, |
---|
371 | STDOUT to the output device, |
---|
372 | and STDERR to the status file. |
---|
373 | The filter program would be invoked with the default filter options. |
---|
374 | <P>For example, here is a sample entry to check and update accounting |
---|
375 | <BLOCKQUOTE><CODE> |
---|
376 | <PRE> |
---|
377 | printer |
---|
378 | :as=|/usr/local/libexec/filters/accounting.pl start |
---|
379 | :ae=|/usr/local/libexec/filters/accounting.pl end |
---|
380 | </PRE> |
---|
381 | </CODE></BLOCKQUOTE> |
---|
382 | <H2><A NAME="ss15.7">15.7 Accounting Utility accounting.pl</A> |
---|
383 | </H2> |
---|
384 | |
---|
385 | <P>In order to provide a framework for doing using the outlined accounting |
---|
386 | methods, the LPRng distribution |
---|
387 | <CODE>UTILS</CODE> directory has a <CODE>accounting.pl</CODE> script. |
---|
388 | This script does the following. |
---|
389 | <OL> |
---|
390 | <LI>It is assumed that the accounting filter is invoked with the |
---|
391 | following printcap entry. |
---|
392 | The start and end is used by the filter to determine at which point in |
---|
393 | the accounting process it is invoked. |
---|
394 | <BLOCKQUOTE><CODE> |
---|
395 | <PRE> |
---|
396 | printer |
---|
397 | :as=|/usr/local/libexec/filters/accounting.pl start |
---|
398 | :ae=|/usr/local/libexec/filters/accounting.pl end |
---|
399 | </PRE> |
---|
400 | </CODE></BLOCKQUOTE> |
---|
401 | </LI> |
---|
402 | <LI>It maintains the accounting file as a set of entries in the following format: |
---|
403 | <BLOCKQUOTE><CODE> |
---|
404 | <PRE> |
---|
405 | START [job identification] |
---|
406 | start -pnn ... |
---|
407 | ... |
---|
408 | end -pnn+pagecount ... |
---|
409 | END -ppagecount [job identification] |
---|
410 | </PRE> |
---|
411 | </CODE></BLOCKQUOTE> |
---|
412 | </LI> |
---|
413 | <LI>Each time the filter is invoked with the <CODE>start</CODE> |
---|
414 | tags, |
---|
415 | it will add a <CODE>START</CODE> record to the end of the accounting file.</LI> |
---|
416 | <LI>When it is invoked with the <CODE>end</CODE> option, |
---|
417 | it will update the accounting file and add an <CODE>END</CODE> entry.</LI> |
---|
418 | <LI>It will handle aborted jobs by looking for jobs with have a <CODE>START</CODE> |
---|
419 | entry and a following <CODE>start</CODE> line and assuming that they |
---|
420 | progressed to the point of starting print operations, |
---|
421 | i.e. - the printer page counter was accessed and reported. |
---|
422 | It will then look for the next <CODE>START</CODE> entry with a |
---|
423 | following <CODE>start</CODE> line, |
---|
424 | and assume that the pages between the two points were used by the |
---|
425 | aborted job.</LI> |
---|
426 | </OL> |
---|
427 | <P>Administrators can use this script as a starting point for more advanced |
---|
428 | accounting. |
---|
429 | For example, |
---|
430 | rather than just recording the information, |
---|
431 | at the job start the script can query either a local database |
---|
432 | or a remote server to see if the user has permissions to access the printer. |
---|
433 | At the end of the job or when an <CODE>END</CODE> line is written to the |
---|
434 | accounting file, |
---|
435 | the local database or remote accounting server can be updated. |
---|
436 | <HR> |
---|
437 | <A HREF="LPRng-HOWTO-16.html">Next</A> |
---|
438 | <A HREF="LPRng-HOWTO-14.html">Previous</A> |
---|
439 | <A HREF="LPRng-HOWTO.html#toc15">Contents</A> |
---|
440 | </BODY> |
---|
441 | </HTML> |
---|