1 | # $Id$ |
---|
2 | |
---|
3 | PyKota - Print Quota for CUPS |
---|
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), which works by directly querying the printers |
---|
28 | for the number of pages they have printed. |
---|
29 | |
---|
30 | Actual working features : |
---|
31 | |
---|
32 | - Per printer user quotas. |
---|
33 | |
---|
34 | - Automated email warning of users above quota to the |
---|
35 | user himself and to the print quota administrator. |
---|
36 | |
---|
37 | - CUPS filter for quota accounting : pykota |
---|
38 | |
---|
39 | - Command line print quota editor : edpykota |
---|
40 | |
---|
41 | - Command line print quota report generator : repykota |
---|
42 | |
---|
43 | - Command line print quota automated warning sender : warnpykota |
---|
44 | |
---|
45 | - Command line tools mimic the disk quota utilities for |
---|
46 | easier mastering. |
---|
47 | |
---|
48 | - Centralized storage of quotas : you can manage quotas for |
---|
49 | different printers on different print servers and store them all |
---|
50 | on the same quota storage server. |
---|
51 | WARNING : actually all your printers must have an unique name, |
---|
52 | but this may change in a future version. |
---|
53 | |
---|
54 | - SNMP querying of any networked SNMP-enabled printer. |
---|
55 | |
---|
56 | - External command querying of any printer : you can use |
---|
57 | you own querying command, e.g. to query a printer via |
---|
58 | the serial port, sending it a special PJL job and |
---|
59 | reading the result. See the example scripts in the |
---|
60 | "untested" directory and try to adapt them to your |
---|
61 | configuration. |
---|
62 | |
---|
63 | - Special scripts included for a seamless integration of |
---|
64 | PyKota on Debian machines. |
---|
65 | |
---|
66 | All the command line tools accept the -h | --help command line option |
---|
67 | which prints all the available options and show usage examples. |
---|
68 | |
---|
69 | Planned features are described in the TODO file. |
---|
70 | |
---|
71 | Actually only the lazy quota method is implemented. What do I call |
---|
72 | lazy method ? |
---|
73 | |
---|
74 | The lazy method consists in querying the printer (actually via SNMP) |
---|
75 | for its total pages counter, just before the beginning of a job, and |
---|
76 | use this to modify the *preceding* user's quota. So you're |
---|
77 | always late of one print job, but this is generally ok, especially |
---|
78 | because a check is also done to see if the current user is allowed |
---|
79 | or not to print. |
---|
80 | |
---|
81 | Problem may theorically arise in batches of successive print jobs by |
---|
82 | different users when there's no sleep time between two jobs : the |
---|
83 | used pages may theorically be attributed to an incorrect user in the |
---|
84 | case that the printer is asked for its page counter at the beginning |
---|
85 | of a new job and before the end of the previous job. This depends on |
---|
86 | the printer speed and time between jobs, but so far I've not seen |
---|
87 | any problem with moderately used printers. This also depends on CUPS |
---|
88 | internal behavior : if CUPS doesn't begin to send a job to a printer |
---|
89 | before the previous one is completely printed, then there's no |
---|
90 | problem. |
---|
91 | |
---|
92 | Other querying methods which won't suffer from this possible |
---|
93 | problem, but probably from other ones ;-) will be implemented in the |
---|
94 | future. |
---|
95 | |
---|
96 | PyKota is known to work fine with HP Laserjet 2100 and 2200 |
---|
97 | networked printers, and should work with any SNMP-enabled |
---|
98 | network printer capable of outputing its lifetime printed pages |
---|
99 | number. |
---|
100 | |
---|
101 | If your printers don't support SNMP, then making them work with |
---|
102 | PyKota is up to you. Some sample scripts which can query non-SNMP |
---|
103 | printers for their lifetime page counter are included in the |
---|
104 | ./untested directory. You'll have to test and adapt them though, and |
---|
105 | define them as external requesters in the PyKota configuration file. |
---|
106 | |
---|
107 | ============================================================ |
---|
108 | |
---|
109 | INSTALLATION: |
---|
110 | ============= |
---|
111 | |
---|
112 | WARNING : |
---|
113 | ========= |
---|
114 | |
---|
115 | If you run a PyKota version lower than 1.01, you definitely have to |
---|
116 | upgrade you Quota Storage Database. Please read the documentation |
---|
117 | included in the initscripts subdirectory first ! |
---|
118 | |
---|
119 | Prerequisite : |
---|
120 | -------------- |
---|
121 | |
---|
122 | You need to have the following tools installed on the CUPS Server : |
---|
123 | |
---|
124 | - CUPS |
---|
125 | - Python v2.1 or above |
---|
126 | - eGenix' mxDateTime Python extension |
---|
127 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
128 | libraries. |
---|
129 | - SNMP tools (specifically the snmpget command) |
---|
130 | |
---|
131 | You need to have the following tools installed on the Quota Storage |
---|
132 | Server : |
---|
133 | |
---|
134 | - PostgreSQL |
---|
135 | |
---|
136 | PygreSQL and the PostgreSQL client libraries's versions on the CUPS |
---|
137 | Server must match the PostgreSQL version used on the Quota Storage |
---|
138 | Server. |
---|
139 | |
---|
140 | This list of prerequisite software may change in the future, when |
---|
141 | PyKota will support more functionnalities you will be given |
---|
142 | alternatives. |
---|
143 | |
---|
144 | Of course the CUPS Server and the Quota Storage Server can be the |
---|
145 | very same machine if you've got a tiny network, or you can have |
---|
146 | multiple CUPS Servers all storing their quotas on the same Quota |
---|
147 | Storage Server if you've got a bigger network. |
---|
148 | |
---|
149 | Then : |
---|
150 | ------ |
---|
151 | |
---|
152 | Download the latest PyKota version from the CVS tree on : |
---|
153 | |
---|
154 | http://savannah.nongnu.org/projects/pykota |
---|
155 | |
---|
156 | Just type : |
---|
157 | |
---|
158 | python setup.py install |
---|
159 | |
---|
160 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
161 | |
---|
162 | The installation script will now automatically check if some software |
---|
163 | is missing and ask you if you still want to proceed with the |
---|
164 | installation or abort it completely. |
---|
165 | |
---|
166 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
167 | the appropriate storage backend for your configuration. Read |
---|
168 | the associated README file and execute the initialization script |
---|
169 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
170 | provided as well. |
---|
171 | |
---|
172 | Copy the conf/pykota.conf.sample sample configuration file to |
---|
173 | /etc/pykota.conf, and adapt this file to your own needs and |
---|
174 | configuration. |
---|
175 | |
---|
176 | Modify the PPD files for each printer on which you want to manage |
---|
177 | print quotas, for example /etc/cups/ppd/lp.ppd : |
---|
178 | |
---|
179 | --- Add the line below exactly as-is somewhere near the top --- |
---|
180 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
181 | --- Add the line above exactly as-is somewhere near the top --- |
---|
182 | |
---|
183 | Modify the path to the pykota executable if needed, unfortunately |
---|
184 | you have to supply the correct absolute path here due to CUPS |
---|
185 | internals, or put the pykota executable into /usr/lib/cups/filter |
---|
186 | instead of into /usr/bin. |
---|
187 | |
---|
188 | Do this for each ppd file present in this directory if you want |
---|
189 | to enable quota on every printer. |
---|
190 | |
---|
191 | WARNING : In the case you've got a non-postscript printer, chances |
---|
192 | are that the *cupsFilter is already filled-in and points |
---|
193 | to cupsomatic or such a print filter. In this case please |
---|
194 | check if you can switch your printer to PostScript mode |
---|
195 | or if there's a way to make it accept PostScript jobs. |
---|
196 | If yes then ensure that your workstations uses a PostScript |
---|
197 | printer driver, and replace the *cupsFilter line with the |
---|
198 | one pointing to the pykota filter. This should work, but |
---|
199 | is currently untested. |
---|
200 | If your printer really needs the original *cupsFilter line |
---|
201 | then you may not be able to use PyKota easily for now. |
---|
202 | |
---|
203 | Add printers and users to the quota system and set their quota values : |
---|
204 | |
---|
205 | $ edpykota --add -P printer -S softlimit -H hardlimit user1 ... userN |
---|
206 | |
---|
207 | launching edpykota without any argument or with the --help |
---|
208 | command line option will show you all the possibilities. |
---|
209 | |
---|
210 | Restart CUPS, for example under Debian GNU/Linux systems : |
---|
211 | |
---|
212 | $ /etc/init.d/cupsys restart |
---|
213 | |
---|
214 | Your users now should be able to print but not exceed their |
---|
215 | printing quota. |
---|
216 | |
---|
217 | To see printer command usage, you can use : |
---|
218 | |
---|
219 | $ repykota --printer lp |
---|
220 | |
---|
221 | or : |
---|
222 | |
---|
223 | $ repykota |
---|
224 | |
---|
225 | which will print quota usage for all users on all printers, |
---|
226 | along with totals. |
---|
227 | |
---|
228 | WARNING : as of today, 2003-02-06, group quotas are not |
---|
229 | implemented. |
---|
230 | |
---|
231 | SECURITY : You should ensure that only the print quota administrator |
---|
232 | can run the warnpykota command, but this is actually not |
---|
233 | enforced in the program. Any user able to launch warnpykota |
---|
234 | could flood over-quota users' email boxes. |
---|
235 | |
---|
236 | You should ensure that only the print quota administrator |
---|
237 | can run the edpykota command, but this is actually not |
---|
238 | enforced in the program. Otherwise, any user could modify |
---|
239 | his/her or other people's print quota. |
---|
240 | |
---|
241 | launching : chmod 750 /usr/bin/warnpykota /usr/bin/edpykota |
---|
242 | should make you reasonably safe. |
---|
243 | |
---|
244 | ============================================================ |
---|
245 | |
---|
246 | Please e-mail bugs to: alet@librelogiciel.com (Jerome Alet) |
---|