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