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