A Print Quota Scheme
Yao-Chiang Kan, Jackie Carlson, and Jen-Sheng Wang
Reducing the cost of printer maintenance is usually an important issue for any organization, but is particularly so at a university. The cost of our printing supplies (paper and toner) reached a high last year of $40,000 at the College of Engineering at Michigan State University, and we were asked to implement print quotas for both UNIX and PC systems. This article explores that system and should provide techniques that can be applied to your environment, too.
We needed to enforce print quotas without increasing costs and purchasing expensive software. With a few modifications to the interface files and a couple of scripts, we accomplished our goals. We implemented print quotas for our printers in public labs almost a year ago and have since reduced wear and tear on the printers and reduced toner, paper, and repair costs by 40%. The print quota scheme we designed is cost effective and simple to administer.
In our computing environment, we deal with several different platforms: SUN Solaris, HP-UX 10.x, Windows NT, Windows 95, and Windows for Workgroup 3.11. We configured a SUN Sparc10 running Solaris 2.5.1 to be the print quota server for the UNIX labs and office printers. A SUN Sparc2 running Solaris 2.5.1 is the print quota server for four of our public PC labs. The Windows NT print clients talk to the print server using Microsoft's TCP/IP printing. PCs running Windows for Workgroups use the PCTCP lpr function to directly communicate with the Solaris print server. The UNIX print clients send print jobs to the print server by using SYS V printing.
There are eight quota-enabled printers including six HP 4MV printers, one HP 5SI/MX printer, and one QMS color laser printer. All HP 4MV and 5SI/MX printers support a function called "True End of Job (TEOJ)" that causes the HP printers to return a page printed status message for a print job. The QMS printer has the "Background Channel (BC)" function, which is similar to HP's TEOJ. By using TEOJ and BC functions, our print quota system is established.
The Print Quota Scheme Knowing how to set up a UNIX print server running Solaris is required, of course. A local printing process on Solaris is described in Figure 1. When a print job arrives on the print server, lpsched is evoked to handle that print job. lpsched is responsible for spooling the print request, filtering the job, and starting the interface program to actually print the job. Printer filters in Solaris are used to convert the content type of a file to a content type that is acceptable to the destination printer. The Solaris interface program does the final printing of the job and is the most important stage of the printing process. Our print quota scheme is implemented within the interface program.
The print quota scheme requires four special files shown in Listing 1. (All listings for this article can be found at ftp.mfi.com in /pub/sysadmin.) The first file is a user print quota database (UPQdB), which has a file named the same as the user name. Every user has his or her own UPQdB file. The UPQdB contains several fields that are separated by colons. The first field in UPQdB is the user's print quota, the second one is total pages printed since the beginning of the semester, and the third field is pages printed in the current week. The rest of those fields are pages printed for each quota-enabled printer in the current week. The order of these printer fields is determined by the printer list file (PLF). The second file is the PLF, which stores a list of all quota-enabled printers. The third file stores the default quota (DQF) for all users. The last file is a user print-credit file (UPCF), which stores a user's purchased print quota left from the previous semester. Below is the process used to enforce user print quotas.
Steps of the interface program:
- Check the username against the NIS+ password table and filter out users who should not print, such as root.
- The user's UPQdB is created at the time the user first sends a print job to the printer. The print quota is the sum of the default quota and the purchased quota left from the previous semester.
- Check user's print quota and total pages printed from UPQdB.
a. If a user is over quota, exit from the interface program and notify the user via email.
b. If a user is not over quota, determine which printer is being used according to the PLF and enter (in the field assigned to this particular printer) the number of pages printed, then update the total pages printed in the UPQdB.
Steps of the cron job:
- Report users' print usage weekly, re-initialize each printer's field to zero in the database, and reset the weekly pages printed to zero.
- If a user has purchased additional pages, then the UPCF is created, and the UPQdB is removed. If a user does not have any quota remaining, then the only step is to remove the UPQdB. This happens at the start of every new semester.
Steps to increase a user's quota:
- Purchase a token from the MSU bookstore or provide a departmental account number to be charged for the quota increase.
- A single token is good for the additional printing of one hundred pages.
- Use the script my_quota to view disk and print quota usage information.
- A support consultant can also increase a user's print quota by multiple of 100.
The Implementation
Set Up a Print Quota Server The JetAdmin software for Solaris provides an interface file that utilizes most of the HP printers' functions. The JetAdmin software can be downloaded from Hewlett Packard's Web site:
http://www.hp.com/cposupport/indexes1/a.html
You can obtain the QMS UNIX host software from the QMS Web site:
http://www.qms.com/support/drivers/ \ drivers-list.html?platform=UNIX
To install the JetAdmin software on a system running Sun's Solaris, use the command pkgadd. Qinstall, which is included with the QMS software, can be used to install QMS.
After QMS and JetAdmin have been installed, a printer queue can be set up using the utilities bundled with these packages. To install HP printers run jetadmin and follow the menu to configure a printer queue. For QMS printers, run addprt to add a printer queue. Remember to enable TEOJ and status log in the HP printer queue configuration and enable the BC function as part of the QMS printer configuration. After the queue has been installed, we can get the desired interface file from /etc/lp/interfaces/xxx, where xxx is the name of the print queue. From here on, these queues will not be necessary. They can be left there or deleted.
Since the interface files are written in Bourne and Korn shells, a Bourne shell library was created to accomplish the print quota scheme. Listing 2 shows the library, PrnQt_lib.sh, with the functions needed to use print quotas. In this library, the location of UPQdB, PLF, DQF, and UPCF are specified by variables, UserPrnQtFile, PrnterListFile, GenPrnQtFile, and UserLeftQt, respectively. The Usermatch() function is used to verify a user against the NIS+ password table. The InitUserPrnQtFile() function initializes a user's UPQdB and adds the user's page credit into the user's UPQdB. The ChkPrnQt() function first checks the PLF for a new printer and then determines whether a user is over quota. This function also allows administrators to add a new quota-enabled printer at any time without being concerned with any inconsistencies of the user's UPQdB. The UpdatePrnQtFile() updates UPQdB. This function takes two arguments. We like to map one color page printed to be equivalent to printing 20 black-and-white pages. Thus, the first argument is the number of physical page printed, and the second is the cost equivalent of single pages printed. A print server might be a machine in the lab and a user might log on at the console or even remotely; thus, the evoked interface program, which runs UpdatePrnQt, will be owned by the person logged onto the print server. Thus, a C wrapper is needed to update the user quota file, which is owned by lp. This C program is listed in Listing 3, updatPrnQT.c.
The next step is to find a place in the interface program to put PrnQt_lib.sh. Listing 4, model.QMS, is an example of a modifed interface file for a QMS color printer. This modified interface file updates UPQdB after every page printed. The interface file for the HP printer has two parts, one is under /etc/lp/interfaces, and the other is under /etc/lp/interface/model.orig. The first part deals with some settings; the second is the core program, which deals with the print jobs and is invoked by the first part. The library and modification go into the first part of interface program, which is listed in Listing 5, model.HP4MV. Listing 5 shows only the modified or the important portions of the program; the complete program is too large to include entirely. This modified interface file updates UPQdB after a print job is finished. The modifications of these two interface files can be classified as follows:
- Set variables and add /etc/lp/interfaces to PATH so that the library, PrnQt_lib.sh under /etc/lp/interfaces, can be found.
- Convert username to lowercase, since the username passed from Microsoft Windows systems is in uppercase.
- Include the PrnQt_lib.sh.
- Check user.
- Check user's print quota.
- Read pages printed.
- Update user's print quota file.
After modifying the interface program, we need to set up the print server with this modified interface program. The procedures for setting up a UNIX system running Sun's Solaris to be a print server are summarized below. (More details can be found in the System Administration Guide in Sun's Solaris Answerbook.)
- Initialize the Print Server.
a. Configure the port monitor.
b. Register the network listen service.
- Add print filters to the print server using the lpfilter command.
- Add print queues to the print server. The -i option is used to establish a new interface program. Two examples are provided below:
For HP printers:
mknod $/dev/eb119_ps1 c 13 2
/usr/sbin/lpadmin -peb119_ps1 \ -v/dev/eb119_ps1 -imodel.HP4MV
For the QMS printer:
/usr/sbin/lpadmin -peb120_colorps \ -v/dev/null -imodel.QMS
The model.HP4MV and model.QMS are the modified interface programs above. For HP printers, make sure that the second interface file is under /etc/lp/interfaces/model.orig. The filename should be named the same as the printer name.
- Configure that printer to accept print requests and enable the printer.
The last step in setting up the print quota server is to add the usage report script, shown in Listing 6, to the cron jobs. The command crontab -e is used to edit the cron table on that server. This script only needs to be added on the server that exports the UPQdB partition to other servers.
Set Up Printer Clients For Solaris clients, use the following commands to set up the printer:
a. /usr/sbin/lpsystem -t s5 ${PrinterHost}
b. /usr/sbin/lpadmin -p ${Printer} -s ${PrinterHost} -I any
c. /usr/sbin/accept ${Printer}
d. /usr/bin/enable ${Printer}
where ${Printer} is the name of the printer to be set up, and ${PrinterHost} is the name of print server.
For HP client, use the following commands to set up the printer:
a. /usr/lib/lpadmin -p${Printer} -v/dev/null -mrmodel \ -ocmrcmodel -osmrsmodel -ob3 -orm${PrinterHost} \ -orp${Printer}
b. /usr/bin/enable ${Printer}
c. /usr/lib/accept ${Printer}
For Microsoft Windows NT, follow the procedures below:
a. Open 'Network' in 'Control Panel'.
b. Click on 'Service' tab and install 'Microsoft TCP/IP Printing' service.
c. Reboot the machine.
d. Click 'Add New Printer in Printer' under 'My Computer'.
e. Choose 'My Computer' and click 'Next'.
f. Click 'Add New Port', highlight 'LPR Port', and click 'Add New Port'.
g. Type the name of the print server in the 'lpd Server' field and type the name of the printer in the 'Printer Name' field.
h. Click 'OK' and then 'Close'.
i. Click 'Next' then follow the instructions on the screen.
For Windows 95, the program "Windows LPR Spooler" by Thomas Heil is used. Check http://ich210.ich. \ kfa-juelich.de/wlprspl/ if you need to download that software. Summary setup procedures follow:
a. Open the Windows LPR Spooler after that software is installed.
b. Go to 'Define new queue' under the 'Queue' submenu under the 'Setup' menu.
c. Type the spool file name in the 'LocalSpool File Name' field. If you do not change the default spool directory, this file will be created as c:\Temp.SPL.
d. Enter the quota-enabled printer name in the 'Remote Printer/Queue Name' field.
e. Type the name of the print server in the 'Remote Host Name or IP Address' field.
f. Type anything you want in the 'Queue description' field.
g. Choose 'BSD LPR/LPD Protocol' in the 'Protocol to be used' field.
h. Go to 'Printers' under 'My Computer' on the Windows 95 desktop.
i. Click 'Add Printer', choose 'Local Printer', and select the correct printer manufacturer and model.
j. Choose the port that will be the file name that you typed in Step c above.
k. Follow the instructions on the screen and finish adding a printer.
For Windows for Workgroups with PCTCP installed:
a. Install the PCTCP by running the install program.
b. You can set up the lpr printer by using 'PCTCP Network Control' in PCTCP group or edit the pctcp.ini directly. Open pctcp.ini, and add or modify the following in the pctcp.ini file.
[pctcp idrive-restore]
LPT1:=\\printer_server\printer_name lpr
c. Users will need to log on with their username and password before printing a job, since our interface program will filter out non-authorized users. Use the idnet command under DOS to set the username and password or use 'Network' in the 'Control Panel' to log on.
The Responsibilities
User Users need to be able to check their current pages printed. The script, shprnqt, in Listing 7, is used to show the current number of pages printed and print quota. In our current configuration, the partition, /PrnQt, is exported to every SUN and HP workstation. This configuration makes the script, shprnqt, very simple. Another reason to share /PrnQt is because this partition contains all installation scripts necessary to install both SUN and HP printer clients. At this point, users can only check their print quota from a UNIX system.
Consultant Consultants need to be able to increase a user's print quota if a user purchased a token or provides a department account. Listing 8 shows that script. A wrapper program, Listing 9, is needed to allow consultants to change a user's quota. The permissions of that script should be set to 755. The permissions of the wrapper program should be set to 4750 and owned by lp and group by consultant.
Administrator The administrator needs to edit the variable $Rdate in the usage report script, Listing 6, and modify it to be the date at the start of a new semester. The administrator must also maintain the quota-enabled printer list and default quota.
Conclusion Although we consider this print quota scheme to be a work in progress, it works well and has saved us money. Print quotas have stopped the abuse of our printers. Users are paying more attention to both what and how much they print. The scheme itself can be refined and improved. Our future modifications will focus on the following:
- Allow Microsoft Windows users to check their print quota without having to log on to a UNIX machine. This can be done by using ONC RPC for Windows NT ported by Martin F. Gergeleit.
- The script used by consultants to increase a user's quota should be able to be run on PC by using ONC RPC for Windows NT, so consultants don't need to log on to a UNIX machine first.
- The modified HP interface file in Listing 5 counts pages printed after a job is finished. The counting program can be moved to the second interface file in order to count page by page.
About the Author
Yao-Chiang Kan was a System/Network graduate assistant for the Division of Engineering Computing Services (DECS) at Michigan State University (MSU) for the past three and a half years. He works on Electromagnetics research now and can be reached at kan@egr.msu.edu.
Jackie Carlson is the manager of the System/Network in DECS at MSU. You can contact her at carlson@egr.msu.edu.
Jen-Sheng Wang is a System/Network graduate assistant for DECS at MSU, and his email address is wangjins@egr.msu.edu.
|