root / pykota / trunk / README @ 1575

Revision 1575, 17.8 kB (checked in by jalet, 20 years ago)

PCLXL support now works !

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# $Id$
2
3PyKota - Print Quota for CUPS and LPRng
4
5(c) 2003-2004 Jerome Alet <alet@librelogiciel.com>
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
20====================================================================
21
22   NOTE FOR LPRNG USERS :
23   
24     FROM MAY 21ST 2004 ON, AND UNTIL THIS NOTE IS REMOVED
25     FROM THIS FILE, PYKOTA CAN'T BE USED ANYMORE WITH LPRNG.
26     
27     SUPPORT FOR LPRNG SHOULD BE RE-ADDED SOON WHEN A HUGE REWRITE
28     OF SOME PARTS OF PYKOTA WILL HAVE TAKEN PLACE
29
30====================================================================
31
32READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE'
33
34====================================================================
35
36PyKota features :
37-----------------
38
39    Operating systems :
40   
41        - Any Unix-like system as print server.
42           
43        - Any operating system as client.
44           
45    Printing systems :
46   
47        - Supports both CUPS and LPRng as the printing system.
48       
49          NB : LPRng support is currently being rewritten, so
50          LPRng is actually not supported in latest CVS versions.
51           
52    Databases :
53   
54        - Supports PostgreSQL as the Quota Storage backend.
55          Complete database creation script in SQL is included.
56       
57        - Supports OpenLDAP as the Quota Storage backend.
58          Complete LDAP schema and sample empty tree are included.
59          Plugging PyKota into your existing LDAP infrastructure
60          is really easy thanks to PyKota's great configurability.
61           
62    Printers :       
63   
64        - Hardware or Software accounting methods are completely
65          configurable.
66         
67        - Supports any printer which can report its internal
68          page counter. Can ask printers for their internal
69          page counter via SNMP, Netatalk, PJL, PS, or any
70          other way.
71          This is completely configurable.
72         
73        - Supports DSC compliant PostScript, PDF, PCL5 and
74          PCLXL (aka PCL6) printers natively for software
75          accounting methods. More formats to come.
76           
77    Quota systems :       
78   
79        - Supports printers and printers groups quotas.
80       
81        - Supports users and users groups quotas.
82       
83        - Supports page quotas.
84          Page quotas can be set differently on a per printer
85          and per user/group basis.
86       
87        - Supports account balance quotas in any currency.
88          Account balance quotas can be set on a per user
89          basis. The account balance is shared amongst
90          all printers. The history of payments (positive
91          or negative credits to an user account) is kept.
92         
93        - Page quota and account balance can be set/reset
94          independantly.
95         
96        - Limiting factor, page quota or account balance, 
97          can be set on a per user or per group basis.
98         
99        - Price per page and per job can be set differently 
100          on any printer.
101       
102        - Low level of page quota or account balance are
103          configurable.
104         
105        - Both soft and hard limit with configurable grace delay 
106          can be set for page quota.
107         
108        - Possibility to disable quota enforcement for any user
109          or group, while still keeping page accounting.
110             
111    Administration :       
112   
113        - Powerful administration tools can be used to
114          automate setting or resetting of quotas or
115          account balances at specific intervals.
116         
117        - Administration tools can modify several users, 
118          groups, or printers at once.
119         
120        - Account balances can be set, incremented, or 
121          decremented.
122         
123        - Both printers and users can be automatically added on
124          first print in a completely configurable way.
125         
126        - Quota report generator available either from the 
127          command line or in any web browser.
128          The web-based quota report generator can be
129          user/password protected.
130         
131        - Print quote generator can tell users how much 
132          a print job will cost them in advance.
133         
134        - Policy with regard to unregistered users can   
135          be configured for each printer to either deny
136          printing, allow printing, or delegate the
137          decision to any external tool.
138         
139        - Warning and error messages can be automatically 
140          sent via email to the administrator, the user,
141          both, or none.
142         
143        - Warning and error messages' content is completely
144          configurable.
145         
146        - Configuration can be changed without needing to 
147          restart the printing system.
148       
149        - Complete print job history is kept. This can be
150          disabled if needed.
151         
152        - Automated low quota or balance remainder can be
153          scheduled regularly or launched manually.
154         
155    User Interface :         
156   
157        - All the command line tools accept the -h | --help
158          command line option which prints all the available
159          options and show usage examples.
160         
161        - Completely internationalized. Actually supports the 
162          English, French, Spanish, Portuguese, Brasilian, Swedish
163          and Italian languages. More to come.
164
165====================================================================
166       
167Planned features are described in the TODO file.
168
169Actually two (or an infinity of) page accounting methods are
170implemented :
171
172  - The 'hardware' method consists in querying the printer (via SNMP
173    or Netatalk or any other method of your choice) for its total pages
174    counter.
175   
176    With CUPS, this is done both at the beginning and at the end of a
177    print job. The counters difference is then immediately used to
178    decrease the user's account balance or increase his quota usage.
179   
180    With LPRng, this is done just before the beginning of a job, and used
181    this to modify the *preceding* user's quota. So you're always late
182    of one print job, but this is generally ok.
183   
184  - The 'software' method consists in delegating the computation of the
185    job's size in number of pages to any external command of your choice.
186    The command can read the job's data from its standard input and MUST
187    output the job's size on its standard output. Changes to the user
188    account are reported immediately, both with CUPS and LPRng.
189   
190PyKota is known to work fine with HP Laserjet 2100 and 2200, and
191Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under
192Debian GNU/Linux (Sarge and Sid) operating systems. It should work
193fine with most network printers.
194
195============================================================
196
197INSTALLATION:
198=============
199
200NB :
201====
202
203  You may learn more about PyKota, if it fits your own organization,
204  its internal working, and some potential performance drawbacks and
205  how to avoid them, in a WiKi administered by Ryan Suarez at :
206 
207    http://webcrossing.macosxlabs.org/webx?14@30.QAu3a5k0c4z.7@.26bf4661
208
209Prerequisite :
210--------------
211   
212  You need to have the following tools installed on the CUPS Server :
213 
214    - CUPS or LPRng
215    - Python v2.1 or above
216    - eGenix' mxDateTime Python extension
217    - SNMP tools (specifically the snmpget command) if you plan to
218      request your printer's lifetime page counter via SNMP.
219    - Netatalk (specifically the pap command) if you plan to
220      request your printer's lifetime page counter via AppleTalk.
221    - PostgreSQL's PygreSQL Python extension and the PostgreSQL client
222      libraries if you plan to use PostgreSQL as the Quota Storage
223      backend.
224 or     
225    - python-ldap Python module and the OpenLDAP client libraries 
226      if you plan to use OpenLDAP as the Quota Storage backend.
227   
228  On Intel i386 architecture, and for performance reasons if you
229  print in PCL5 or PCL6 format, it is strongly suggested that you 
230  install the Python accelerator Psyco, available at :
231 
232      http://psyco.sourceforge.net
233     
234  Under Debian :   
235 
236      $ apt-get install python-psyco
237     
238  Other architectures may be supported as well in the future, check   
239  on Psyco's website.
240 
241  Installing Psyco is not mandatory, but it woud speedup PCL5 parsing
242  by almost 3 times. PostScript and PDF parsing can also benefit,
243  but in an almost unnoticeable manner since this part of the code
244  is already optimal. For PCL5 this is a completely different matter,
245  and if you install Psyco you will never regret it !
246  Same remark applies for PCL6 (aka PCLXL) but performance improvement
247  is yet to be tested (it is high anyway).
248 
249  You may also benefit from having the following tools installed to
250  deal with some printers :
251 
252    - npadmin
253    - netcat
254    - ghostscript
255   
256  You need to have the following tools installed on the Quota Storage 
257  Server :
258 
259    - PostgreSQL
260   
261  or 
262 
263    - OpenLDAP
264   
265NB :   
266
267  PygreSQL must be linked with the PostgreSQL client libraries on
268  the Print Server. The PostgreSQL client libraries' version must
269  match the PostgreSQL version used on the Quota Storage Server.
270  BEWARE : under Debian Sarge, as of March 15th 2004, there's a
271  problem with python2.2-pygresql and python-2.3-pygresql, so please
272  install python2.1-pygresql and use Python 2.1 to install and run
273  PyKota. This is not a bug in PyKota, and this should be fixed
274  by Debian in a few days I hope.
275 
276or 
277
278  python-ldap must be linked with the OpenLDAP client libraries on the
279  Print Server. The OpenLDAP client libraries' version must match the
280  OpenLDAP version used on the Quota Storage Server.
281 
282  This list of prerequisite software may change in the future, when
283  PyKota will support more functionnalities you will be given
284  alternatives.
285 
286  Of course the Print Server and the Quota Storage Server can be the
287  very same machine if you've got a tiny network, or you can have
288  multiple Print Servers all storing their quotas on the same Quota
289  Storage Server if you've got a bigger network.
290 
291Then :   
292------
293 
294Download the latest PyKota version from the CVS tree on :
295
296    http://savannah.nongnu.org/projects/pykota
297
298Just type :
299
300    python setup.py install
301
302You may need to be logged in with sufficient privileges (e.g. root)
303
304The installation script will now automatically check if some software
305is missing and ask you if you still want to proceed with the
306installation or abort it completely.
307
308Go to the initscripts subdirectory of PyKota's sources, and choose
309the appropriate storage backend for your configuration. Read
310the associated README file and execute the initialization script
311to create an empty PyKota Storage. Upgrade scripts may be
312provided as well.
313
314Copy the conf/pykota.conf.sample and  conf/pykotadmin.conf.sample
315sample configuration files to /etc/pykota/pykota.conf and
316/etc/pykota/pykotadmin.conf. The installation script tries to do
317this for you if needed and you agreed to this action. You need to
318adapt these files to your own needs. Especially you have to create
319sections named after your own printers, and change the
320administrator's email address which by default is root@localhost.
321Read and try to understand these two very well commented files,
322so that you'll encounter less problems later.
323
324Also be sure to double check that commands that query printers
325for their internal page counter work from the command line
326before using them in PyKota's configuration.
327
328The rest of the installation depends on your printing system :
329
330  - CUPS Printing System :
331 
332    Once and for all :
333   
334        Create a symbolic link to the cupspykota backend
335        in CUPS's backend directory :
336       
337          $ cd /usr/lib/cups/backend
338          $ ln -s /usr/share/pykota/cupspykota cupspykota
339         
340        Restart CUPS so that the new backend can be detected.
341       
342          $ /etc/init.d/cupsys restart
343         
344    For new printers :
345   
346        Go to CUPS management interface (http://localhost:631)
347        and choose the appropriate PyKota managed device depending
348        on the type of printer you use. For example, if your
349        printer is waiting on :
350       
351            socket://myprinter.example.com:9100
352           
353        Then choose :   
354       
355            cupspykota:socket://myprinter.example.com:9100
356           
357        Configure your printer as usual.   
358       
359        Now double check /etc/pykota/pykota.conf
360        This file should contain a section named after the
361        printer you've just added, unless you have set
362        all options globally.
363        The new pkhint command can help you with correct settings
364        for your printers, but don't rely on it because it is still
365        incomplete.
366       
367        That's all.
368   
369    For existing printers :
370   
371        If you had already installed a version of PyKota earlier
372        than 1.16alpha7, then remove the *cupsFilter lines in your
373        PPD files for each printer already managed printers. Each
374        line to remove is of the form :
375       
376          *cupsFilter: "application/vnd.cups-postscript 0 /usr/share/pykota/pykota"
377       
378        This means that each time the pstops filter will be executed, it will
379        pass the job's data through the pykota filter which is present in
380        /usr/share/pykota
381       
382        Don't touch anything else, especially any other *cupsFilter line.
383        Then save each of these files.
384       
385        Then, the easiest is to directly modify the DeviceURI lines
386        in /etc/cups/printers.conf, you just have to put
387        'cupspykota:' in front of what is already on these lines.
388        For example, replace :
389   
390            DeviceURI socket://myprinter.example.com:9100
391       
392        with :   
393   
394            DeviceURI cupspykota:socket://myprinter.example.com:9100
395           
396        or :   
397       
398            DeviceURI cupspykota://socket://myprinter.example.com:9100
399       
400        Save the file and restart CUPS.
401
402  - LPRng Printing System :
403 
404      For now LPRng support in PyKota is deactivated. Please be patient.
405     
406Now you can begin to populate the PyKota's database with printers,
407users and groups :
408 
409Add printers and users to the quota system and set their quota values :
410
411Starting from version 1.18alpha2, the preferred command to manage
412printers is named pkprinters
413
414    $ pkprinters --help
415   
416    will tell you how to create, manage or delete printers and
417    printers groups.
418   
419    $ pkprinters --add --charge 0.05 hp2100
420   
421    would add the printer named hp2100 with a price per page
422    of 0.05 unit.
423
424Now set quotas for users on this printer :     
425
426    $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN
427       
428    launching edpykota without any argument or with the --help
429    command line option will show you all the possibilities.
430   
431    by default, each user is limited by "quota", this means that on
432    each printer he can have a different soft and hard limit.
433    You may want to limit the user by his account balance value,
434    in which case, the print quota is shared between all printers
435    instead of being different. To do this, use the following :
436   
437    $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN
438   
439    This will put 10 $ (or Euros, PyKota doesn't care) on each user's account
440    balance, and tell PyKota to limit them by their account balance value.
441    Whenever they print on any printer, their account balance value is
442    decreased by an amount which depends on the particular price per page
443    and per job that you may have defined on the printer with edpykota's
444    --charge command line option.
445    Soft and Hard limits are not used if "--limitby balance" is used,
446    but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf
447    to obtain a similar result (warning message when quota is low).
448
449Restart CUPS or LPRng, for example under Debian GNU/Linux systems :         
450
451    $ /etc/init.d/cupsys restart
452   
453  or :
454 
455    $ /etc/init.d/lprng restart
456       
457Your users now should be able to print but not exceed their
458printing quota.
459
460To see printer quota usage, you can use :
461
462    $ repykota --printer lp
463   
464or :
465
466    $ repykota
467   
468    which will print quota usage for all users on all printers,
469    along with totals, if you are the root user. If you are
470    a regular user, only your own quota report will be produced.
471   
472Quota reports are also available remotely by using the CGI script
473printquota.cgi provided in the cgi-bin/ subdirectory. You can
474also use the CSS stylesheet present in the stylesheets/ subdirectory
475and put it at your web server's DocumentRoot, to benefit from a nicer
476look, especially quota violations will appear in different colors.
477
478For different security concerns, please give a look at the SECURITY
479file which is part of this software.
480           
481============================================================
482
483Mailing list :
484--------------
485
486  A mailing list is dedicated to Pykota, you can subscribe to it
487  or consult its archives at :
488 
489    http://cgi.librelogiciel.com/mailman/listinfo/pykota
490   
491IRC :   
492-----
493
494  You can also chat with us :
495 
496        /server irc.freenode.net
497        /join #pykota
498   
499============================================================
500   
501Please e-mail bugs to the mailing list at : pykota@librelogiciel.com
502or to the main author at : alet@librelogiciel.com (Jerome Alet)
Note: See TracBrowser for help on using the browser.