root / pykota / trunk / README @ 2054

Revision 2054, 24.0 kB (checked in by jalet, 19 years ago)

Big database structure changes. Upgrade script is now included as well as
the new LDAP schema.
Introduction of the -o | --overcharge command line option to edpykota.
The output of repykota is more complete, but doesn't fit in 80 columns anymore.
Introduction of the new 'maxdenybanners' directive.

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