It works very good !
I was wondering some question but with the IFHP-howto and tests I finally find answers.
So one more time: Thank you very much for your help !!!
Paul
--From: "Jamie Jennings" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: LPRng: I'm lost with accounting... Date: Fri, 16 Jan 2004 14:06:11 -0330 (NST)
OK, well what I do is this:
Comment out the last three lines of the printcap entry. You don't need to worry about pagecounting or accounting in /etc/printcap.
Get rid of the '--start' and '--stop' arguments to your python script. Your script will instead need to determine this based on whether it is passed 'filestart' or 'fileend'.
In your ifhp.conf file, you need to specify your accounting script like this (there should already be a sample one commented out:
## accounting script accounting=/usr/local/quotaimp/quotaimp.py
Also, you need to adjust the following lines in ifhp.conf to have appropriate settings for your environment. These lines affect how pagecounting will be done. 'pagecount_poll_start' specifies how many times to check the page counter when a job starts. In my case, I have it check once (ie. just get the number). Then it continues polling the pagecounter at 15 second intervals ('pagecount_interval') until it gets 2 ('pagecount_poll_end') consecutive values that match. Again, adjust these values based on testing with your printers (ie. the speed of your printers and the amount of delay you want/need between jobs).
##pagecount_poll=5 pagecount_poll_end=2 pagecount_poll_start=1 pagecount_interval=15 pagecount_timeout=0
Assuming you are using the latest version of ifhp, all the other default settings should be fine.
When the print job starts, it will first query the printer for the pagecount and then it will call your filter with the 'filestart' line as arguments. Here you can check a users' 'quota'. If the print job is permitted, you exit normally and the print job will begin printing. Otherwise, you exit with an error (ie. return/exit 1) and the print job will be aborted.
Once the job is complete and the pagecounter value is matched twice, ifhp will again run your script, but this time with the 'fileend' line. You need to parse this line and get the pagecount (it's the first '-b' argument). Then you can do your billing.
This isn't foolproof, it can sometimes get fooled by paper jams, etc but at least the user is never over-billed. In my situation that's the main concern - a few lost pages every now and then is not a big deal with the volume of printing that I deal with.
If you need any more help, let me know. I use this technique with a accounting filter written in C, and a daemon backend which uses MySQL (also written in C). Users have account balances, printing exemptions, etc. which much be checked before a print job is allowed and then updated after a print job completes.
Good luck! Jamie
>
> Hi. Thank you for your reply.
>
> I already use ifhp but I didn't know it could help me with quota. (I read
> whole LPRng-Reference
> and some chapters of LPRng-Cookbook)
>
> So if you can tell me more about your solution, I would be very grateful !
>
> Here is my whole printcap entry if it could help:
> The last 2 commented ifhp lines are just tests I've done, but I didn't
> really understood what it is suppose to do... Maybe the answer is in
> :ifhp=pagecount
>
> lp:
> :sd=/var/spool/lpd/%P
> :force_localhost
> :lp=10.23.1.58%9100
> # :lp=/dev/null
> :ifhp=model=hp2200
> # :ifhp=pagecount=|/home/paul/p.py
> # :ifhp=pagecounter,status,dev=10.23.1.58%9100
> :filter=/usr/libexec/filters/ifhp
> :af=|/tmp/p.py
> :as=|/usr/local/quotaimp/quotaimp.py --start
> :ae=|/usr/local/quotaimp/quotaimp.py --stop
>
> Thank you for your help !
>
> Paul
_________________________________________________________________
Hotmail : un compte GRATUIT qui vous suit partout et tout le temps ! http://g.msn.fr/FR1000/9493
----------------------------------------------------------------------------- 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. -----------------------------------------------------------------------------
