root / pykota / trunk / README @ 1570

Revision 1570, 17.4 kB (checked in by jalet, 20 years ago)

Now uses Psyco if it is available

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