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 | If your printers don't support SNMP, then making them work with |
---|
96 | PyKota is up to you. Some sample scripts which can query non-SNMP |
---|
97 | printers for their lifetime page counter are included in the |
---|
98 | ./untested directory. You'll have to test and adapt them though, and |
---|
99 | define them as external requesters in the PyKota configuration file. |
---|
100 | |
---|
101 | ============================================================ |
---|
102 | |
---|
103 | INSTALLATION: |
---|
104 | ============= |
---|
105 | |
---|
106 | Prerequisite : |
---|
107 | -------------- |
---|
108 | |
---|
109 | You need to have the following tools installed on the CUPS Server : |
---|
110 | |
---|
111 | - CUPS |
---|
112 | - Python v2.1 or above |
---|
113 | - eGenix' mxDateTime Python extension |
---|
114 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
115 | libraries. |
---|
116 | - SNMP tools (specifically the snmpget command) |
---|
117 | |
---|
118 | You need to have the following tools installed on the Quota Storage |
---|
119 | Server : |
---|
120 | |
---|
121 | - PostgreSQL |
---|
122 | |
---|
123 | PygreSQL and the PostgreSQL client libraries's versions on the CUPS |
---|
124 | Server must match the PostgreSQL version used on the Quota Storage |
---|
125 | Server. |
---|
126 | |
---|
127 | This list of prerequisite software may change in the future, when |
---|
128 | PyKota will support more functionnalities you will be given |
---|
129 | alternatives. |
---|
130 | |
---|
131 | Of course the CUPS Server and the Quota Storage Server can be the |
---|
132 | very same machine if you've got a tiny network, or you can have |
---|
133 | multiple CUPS Servers all storing their quotas on the same Quota |
---|
134 | Storage Server if you've got a bigger network. |
---|
135 | |
---|
136 | Then : |
---|
137 | ------ |
---|
138 | |
---|
139 | Download the latest PyKota version from the CVS tree on : |
---|
140 | |
---|
141 | http://savannah.nongnu.org/projects/pykota |
---|
142 | |
---|
143 | Just type : |
---|
144 | |
---|
145 | python setup.py install |
---|
146 | |
---|
147 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
148 | |
---|
149 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
150 | the appropriate storage backend for your configuration. Read |
---|
151 | the associated README file and execute the initialization script |
---|
152 | to create an empty PyKota Storage. |
---|
153 | |
---|
154 | Copy the conf/pykota.conf.sample sample configuration file to |
---|
155 | CUPS' configuration directory, usually /etc/cups, under the |
---|
156 | name pykota.conf, and adapt this file to your own needs and |
---|
157 | configuration. |
---|
158 | |
---|
159 | Modify the PPD files for each printer on which you want to manage |
---|
160 | print quotas, for example /etc/cups/ppd/lp.ppd : |
---|
161 | |
---|
162 | --- Add the line below exactly as-is somewhere near the top --- |
---|
163 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
164 | --- Add the line above exactly as-is somewhere near the top --- |
---|
165 | |
---|
166 | Modify the path to the pykota executable if needed, unfortunately |
---|
167 | you have to supply the correct absolute path here due to CUPS |
---|
168 | internals, or put the pykota executable into /usr/lib/cups/filter |
---|
169 | instead of into /usr/bin. |
---|
170 | |
---|
171 | Do this for each ppd file present in this directory if you want |
---|
172 | to enable quota on every printer. |
---|
173 | |
---|
174 | WARNING : In the case you've got a non-postscript printer, chances |
---|
175 | are that the *cupsFilter is already filled-in and points |
---|
176 | to cupsomatic or such a print filter. In this case please |
---|
177 | check if you can switch your printer to PostScript mode |
---|
178 | or if there's a way to make it accept PostScript jobs. |
---|
179 | If yes then ensure that your workstations uses a PostScript |
---|
180 | printer driver, and replace the *cupsFilter line with the |
---|
181 | one pointing to the pykota filter. This should work, but |
---|
182 | is currently untested. |
---|
183 | If your printer really needs the original *cupsFilter line |
---|
184 | then you may not be able to use PyKota easily for now. |
---|
185 | |
---|
186 | Add printers and users to the quota system and set their quota values : |
---|
187 | |
---|
188 | $ edpykota --add -P printer -S softlimit -H hardlimit user1 ... userN |
---|
189 | |
---|
190 | launching edpykota without any argument or with the --help |
---|
191 | command line option will show you all the possibilities. |
---|
192 | |
---|
193 | Restart CUPS, for example under Debian GNU/Linux systems : |
---|
194 | |
---|
195 | $ /etc/init.d/cupsys restart |
---|
196 | |
---|
197 | Your users now should be able to print but not exceed their |
---|
198 | printing quota. |
---|
199 | |
---|
200 | To see printer command usage, you can use : |
---|
201 | |
---|
202 | $ repykota --printer lp |
---|
203 | |
---|
204 | or : |
---|
205 | |
---|
206 | $ repykota |
---|
207 | |
---|
208 | which will print quota usage for all users on all printers, |
---|
209 | along with totals. |
---|
210 | |
---|
211 | WARNING : as of today, 2003-02-06, group quotas are not |
---|
212 | implemented. |
---|
213 | |
---|
214 | SECURITY : You should ensure that only the print quota administrator |
---|
215 | can run the warnpykota command, but this is actually not |
---|
216 | enforced in the program. Any user able to launch warnpykota |
---|
217 | could flood over-quota users' email boxes. |
---|
218 | |
---|
219 | You should ensure that only the print quota administrator |
---|
220 | can run the edpykota command, but this is actually not |
---|
221 | enforced in the program. Otherwise, any user could modify |
---|
222 | his/her or other people's print quota. |
---|
223 | |
---|
224 | launching : chmod 750 /usr/bin/warnpykota /usr/bin/edpykota |
---|
225 | should make you reasonably safe. |
---|
226 | |
---|
227 | ============================================================ |
---|
228 | |
---|
229 | Please e-mail bugs to: alet@librelogiciel.com (Jerome Alet) |
---|