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