root / pykota / trunk / README @ 2151

Revision 2151, 25.3 kB (checked in by jerome, 19 years ago)

Why the hell did I forget to add this wonderful feature which
comes at no cost thanks to cron : highly granular periodic
print quotas ?

  • 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
22READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE'
23
24====================================================================
25
26PyKota features :
27-----------------
28
29    Free Software :
30   
31        - Licensed under the terms of the GNU General Public License.
32       
33    Commercially Supported :   
34   
35        - Support Contracts are available from http://www.librelogiciel.com/techsupport/
36       
37    Operating systems :
38   
39        - Any Unix-like system as print server.
40           
41        - Any operating system as client.
42           
43    Printing systems :
44   
45        - Supports both CUPS and LPRng as the printing system.
46       
47    Databases :
48   
49        - Supports PostgreSQL as the Quota Storage backend.
50          Complete database creation script in SQL is included.
51       
52        - Supports any LDAP server as the Quota Storage backend.
53          Complete LDAP schema and sample empty tree are included.
54          Plugging PyKota into your existing LDAP infrastructure
55          is really easy thanks to PyKota's great configurability.
56         
57        - The print jobs history can be stored in any database 
58          of your choice (or in plain text files) if needed.
59           
60    Printers :       
61   
62        - Hardware or Software accounting methods are completely
63          configurable.
64         
65        - Supports any printer which can report its internal
66          page counter. Can ask printers for their internal
67          page counter via SNMP, Netatalk, PJL, PS, or any
68          other way.
69          This is completely configurable.
70         
71        - Supports DSC compliant and binary PostScript, PDF, PCL5 (up to),
72          PCLXL (aka PCL6) and ESC/P2 printers natively for software
73          accounting methods. More formats to come.
74           
75    Quota systems :       
76   
77        - Supports printers and printers groups quotas.
78       
79        - Supports users and users groups quotas.
80       
81        - Supports page quotas.
82          Page quotas can be set differently on a per printer
83          and per user/group basis.
84       
85        - Supports account balance quotas in any currency.
86          Account balance quotas can be set on a per user
87          basis. The account balance is shared amongst
88          all printers. The history of payments (positive
89          or negative credits to an user account) is kept.
90         
91        - Supports high granularity periodic print quotas : down
92          to one minute intervals if needed.
93       
94        - Page quotas and account balance can be set/reset
95          independantly.
96         
97        - Page quotas can be set on a per user or per group basis
98          for a particular printer.
99         
100        - Price per page and per job can be set differently 
101          on any printer.
102       
103        - Low level of page quota or account balance are
104          configurable.
105         
106        - Both soft and hard limit with configurable grace delay 
107          can be set for page quota.
108         
109        - Possibility to disable quota enforcement for any user
110          or group, while still keeping page accounting.
111         
112        - Each user can have an overcharging (or undercharging) factor, 
113          which is applied whenever PyKota computes the cost of a
114          print job.
115         
116    Administration :       
117   
118        - Powerful delegation of administrative priviledges.
119       
120        - Powerful administration tools can be used to
121          automate setting or resetting of quotas or
122          account balances at specific intervals.
123         
124        - Administration tools can modify several users, 
125          groups, or printers at once with the use of
126          powerful wildcard characters.
127         
128        - Account balances can be set, incremented, or 
129          decremented. History of payments is kept.
130         
131        - Number of pages used can be set, incremented, or 
132          decremented.
133         
134        - Both printers and users can be automatically added on
135          first print in a completely configurable way.
136         
137        - Quota report generator available either from the 
138          command line or in any web browser.
139          The web-based quota report generator can be
140          user/password protected.
141         
142        - Print quote generator can tell users how much 
143          a print job will cost them in advance.
144         
145        - Policy with regard to unregistered users can   
146          be configured for each printer to either deny
147          printing, allow printing, or delegate the
148          decision to any external tool.
149         
150        - Warning and error messages can be automatically 
151          sent via email or via any other mean to the administrator,
152          the user, both, or none.
153         
154        - Warning and error messages' content is completely
155          configurable.
156         
157        - Configuration can be changed without needing to 
158          restart the printing system.
159       
160        - Complete print job history is kept. This can be
161          disabled if needed.
162         
163        - Automated low quota or balance remainder can be
164          scheduled regularly or launched manually.
165         
166        - Starting and Ending personalized dynamic banners can be
167          generated on the fly, and accounted for or not, depending
168          on some configuration settings.
169          Banners can still be enabled even if the print job is denied.
170          NB : Banners are a CUPS only feature for now.
171         
172        - Duplicate print jobs can be forbidden automatically. 
173         
174        - Powerful data dumper to export datas to other
175          software (spreadsheets for example). Actually
176          supported formats are :
177         
178            - Comma separated values ;
179           
180            - Semicolon separated values ;
181           
182            - Tab separated values ;
183           
184            - XML.
185           
186            - CUPS' page_log format, to easily interface in
187              real time with third party apps like phpPrintAnalyzer
188              and similar tools.
189         
190    User Interface :         
191   
192        - All the command line tools accept the -h | --help
193          command line option which prints all the available
194          options and show usage examples.
195         
196        - Completely internationalized. Actually supports the 
197          English, French, Spanish, Portuguese, Brazilian, Swedish,
198          Thai, Greek, German, Italian, Norwegian (Bokm�, Turkish
199          and traditional Chinese languages.
200          More to come.
201         
202        - Web based print quota monitor and data dumper are included. 
203       
204        - An On Screen Display X-Window print quota monitor is included.
205       
206        - An email gateway to allow users to retrieve their print quota
207          information by sending an email message to a dedicated address
208          is included.
209       
210        - A cross-platform print quota monitor will soon be available
211          as an purchaseable add-on.
212         
213        - Third party web based management tools are available.
214
215====================================================================
216       
217Planned features are described in the TODO file.
218
219Actually two (or an infinity of) page accounting methods are
220implemented :
221
222  - The 'hardware' method consists in querying the printer (via SNMP
223    or Netatalk or any other method of your choice) for its total pages
224    counter.
225   
226    This is done both at the beginning and at the end of a
227    print job. The counters difference is then immediately used to
228    decrease the user's account balance or increase his quota usage.
229   
230  - The 'software' method consists in delegating the computation of the
231    job's size in number of pages to any external command of your choice.
232    The command can read the job's data from its standard input and MUST
233    output the job's size on its standard output. Changes to the user
234    account are reported immediately.
235   
236PyKota is known to work fine with most laser printers, either with
237software accounting, or with hardware accounting if the printer
238supports this.
239
240============================================================
241
242SUPPORT CONTRACTS:
243==================
244
245  You can now purchase 8x5x365@NextBusinessDay Technical
246  Support Contracts from us. The yearly fee is computed with 
247  the following formula :
248
249  (100.0 * NbPrintServers) + (2.5 * NbPrinters) + (0.04 * NbUsers) EUROS.
250 
251  This fee includes the VAT, and a free subscription to official 
252  PyKota packages. 
253
254  Please send an email to alet@librelogiciel.com if you're
255  interested in purchasing such a contract.   
256
257  Remember that purchasing a support contract for Free Software like PyKota
258  is a great way to show your appreciation for the work already being done
259  on this project, and will help to improve this software in the future.
260
261============================================================
262
263INSTALLATION:
264=============
265
266NB :
267====
268
269  You may learn more about PyKota, if it fits your own organization,
270  its internal working, and some potential performance drawbacks and
271  how to avoid them, in a document created by Ryan Suarez at :
272 
273    http://archive.macosxlabs.org/forum/webcrossing_archive/documentation/Pykota_and_CUPS/Pykota_and_CUPS.html
274
275  You may also find the following document interesting :
276 
277    http://es.tldp.org/Tutoriales/doc-openldap-samba-cups-python/
278   
279  This document, written in Spanish by Sergio Gonzalez Gonzalez, 
280  describes the integration of PyKota into an OpenLDAP + Samba
281  + CUPS installation. Even for people who can't read spanish
282  this document is really interesting, and contains lots of
283  screenshots.
284 
285  Finally, SuSe users may find the following document to best describe
286  how to install PyKota on their favorite distribution. It's a Spanish
287  document written by Dennis Romero :
288 
289    http://www.cvr.espol.edu.ec/people/dennis/Pykota1.19-SuSE9.1.pdf
290 
291 
292Prerequisite :
293--------------
294   
295  You need to have the following tools installed on the CUPS Server :
296 
297    - CUPS (http://www.cups.org) or LPRng (http://www.lprng.com)
298    - Python v2.1 or above (http://www.python.org)
299    - eGenix' mxDateTime Python extension (http://www.egenix.com)
300    - The JAXML Python module to be able to dump datas in the XML format.
301      (http://www.librelogiciel.com/software/)
302    - The Python-SNMP module to query printers for their page counter.
303      (http://pysnmp.sourceforge.net).
304      IMPORTANT : version 3.4.3 (or 3.4.2) is REQUIRED. Versions 2.x or
305      4.x won't work for now.
306    - The Python-OSD module to use the graphical print quota reminder.
307    - SNMP tools (specifically the snmpget command) if you prefer to
308      use your own script to request query printers.
309    - Netatalk (specifically the pap command) if you plan to
310      request your printer's lifetime page counter via AppleTalk.
311      (http://netatalk.sourceforge.net)
312    - The ReportLab Python module (http://www.reportlab.org) if you want 
313      to have PyKota generate nice banners for you.
314    - The Python Imaging Library (aka PIL) module
315      (http://www.pythonware.com/downloads) if you want to have PyKota
316      generate nice banners for you.
317    - PostgreSQL's PygreSQL Python extension and the PostgreSQL client
318      libraries if you plan to use PostgreSQL as the Quota Storage
319      backend.
320      (http://www.postgresql.org and http://www.pygreql.org)
321 or     
322    - python-ldap Python module and the OpenLDAP client libraries 
323      if you plan to use an LDAP server as the Quota Storage backend.
324      (http://www.openldap.org and http://python-ldap.sourceforge.net)
325   
326  On Intel i386 architecture, and for performance reasons, it is
327  strongly suggested that you install the Python accelerator Psyco,
328  available at :
329 
330      http://psyco.sourceforge.net
331     
332  Under Debian :   
333 
334      $ apt-get install python-psyco
335     
336  Other architectures may be supported as well in the future, check   
337  this on Psyco's website.
338 
339  Installing Psyco is not mandatory, but it will speedup PCL5 parsing
340  by almost 3 times. PostScript and PDF parsing can also benefit,
341  but in an almost unnoticeable manner since this part of the code
342  is already optimal. For PCL5 this is a completely different matter,
343  and if you install Psyco you will never regret it !
344  Same remark applies for PCL6 (aka PCLXL) : the parser is completely
345  different, but the performance gain with Psyco is impressive.
346 
347  You may also benefit from having the following tools installed to
348  deal with some printers :
349 
350    - npadmin
351    - netcat
352    - ghostscript
353   
354  You need to have the following tools installed on the Quota Storage 
355  Server :
356 
357    - PostgreSQL (http://www.postgresql.org)
358   
359  or 
360 
361    - OpenLDAP, or any other LDAP server (http://www.openldap.org)
362   
363NB :   
364
365  PygreSQL must be linked with the PostgreSQL client libraries on
366  the Print Server. The PostgreSQL client libraries' version must
367  match the PostgreSQL version used on the Quota Storage Server.
368 
369or 
370
371  python-ldap must be linked with the OpenLDAP client libraries on the
372  Print Server. The OpenLDAP client libraries' version should match the
373  OpenLDAP version used on the Quota Storage Server, if applicable.
374 
375  This list of prerequisite software may change in the future, when
376  PyKota will support more functionnalities you will be given
377  alternatives.
378 
379  Of course the Print Server and the Quota Storage Server can be the
380  very same machine if you've got a tiny network, or you can have
381  multiple Print Servers all storing their quotas on the same Quota
382  Storage Server if you've got a bigger network.
383 
384Hint : 
385------
386
387  - The Debian GNU/Linux distribution is to our knowledge the
388    easiest distribution to install PyKota on, because all
389    of PyKota dependencies are already included, excepted
390    for the PySNMP (http://pysnmp.sourceforge.net) module
391    which for now has to be downloaded separately.
392
393Then :   
394------
395 
396Download the latest PyKota version from the Subversion tree :
397
398    $ svn co svn://svn.librelogiciel.com/pykota/trunk pykota
399
400You can now check if the dependencies are correct by typing :
401
402    $ python checkdeps.py
403   
404To install the software, just type :
405
406    $ python setup.py install
407
408You may need to be logged in with sufficient privileges (e.g. root)
409
410Create a system user for PyKota :
411
412    $ adduser --system --group --home /etc/pykota --gecos PyKota pykota
413   
414Put the user your printing system is run as in the pykota system group :
415
416    $ adduser lp pykota
417   
418    NB : on our system, the CUPS printing system runs as system user 'lp'.
419    Please adapt this to your own system.
420
421Go to the initscripts subdirectory of PyKota's sources, and choose
422the appropriate storage backend for your configuration. Read carefully
423the associated README file and execute the initialization script
424to create an empty PyKota Storage. Upgrade scripts may be
425provided as well.
426
427Copy the conf/pykota.conf.sample and  conf/pykotadmin.conf.sample
428sample configuration files to /etc/pykota/pykota.conf and
429/etc/pykota/pykotadmin.conf 
430The installation script usually copies these files into /usr/share/pykota
431
432NB : You can move PyKota's configuration files elsewhere, they will
433be searched first in user pykota's home directory.
434
435You need to adapt these files to your own needs. Especially you may
436have to create sections named after your own printers, and change
437the administrator's email address which by default is
438root@localhost. Read and try to understand these two very well
439commented files, so that you'll encounter less problems later.
440
441Also be sure to double check that commands that query printers
442for their internal page counter work from the command line
443before using them in PyKota's configuration.
444
445The rest of the installation depends on your printing system :
446
447  - CUPS Printing System :
448 
449    Once and for all :
450   
451        Create a symbolic link to the cupspykota backend
452        in CUPS's backend directory :
453       
454          $ cd /usr/lib/cups/backend
455          $ ln -s /usr/share/pykota/cupspykota cupspykota
456         
457        Restart CUPS so that the new backend can be detected.
458       
459          $ /etc/init.d/cupsys restart
460         
461        or :   
462     
463          $ /etc/rc.d/init.d/cupsys restart
464         
465        or any similar command depending on your operating system. 
466         
467    For new printers :
468   
469        Go to CUPS management interface (http://localhost:631)
470        and choose the appropriate PyKota managed device depending
471        on the type of printer you use. For example, if your
472        printer is waiting on :
473       
474            socket://myprinter.example.com:9100
475           
476        Then choose :   
477       
478            cupspykota:socket://myprinter.example.com:9100
479           
480        Configure your printer as usual.   
481       
482        Now double check /etc/pykota/pykota.conf
483       
484        You should manually create a section named after the
485        printer you've just added, unless you have set
486        all options globally.
487       
488        The new pkhint command can help you with correct settings
489        for your printers, but don't rely on it because it is still
490        experimental work. To use pkhint, you have to feed it with
491        CUPS' printers.conf file this way :
492       
493          $ pkhint </etc/cups/printers.conf
494       
495        pkhint will try to tell you what is the best accounting
496        method for each printer and will print some lines you'll
497        just have to copy&paste in the appropriate sections in
498        /etc/pykota/pykota.conf
499       
500        That's all.
501   
502    For existing printers :
503   
504        If you had already installed a version of PyKota earlier
505        than 1.16alpha7, then remove the *cupsFilter lines in your
506        PPD files for each already managed printer. Each
507        line to remove is of the form :
508       
509          *cupsFilter: "application/vnd.cups-postscript 0 /usr/share/pykota/pykota"
510       
511        This means that each time the pstops filter will be executed, it will
512        pass the job's data through the pykota filter which is present in
513        /usr/share/pykota
514       
515        Don't touch anything else, especially any other *cupsFilter line.
516        Then save each of these files.
517       
518        Then, the easiest is to directly modify the DeviceURI lines
519        in /etc/cups/printers.conf, you just have to put
520        'cupspykota:' in front of what is already on these lines.
521        For example, replace :
522   
523            DeviceURI socket://myprinter.example.com:9100
524       
525        with :   
526   
527            DeviceURI cupspykota:socket://myprinter.example.com:9100
528           
529        or :   
530       
531            DeviceURI cupspykota://socket://myprinter.example.com:9100
532       
533        Save the file and restart CUPS.
534       
535        Here too, you may find it interesting to use the pkhint command as
536        described above to help with manual configuration of the file
537        /etc/pykota/pykota.conf
538
539  - LPRng Printing System :
540 
541    For each printer on which you want to use PyKota :
542   
543        Modify the printer's entry in /etc/printcap : you have to add
544        the three following lines :
545       
546          :achk=true:\
547          :as=/usr/share/pykota/lprngpykota:\
548          :ae=/usr/share/pykota/lprngpykota:\
549         
550        This will tell LPRng to activate accounting, and use the lprngpykota
551        accounting filter both at the start and at the end of printing.
552       
553    When all modifications are done, just save the /etc/printcap file and   
554    restart LPRng :
555   
556          $ /etc/init.d/lprng restart
557         
558        or :   
559     
560          $ /etc/rc.d/init.d/lprng restart
561         
562        or any similar command depending on your operating system. 
563       
564    NB : the pkhint command can't be used with LPRng for now, so you   
565         have to modify /etc/pykota/pykota.conf carefully. The comments
566         in this file will help you.
567     
568Now you can begin to populate the PyKota's database with printers,
569users and groups :
570 
571Add printers and users to the quota system and set their quota values :
572
573Starting from version 1.18alpha2, the preferred command to manage
574printers is named pkprinters
575
576    $ pkprinters --help
577   
578    will tell you how to create, manage or delete printers and
579    printers groups.
580   
581    $ pkprinters --add --charge 0.05 hp2100
582   
583    would add the printer named hp2100 with a price per page
584    of 0.05 unit.
585
586Now set quotas for users on this printer :     
587
588    $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN
589       
590    launching edpykota without any argument or with the --help
591    command line option will show you all the possibilities.
592   
593    by default, each user is limited by "quota", this means that on
594    each printer he can have a different soft and hard limit.
595    You may want to limit the user by his account balance value,
596    in which case, the print quota is shared between all printers
597    instead of being different. To do this, use the following :
598   
599    $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN
600   
601    This will put 10 $ (or Euros, PyKota doesn't care) on each user's account
602    balance, and tell PyKota to limit them by their account balance value.
603    Whenever they print on any printer, their account balance value is
604    decreased by an amount which depends on the particular price per page
605    and per job that you may have defined on the printer with edpykota's
606    --charge command line option.
607    Soft and Hard limits are not used if "--limitby balance" is used,
608    but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf
609    to obtain a similar result (warning message when quota is low).
610
611Restart CUPS or LPRng, for example under Debian GNU/Linux systems :         
612
613    $ /etc/init.d/cupsys restart
614   
615  or :
616 
617    $ /etc/init.d/lprng restart
618       
619Your users now should be able to print but not exceed their
620printing quota.
621
622To see printer quota usage, you can use :
623
624    $ repykota --printer lp
625   
626or :
627
628    $ repykota
629   
630    which will print quota usage for all users on all printers,
631    along with totals, if you are a PyKota Administator. If you are
632    a regular user, only your own quota report will be produced.
633   
634Quota reports are also available remotely by using the CGI script
635printquota.cgi provided in the cgi-bin/ subdirectory. You can
636also use the CSS stylesheet present in the stylesheets/ subdirectory
637and put it at your web server's DocumentRoot, to benefit from a nicer
638look, especially quota violations will appear in different colors.
639
640For different security concerns, please give a look at the SECURITY
641file which is part of this software.
642           
643============================================================
644
645Additionnal tools :
646-------------------
647
648Some people have developped tools around PyKota, and make
649them available under the GNU General Public License :
650
651  - Kanakorn Horsiritham developped phpPykotaAdmin which is
652    a web based database independant administrative GUI,
653    written in PHP.
654 
655      http://opensource.psu.ac.th/~kanakorn/mambo/
656     
657    He was also kind enough to write an installation guide 
658    in english for CUPS and PyKota with phpPykotaAdmin on Fedora
659    Core 3. You'll find this document on the same website.
660   
661    This great software currently at version 0.3 is a wonderful
662    basis for an administrative GUI since it only depends on
663    PyKota commands to be present to successfully manage
664    PyKota's database.
665 
666Additionnal software will be listed here when they will be 
667ready.
668
669============================================================
670
671Mailing list :
672--------------
673
674  A mailing list is dedicated to Pykota, you can subscribe to it
675  or consult its archives at :
676 
677    http://cgi.librelogiciel.com/mailman/listinfo/pykota
678   
679  The mailing list is the preferred way to obtain support, because 
680  all members can help and can also benefit from the solutions
681  proposed by other members.
682 
683  Posts by non-members are usually rejected.
684 
685  The mailing list language is english and only english.
686   
687IRC :   
688-----
689
690  You can also chat with us :
691 
692        /server irc.freenode.net
693        /join #pykota
694       
695  Preferred language on this channel is english, but french     
696  is also accepted. Try to avoid exposing complex problems
697  in french because english speaking people on the channel
698  wouldn't benefit from the solutions.
699 
700  PyKota's main author is known as 'tamere' on IRC.
701   
702============================================================
703   
704Please e-mail bugs to the mailing list at : pykota@librelogiciel.com
705or to the main author at : alet@librelogiciel.com (Jerome Alet)
Note: See TracBrowser for help on using the browser.