[695] | 1 | # $Id$ |
---|
| 2 | |
---|
[952] | 3 | PyKota - Print Quota for CUPS and LPRng |
---|
[695] | 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 | |
---|
[1052] | 22 | READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE' |
---|
[761] | 23 | |
---|
| 24 | ==================================================================== |
---|
| 25 | |
---|
[695] | 26 | PyKota is a complete Print Quota system for the Common Unix Printing |
---|
[952] | 27 | System (aka CUPS) or LPR Next Generation (LPRng), which works by directly |
---|
| 28 | querying the printers for the number of pages they have printed. |
---|
[695] | 29 | |
---|
[739] | 30 | Actual working features : |
---|
| 31 | |
---|
[952] | 32 | - Supports both CUPS and LPRng backends. |
---|
| 33 | |
---|
[1043] | 34 | - Can store quota information either with PostgreSQL or with |
---|
| 35 | OpenLDAP. |
---|
| 36 | |
---|
[927] | 37 | - Per printer user and group quotas. |
---|
[739] | 38 | |
---|
| 39 | - Automated email warning of users above quota to the |
---|
| 40 | user himself and to the print quota administrator. |
---|
| 41 | |
---|
[952] | 42 | - Filter for quota accounting : pykota |
---|
[739] | 43 | |
---|
| 44 | - Command line print quota editor : edpykota |
---|
| 45 | |
---|
| 46 | - Command line print quota report generator : repykota |
---|
| 47 | |
---|
| 48 | - Command line print quota automated warning sender : warnpykota |
---|
| 49 | |
---|
[1066] | 50 | - Command line print quote maker, to learn how much a print job |
---|
| 51 | will cost in advance : pykotme |
---|
| 52 | |
---|
[760] | 53 | - Command line tools mimic the disk quota utilities for |
---|
| 54 | easier mastering. |
---|
| 55 | |
---|
[739] | 56 | - Centralized storage of quotas : you can manage quotas for |
---|
| 57 | different printers on different print servers and store them all |
---|
| 58 | on the same quota storage server. |
---|
| 59 | |
---|
[794] | 60 | - SNMP querying of any networked SNMP-enabled printer. |
---|
[739] | 61 | |
---|
[920] | 62 | - Netatalk querying of any networked AppleTalk-enabled printer. |
---|
| 63 | |
---|
[794] | 64 | - External command querying of any printer : you can use |
---|
| 65 | you own querying command, e.g. to query a printer via |
---|
| 66 | the serial port, sending it a special PJL job and |
---|
[840] | 67 | reading the result. See the example scripts in the |
---|
| 68 | "untested" directory and try to adapt them to your |
---|
| 69 | configuration. |
---|
[980] | 70 | |
---|
| 71 | - External accounting methods : you can use your own accounting |
---|
| 72 | method to compute each job's size. Just create a shell script |
---|
[985] | 73 | which reads the job's data from its standard input and prints |
---|
| 74 | the job's size on its standard output, and you're done ! |
---|
[794] | 75 | |
---|
[739] | 76 | - Special scripts included for a seamless integration of |
---|
| 77 | PyKota on Debian machines. |
---|
| 78 | |
---|
[900] | 79 | - Complete job history is saved. This will allow more |
---|
[1149] | 80 | complex reports in the future. This can be disabled |
---|
| 81 | if preserving the history is of no interest or |
---|
| 82 | makes the database grow out of control. |
---|
[900] | 83 | |
---|
[925] | 84 | - Price per page and price per job can be defined for |
---|
[926] | 85 | every printer. A job's price is the sum of the |
---|
[925] | 86 | price per job for this printer plus the number of |
---|
| 87 | pages multiplied by the price per page for this |
---|
| 88 | printer. |
---|
| 89 | |
---|
| 90 | - User's account balance and lifetime paid money are now |
---|
| 91 | stored in the Quota Storage, and account balance can be |
---|
| 92 | used to limit the user printing instead of a print quota. |
---|
| 93 | Actually you can limit either by account balance OR by |
---|
[1027] | 94 | print quota. Account balance is shared between printers |
---|
| 95 | for an user, while quotas are define separately for |
---|
| 96 | each printer the user prints on. |
---|
[925] | 97 | |
---|
[1153] | 98 | - Unknown users can be automatically added on first print. |
---|
| 99 | |
---|
[739] | 100 | All the command line tools accept the -h | --help command line option |
---|
| 101 | which prints all the available options and show usage examples. |
---|
| 102 | |
---|
| 103 | Planned features are described in the TODO file. |
---|
| 104 | |
---|
[980] | 105 | Actually three (or an infinity of) page accounting methods are |
---|
| 106 | implemented : |
---|
[695] | 107 | |
---|
[980] | 108 | - The 'querying' method consists in querying the printer (via SNMP |
---|
| 109 | or Netatalk) for its total pages counter, just before the beginning |
---|
| 110 | of a job, and use this to modify the *preceding* user's quota. So |
---|
| 111 | you're always late of one print job, but this is generally ok, |
---|
| 112 | especially because a check is also done to see if the current user |
---|
| 113 | is allowed or not to print. You're not limited to SNMP or Netatalk, |
---|
| 114 | because you can also use any external command instead if you want. |
---|
| 115 | |
---|
| 116 | - The 'external' method consists in delegating the computation of the |
---|
| 117 | job's size in number of pages to any external command of your choice. |
---|
| 118 | The command can read the job's data from its standard input and MUST |
---|
| 119 | output the job's size on its standard output. |
---|
| 120 | |
---|
| 121 | - The 'stupid' method consists in counting the 'showpage' PostSript |
---|
| 122 | statements in the job. THIS IS UNRELIABLE, but can serve as an |
---|
| 123 | example if you plan to write your own accounting method for |
---|
| 124 | integration into PyKota. |
---|
[724] | 125 | |
---|
[919] | 126 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
[980] | 127 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
| 128 | Debian GNU/Linux (Sarge and Sid) operating systems. |
---|
[724] | 129 | |
---|
[980] | 130 | I'm interested in receiving success or failure reports with other |
---|
| 131 | brands or models of printers, as well as with other operating |
---|
| 132 | systems. |
---|
[859] | 133 | |
---|
[695] | 134 | ============================================================ |
---|
| 135 | |
---|
| 136 | INSTALLATION: |
---|
| 137 | ============= |
---|
| 138 | |
---|
[887] | 139 | WARNING : |
---|
| 140 | ========= |
---|
| 141 | |
---|
[942] | 142 | If you run a PyKota version lower than 1.03, you definitely have to |
---|
[887] | 143 | upgrade you Quota Storage Database. Please read the documentation |
---|
| 144 | included in the initscripts subdirectory first ! |
---|
| 145 | |
---|
[1034] | 146 | Users of MacOS-X may find the following tutorial useful : |
---|
| 147 | |
---|
| 148 | http://ell-tech.com/pages/pykota.php |
---|
| 149 | |
---|
[714] | 150 | Prerequisite : |
---|
| 151 | -------------- |
---|
| 152 | |
---|
| 153 | You need to have the following tools installed on the CUPS Server : |
---|
| 154 | |
---|
[952] | 155 | - CUPS or LPRng |
---|
[809] | 156 | - Python v2.1 or above |
---|
[714] | 157 | - eGenix' mxDateTime Python extension |
---|
[919] | 158 | - SNMP tools (specifically the snmpget command) if you plan to |
---|
| 159 | request your printer's lifetime page counter via SNMP. |
---|
| 160 | - Netatalk (specifically the pap command) if you plan to |
---|
| 161 | request your printer's lifetime page counter via AppleTalk. |
---|
[1043] | 162 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
| 163 | libraries if you plan to use PostgreSQL as the Quota Storage |
---|
| 164 | backend. |
---|
| 165 | or |
---|
| 166 | - python-ldap Python module and the OpenLDAP client libraries |
---|
| 167 | if you plan to use OpenLDAP as the Quota Storage backend. |
---|
[714] | 168 | |
---|
| 169 | You need to have the following tools installed on the Quota Storage |
---|
| 170 | Server : |
---|
| 171 | |
---|
| 172 | - PostgreSQL |
---|
| 173 | |
---|
[1043] | 174 | or |
---|
| 175 | |
---|
| 176 | - OpenLDAP |
---|
| 177 | |
---|
[1086] | 178 | NB : |
---|
| 179 | |
---|
| 180 | PygreSQL must be linked with the PostgreSQL client libraries on |
---|
| 181 | the Print Server. The PostgreSQL client libraries' version must |
---|
| 182 | match the PostgreSQL version used on the Quota Storage Server. |
---|
[714] | 183 | |
---|
[1043] | 184 | or |
---|
| 185 | |
---|
[1086] | 186 | python-ldap must be linked with the OpenLDAP client libraries on the |
---|
| 187 | Print Server. The OpenLDAP client libraries' version must match the |
---|
| 188 | OpenLDAP version used on the Quota Storage Server. |
---|
[1043] | 189 | |
---|
[714] | 190 | This list of prerequisite software may change in the future, when |
---|
| 191 | PyKota will support more functionnalities you will be given |
---|
| 192 | alternatives. |
---|
| 193 | |
---|
[952] | 194 | Of course the Print Server and the Quota Storage Server can be the |
---|
[851] | 195 | very same machine if you've got a tiny network, or you can have |
---|
[952] | 196 | multiple Print Servers all storing their quotas on the same Quota |
---|
[851] | 197 | Storage Server if you've got a bigger network. |
---|
| 198 | |
---|
[714] | 199 | Then : |
---|
| 200 | ------ |
---|
| 201 | |
---|
[724] | 202 | Download the latest PyKota version from the CVS tree on : |
---|
[695] | 203 | |
---|
[725] | 204 | http://savannah.nongnu.org/projects/pykota |
---|
[695] | 205 | |
---|
[714] | 206 | Just type : |
---|
[695] | 207 | |
---|
[725] | 208 | python setup.py install |
---|
[695] | 209 | |
---|
| 210 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
| 211 | |
---|
[878] | 212 | The installation script will now automatically check if some software |
---|
| 213 | is missing and ask you if you still want to proceed with the |
---|
| 214 | installation or abort it completely. |
---|
| 215 | |
---|
[695] | 216 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
| 217 | the appropriate storage backend for your configuration. Read |
---|
| 218 | the associated README file and execute the initialization script |
---|
[878] | 219 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
| 220 | provided as well. |
---|
[695] | 221 | |
---|
[1107] | 222 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
| 223 | sample configuration files to /etc/pykota/pykota.conf and |
---|
| 224 | /etc/pykota/pykotadmin.conf. The installation script tries to do this |
---|
| 225 | for you if needed and you agreed to this action. |
---|
| 226 | You need to adapt these files to your own needs. |
---|
[1015] | 227 | Especially you have to create sections named after your own |
---|
| 228 | printers, and change the administrator's email address. |
---|
[695] | 229 | |
---|
[952] | 230 | - CUPS Print Backend : |
---|
| 231 | |
---|
| 232 | Modify the PPD files for each printer on which you want to manage |
---|
| 233 | print quotas, for example /etc/cups/ppd/lp.ppd : |
---|
| 234 | |
---|
| 235 | --- Add the line below exactly as-is somewhere near the top --- |
---|
| 236 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
| 237 | --- Add the line above exactly as-is somewhere near the top --- |
---|
| 238 | |
---|
| 239 | Modify the path to the pykota executable if needed, unfortunately |
---|
| 240 | you have to supply the correct absolute path here due to CUPS |
---|
| 241 | internals, or put the pykota executable into /usr/lib/cups/filter |
---|
| 242 | instead of into /usr/bin. |
---|
| 243 | |
---|
| 244 | Do this for each ppd file present in this directory if you want |
---|
| 245 | to enable quota on every printer. |
---|
| 246 | |
---|
| 247 | WARNING : In the case you've got a non-postscript printer, chances |
---|
| 248 | are that the *cupsFilter is already filled-in and points |
---|
| 249 | to cupsomatic or such a print filter. In this case please |
---|
| 250 | check if you can switch your printer to PostScript mode |
---|
| 251 | or if there's a way to make it accept PostScript jobs. |
---|
| 252 | If yes then ensure that your workstations uses a PostScript |
---|
| 253 | printer driver, and replace the *cupsFilter line with the |
---|
| 254 | one pointing to the pykota filter. This should work, but |
---|
| 255 | is currently untested. |
---|
| 256 | If your printer really needs the original *cupsFilter line |
---|
| 257 | then you may not be able to use PyKota easily for now. |
---|
[695] | 258 | |
---|
[952] | 259 | - LPRng Print Backend : |
---|
| 260 | |
---|
| 261 | Modify the /etc/printcap file to add two lines identical to these ones : |
---|
| 262 | |
---|
| 263 | :achk=true |
---|
| 264 | :as=|/usr/bin/pykota |
---|
| 265 | |
---|
| 266 | For each printer on which you want to use print accounting. |
---|
| 267 | |
---|
[716] | 268 | Add printers and users to the quota system and set their quota values : |
---|
[695] | 269 | |
---|
[1086] | 270 | $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN |
---|
[724] | 271 | |
---|
[725] | 272 | launching edpykota without any argument or with the --help |
---|
| 273 | command line option will show you all the possibilities. |
---|
[1086] | 274 | |
---|
| 275 | by default, each user is limited by "quota", this means that on |
---|
| 276 | each printer he can have a different soft and hard limit. |
---|
| 277 | You may want to limit the user by his account balance value, |
---|
[1107] | 278 | in which case, the print quota is shared between all printers |
---|
[1086] | 279 | instead of being different. To do this, use the following : |
---|
| 280 | |
---|
| 281 | $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN |
---|
| 282 | |
---|
| 283 | This will put 10 $ (or Euros, PyKota doesn't care) on each user's account |
---|
| 284 | balance, and tell PyKota to limit them by their account balance value. |
---|
| 285 | Whenever they print on any printer, their account balance value is |
---|
| 286 | decreased by an amount which depends on the particular price per page |
---|
| 287 | and per job that you may have defined on the printer with edpykota's |
---|
| 288 | --charge command line option. |
---|
[1107] | 289 | Soft and Hard limits are not used if "--limitby balance" is used, |
---|
| 290 | but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf |
---|
| 291 | to obtain a similar result (warning message when quota is low). |
---|
[695] | 292 | |
---|
[990] | 293 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
[695] | 294 | |
---|
[725] | 295 | $ /etc/init.d/cupsys restart |
---|
[990] | 296 | |
---|
| 297 | or : |
---|
| 298 | |
---|
| 299 | $ /etc/init.d/lprng restart |
---|
[695] | 300 | |
---|
| 301 | Your users now should be able to print but not exceed their |
---|
| 302 | printing quota. |
---|
| 303 | |
---|
[1149] | 304 | To see printer quota usage, you can use : |
---|
[794] | 305 | |
---|
| 306 | $ repykota --printer lp |
---|
| 307 | |
---|
| 308 | or : |
---|
| 309 | |
---|
| 310 | $ repykota |
---|
| 311 | |
---|
| 312 | which will print quota usage for all users on all printers, |
---|
[1107] | 313 | along with totals, if you are the root user. If you are |
---|
| 314 | a regular user, only your own quota report will be produced. |
---|
[794] | 315 | |
---|
[1107] | 316 | Quota reports are also available remotely by using the CGI script |
---|
| 317 | printquota.cgi provided in the cgi-bin/ subdirectory. |
---|
[990] | 318 | |
---|
[980] | 319 | For different security concerns, please give a look at the SECURITY |
---|
| 320 | file which is part of this software. |
---|
[741] | 321 | |
---|
[695] | 322 | ============================================================ |
---|
| 323 | |
---|
[958] | 324 | Mailing list : |
---|
| 325 | -------------- |
---|
| 326 | |
---|
| 327 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
| 328 | or consult its archives at : |
---|
| 329 | |
---|
| 330 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
| 331 | |
---|
| 332 | ============================================================ |
---|
| 333 | |
---|
[1107] | 334 | Please e-mail bugs to the mailing list at : pykota@librelogiciel.com |
---|
| 335 | or to the main author at : alet@librelogiciel.com (Jerome Alet) |
---|