1 | # $Id$ |
---|
2 | |
---|
3 | PyKota - Print Quota for CUPS and LPRng |
---|
4 | |
---|
5 | (c) 2003 Jerome Alet <alet@librelogiciel.com> |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2 of the License, or |
---|
9 | (at your option) any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program; if not, write to the Free Software |
---|
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | ==================================================================== |
---|
21 | |
---|
22 | READ SPECIAL LICENSING AND REDISTRBUTION TERMS IN THE FILE 'LICENSE' |
---|
23 | |
---|
24 | ==================================================================== |
---|
25 | |
---|
26 | PyKota is a complete Print Quota system for the Common Unix Printing |
---|
27 | System (aka CUPS) or LPR Next Generation (LPRng), which works by directly |
---|
28 | querying the printers for the number of pages they have printed. |
---|
29 | |
---|
30 | Actual working features : |
---|
31 | |
---|
32 | - Supports both CUPS and LPRng backends. |
---|
33 | |
---|
34 | - Can store quota information either with PostgreSQL or with |
---|
35 | OpenLDAP. |
---|
36 | |
---|
37 | - Per printer user and group quotas. |
---|
38 | |
---|
39 | - Automated email warning of users above quota to the |
---|
40 | user himself and to the print quota administrator. |
---|
41 | |
---|
42 | - Filter for quota accounting : pykota |
---|
43 | |
---|
44 | - Command line print quota editor : edpykota |
---|
45 | |
---|
46 | - Command line print quota report generator : repykota |
---|
47 | |
---|
48 | - Command line print quota automated warning sender : warnpykota |
---|
49 | |
---|
50 | - Command line tools mimic the disk quota utilities for |
---|
51 | easier mastering. |
---|
52 | |
---|
53 | - Centralized storage of quotas : you can manage quotas for |
---|
54 | different printers on different print servers and store them all |
---|
55 | on the same quota storage server. |
---|
56 | |
---|
57 | - SNMP querying of any networked SNMP-enabled printer. |
---|
58 | |
---|
59 | - Netatalk querying of any networked AppleTalk-enabled printer. |
---|
60 | |
---|
61 | - External command querying of any printer : you can use |
---|
62 | you own querying command, e.g. to query a printer via |
---|
63 | the serial port, sending it a special PJL job and |
---|
64 | reading the result. See the example scripts in the |
---|
65 | "untested" directory and try to adapt them to your |
---|
66 | configuration. |
---|
67 | |
---|
68 | - External accounting methods : you can use your own accounting |
---|
69 | method to compute each job's size. Just create a shell script |
---|
70 | which reads the job's data from its standard input and prints |
---|
71 | the job's size on its standard output, and you're done ! |
---|
72 | |
---|
73 | - Special scripts included for a seamless integration of |
---|
74 | PyKota on Debian machines. |
---|
75 | |
---|
76 | - Complete job history is saved. This will allow more |
---|
77 | complex reports in the future. |
---|
78 | |
---|
79 | - Price per page and price per job can be defined for |
---|
80 | every printer. A job's price is the sum of the |
---|
81 | price per job for this printer plus the number of |
---|
82 | pages multiplied by the price per page for this |
---|
83 | printer. |
---|
84 | |
---|
85 | - User's account balance and lifetime paid money are now |
---|
86 | stored in the Quota Storage, and account balance can be |
---|
87 | used to limit the user printing instead of a print quota. |
---|
88 | Actually you can limit either by account balance OR by |
---|
89 | print quota. Account balance is shared between printers |
---|
90 | for an user, while quotas are define separately for |
---|
91 | each printer the user prints on. |
---|
92 | |
---|
93 | All the command line tools accept the -h | --help command line option |
---|
94 | which prints all the available options and show usage examples. |
---|
95 | |
---|
96 | Planned features are described in the TODO file. |
---|
97 | |
---|
98 | Actually three (or an infinity of) page accounting methods are |
---|
99 | implemented : |
---|
100 | |
---|
101 | - The 'querying' method consists in querying the printer (via SNMP |
---|
102 | or Netatalk) for its total pages counter, just before the beginning |
---|
103 | of a job, and use this to modify the *preceding* user's quota. So |
---|
104 | you're always late of one print job, but this is generally ok, |
---|
105 | especially because a check is also done to see if the current user |
---|
106 | is allowed or not to print. You're not limited to SNMP or Netatalk, |
---|
107 | because you can also use any external command instead if you want. |
---|
108 | |
---|
109 | - The 'external' method consists in delegating the computation of the |
---|
110 | job's size in number of pages to any external command of your choice. |
---|
111 | The command can read the job's data from its standard input and MUST |
---|
112 | output the job's size on its standard output. |
---|
113 | |
---|
114 | - The 'stupid' method consists in counting the 'showpage' PostSript |
---|
115 | statements in the job. THIS IS UNRELIABLE, but can serve as an |
---|
116 | example if you plan to write your own accounting method for |
---|
117 | integration into PyKota. |
---|
118 | |
---|
119 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
120 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
121 | Debian GNU/Linux (Sarge and Sid) operating systems. |
---|
122 | |
---|
123 | I'm interested in receiving success or failure reports with other |
---|
124 | brands or models of printers, as well as with other operating |
---|
125 | systems. |
---|
126 | |
---|
127 | ============================================================ |
---|
128 | |
---|
129 | INSTALLATION: |
---|
130 | ============= |
---|
131 | |
---|
132 | WARNING : |
---|
133 | ========= |
---|
134 | |
---|
135 | If you run a PyKota version lower than 1.03, you definitely have to |
---|
136 | upgrade you Quota Storage Database. Please read the documentation |
---|
137 | included in the initscripts subdirectory first ! |
---|
138 | |
---|
139 | Users of MacOS-X may find the following tutorial useful : |
---|
140 | |
---|
141 | http://ell-tech.com/pages/pykota.php |
---|
142 | |
---|
143 | Prerequisite : |
---|
144 | -------------- |
---|
145 | |
---|
146 | You need to have the following tools installed on the CUPS Server : |
---|
147 | |
---|
148 | - CUPS or LPRng |
---|
149 | - Python v2.1 or above |
---|
150 | - eGenix' mxDateTime Python extension |
---|
151 | - SNMP tools (specifically the snmpget command) if you plan to |
---|
152 | request your printer's lifetime page counter via SNMP. |
---|
153 | - Netatalk (specifically the pap command) if you plan to |
---|
154 | request your printer's lifetime page counter via AppleTalk. |
---|
155 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
156 | libraries if you plan to use PostgreSQL as the Quota Storage |
---|
157 | backend. |
---|
158 | or |
---|
159 | - python-ldap Python module and the OpenLDAP client libraries |
---|
160 | if you plan to use OpenLDAP as the Quota Storage backend. |
---|
161 | |
---|
162 | You need to have the following tools installed on the Quota Storage |
---|
163 | Server : |
---|
164 | |
---|
165 | - PostgreSQL |
---|
166 | |
---|
167 | or |
---|
168 | |
---|
169 | - OpenLDAP |
---|
170 | |
---|
171 | PygreSQL and the PostgreSQL client libraries' versions on the Print |
---|
172 | Server must match the PostgreSQL version used on the Quota Storage |
---|
173 | Server. |
---|
174 | |
---|
175 | or |
---|
176 | |
---|
177 | python-ldap and the OpenLDAP client libraries' versions on the Print |
---|
178 | Server must match the OpenLDAP version used on the Quota Storage |
---|
179 | Server. |
---|
180 | |
---|
181 | This list of prerequisite software may change in the future, when |
---|
182 | PyKota will support more functionnalities you will be given |
---|
183 | alternatives. |
---|
184 | |
---|
185 | Of course the Print Server and the Quota Storage Server can be the |
---|
186 | very same machine if you've got a tiny network, or you can have |
---|
187 | multiple Print Servers all storing their quotas on the same Quota |
---|
188 | Storage Server if you've got a bigger network. |
---|
189 | |
---|
190 | Then : |
---|
191 | ------ |
---|
192 | |
---|
193 | Download the latest PyKota version from the CVS tree on : |
---|
194 | |
---|
195 | http://savannah.nongnu.org/projects/pykota |
---|
196 | |
---|
197 | Just type : |
---|
198 | |
---|
199 | python setup.py install |
---|
200 | |
---|
201 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
202 | |
---|
203 | The installation script will now automatically check if some software |
---|
204 | is missing and ask you if you still want to proceed with the |
---|
205 | installation or abort it completely. |
---|
206 | |
---|
207 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
208 | the appropriate storage backend for your configuration. Read |
---|
209 | the associated README file and execute the initialization script |
---|
210 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
211 | provided as well. |
---|
212 | |
---|
213 | Copy the conf/pykota.conf.sample sample configuration file to |
---|
214 | /etc/pykota.conf. The installation script tries to do this for |
---|
215 | you if needed and you agreed to this action. |
---|
216 | You need to adapt the /etc/pykota.conf file to your own needs. |
---|
217 | Especially you have to create sections named after your own |
---|
218 | printers, and change the administrator's email address. |
---|
219 | |
---|
220 | - CUPS Print Backend : |
---|
221 | |
---|
222 | Modify the PPD files for each printer on which you want to manage |
---|
223 | print quotas, for example /etc/cups/ppd/lp.ppd : |
---|
224 | |
---|
225 | --- Add the line below exactly as-is somewhere near the top --- |
---|
226 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
227 | --- Add the line above exactly as-is somewhere near the top --- |
---|
228 | |
---|
229 | Modify the path to the pykota executable if needed, unfortunately |
---|
230 | you have to supply the correct absolute path here due to CUPS |
---|
231 | internals, or put the pykota executable into /usr/lib/cups/filter |
---|
232 | instead of into /usr/bin. |
---|
233 | |
---|
234 | Do this for each ppd file present in this directory if you want |
---|
235 | to enable quota on every printer. |
---|
236 | |
---|
237 | WARNING : In the case you've got a non-postscript printer, chances |
---|
238 | are that the *cupsFilter is already filled-in and points |
---|
239 | to cupsomatic or such a print filter. In this case please |
---|
240 | check if you can switch your printer to PostScript mode |
---|
241 | or if there's a way to make it accept PostScript jobs. |
---|
242 | If yes then ensure that your workstations uses a PostScript |
---|
243 | printer driver, and replace the *cupsFilter line with the |
---|
244 | one pointing to the pykota filter. This should work, but |
---|
245 | is currently untested. |
---|
246 | If your printer really needs the original *cupsFilter line |
---|
247 | then you may not be able to use PyKota easily for now. |
---|
248 | |
---|
249 | - LPRng Print Backend : |
---|
250 | |
---|
251 | Modify the /etc/printcap file to add two lines identical to these ones : |
---|
252 | |
---|
253 | :achk=true |
---|
254 | :as=|/usr/bin/pykota |
---|
255 | |
---|
256 | For each printer on which you want to use print accounting. |
---|
257 | |
---|
258 | Add printers and users to the quota system and set their quota values : |
---|
259 | |
---|
260 | $ edpykota --add -P printer -S softlimit -H hardlimit user1 ... userN |
---|
261 | |
---|
262 | launching edpykota without any argument or with the --help |
---|
263 | command line option will show you all the possibilities. |
---|
264 | |
---|
265 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
266 | |
---|
267 | $ /etc/init.d/cupsys restart |
---|
268 | |
---|
269 | or : |
---|
270 | |
---|
271 | $ /etc/init.d/lprng restart |
---|
272 | |
---|
273 | Your users now should be able to print but not exceed their |
---|
274 | printing quota. |
---|
275 | |
---|
276 | To see printer command usage, you can use : |
---|
277 | |
---|
278 | $ repykota --printer lp |
---|
279 | |
---|
280 | or : |
---|
281 | |
---|
282 | $ repykota |
---|
283 | |
---|
284 | which will print quota usage for all users on all printers, |
---|
285 | along with totals. |
---|
286 | |
---|
287 | Quota reports are also available remotely by using the CGI scripts |
---|
288 | provided in the cgi-bin/ subdirectory. |
---|
289 | |
---|
290 | For different security concerns, please give a look at the SECURITY |
---|
291 | file which is part of this software. |
---|
292 | |
---|
293 | ============================================================ |
---|
294 | |
---|
295 | Mailing list : |
---|
296 | -------------- |
---|
297 | |
---|
298 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
299 | or consult its archives at : |
---|
300 | |
---|
301 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
302 | |
---|
303 | ============================================================ |
---|
304 | |
---|
305 | Please e-mail bugs to: alet@librelogiciel.com (Jerome Alet) |
---|