全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2228
推到 Plurk!
推到 Facebook!

print quota 程式來管制彩色列表

 
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-05-14 02:11:57 IP:218.175.xxx.xxx 未訂閱
print quota 程式來管制彩色列表 http://www.cse.ohio-state.edu/~rowland/projects/pquotad/pquotad.html     
Pquotad: The LPRng print quota daemon
Shaun M. Rowland    May 3, 2001    What is pquotad? 
Pquotad is an extension to the LPRng printing system that implements a network based page counting system. To put it simply, pquotad is a glorified network front end to a user page count SDBM database file. The tools included with pquotad allow one to:     Create a page count database based on group and individual user quota configurations. 
Add users to the database. 
Remove users from the database. 
Set a user's quota to a specific value. 
Increase a user's quota. 
Decrease a user's quota.     How does pquotad work? 
Pquotad will work with any printing system in which one can make a print filter level decision on whether a print job should succeed or fail based on a value queried from pquotad. This is no small feat. In fact, this is the most difficult part of implementing printer quotas. Pquotad was written with LPRng in mind because it is easy to incorporate into the print job accounting system. The basic sequence of events is show in Figure 1.     
Figure 1: Basic Printing Sequence    If the printing system can make decisions in the accounting script then the pquotad tools can be used to make those decisions. Once a file is printed the accounting system can update the pquotad database with the number of pages printed. Sounds simple right? Well, it most certainly is not simple. This is most of the work. The pquotad package provides the network aware page counter and the client tool which can be hacked into an accounting script allowing that script to make a decision. This document does not go into great detail about how to incorporate pquotad into a printing system, but it does give an example based off of the OSU-CIS printing system which at this time is a slightly out of date LPRng installation. Hopefully this will give an idea of how to incorporate pqutoad into other printing systems.     The pquotad package 
The pquotad package contains a number of utilities. There is much more than the simple page counting daemon itself. We do not use all of the package in the OSU-CIS printing system at this time. Some of the actions required to set up pquotad are automated in our system, but I have included all the files necessary to get pquotad going from scratch on a Unix system. Installing pquotad on NT, or any printing system on NT for that matter, is strongly discouraged as far as I am concerned. The pquotad package components are outlined in the same order as they will probably be used.     create_pquota_database: Creating the database 
The create_pquota_database program is used to build an initial print quota database. It can also be used to rebuild/reset the print quota database after each quarter or semester. This program reads two configuration files:     default-quotas 
The group based print quotas. Each group is given a print quota and the user gets the largest print quota their group memberships will allow. 
real-quotas 
The user based print quotas. An individual user will get the print quota defined here regardless of what their group based print quota gives them. 
The create_pquota_database program looks at every user on the system and gives them the appropriate print quota. The users get the highest print quota their group memberships allow. If an individual is defined in the real-quotas file they get that print quota amount regardless of what their group memberships are. This program is run in the pquotad installation (or $root_dir) directory.     pquotad: The daemon 
The pquotad program is a forking server that answers queries and performs the print quota database administration tasks. This daemon is the front end to the print quota database. Most actions on the print quota database are the result of a network aware client talking to pquotad with the print quota network protocol. The parent process listens for incoming connections while the client process performs the database reads or writes. These actions are done with proper file locking to ensure that the database does not become corrupted as multiple pquota server hits occur.     print-quota: The print quota query client 
The print-quota client program simply queries a user's quota. It is used in the first lpd accounting action in Figure 1. The results are displayed as:     [rowland@gold rowland]$ print-quota
Username        Base Quota            Current Quota
rowland         unlimited             unlimited    A username can be specified on the command-line. If no username is specified the user running the script is used for the query. Currently the accounting script must parse this output to find out what the user's current print quota is. This is the last value on the second line of output. Someday there will be a command-line option to just return a number. The current printer quota can be found with something like: 
print-quota username |grep -v Current |awk '{print $3}'    in a shell script at this time. The accounting script we use is written in Perl, so this is cleaner if not simpler to accomplish. I do plan on changing this someday, but as in many situations I just do not have the time at the moment.     pqadmin: Administer the print quota database 
The pqadmin program is the administrative interface to the print quota database. This program can be run interactively or with a number of command-line options, and it communicates with pquotad through the print quota network protocol. It is used in the second lpd accounting action in Figure 1. The pqadmin client implements the following actions:     add 
Add a user to the pquota database. 
remove 
Remove a user from the pquota database. 
set 
Set a user's current print quota to a specific value. 
increase 
Increase a user's current print quota. 
decrease 
Decrease a user's current print quota. 
The print quota network protocol is very simple and passes over the network in clear text. The assumption is that the network is secure and that print quota information is not absolutely critical. A command is sent over the network following the protocol. This is followed by an administrative password in all cases except the query command used by print-quota. It would not be overly difficult to modify the protocol to make it more secure, but in many situations including ours this is unnecessary.     PQuota.pm: Where all the work happens 
The PQuota.pm Perl module implements the print quota API. Most of the work is done here. This Perl module is well documented with POD.     Miscellaneous programs 
The following programs are also part of the pquotad package. They do a number of tasks:     page_count 
This shows the number of pages a user printed. This information is taken from the pquotad log file and represents the pages counted as recorded over the period of time the log file has existed. 
print_pquota_database 
This prints the contents of the pquota.dat.* files. This needs to run in the pquota.dat.* directory. 
user_averages 
This prints the average number of pages printed above a certain number of pages printed. The page limit restriction cuts down on the number of entries counted. This needs to run in the pquota.dat.* directory. 
pquotad.sh 
A sample init.d start/stop script.     How do I use this with LPRng? 
This is by far the hardest part of the entire process, and the part I least document for that reason. There are a number of ways to tie pquotad into a printing system, and there are many other things which can be done, such as group based restrictions, that are beyond the scope of this document. I have worked with LPRng enough to write a book on this particular topic. Maybe someday that will become a reality, but here I can give some pointers as to how we accomplished print quota integration bearing in mind that our LPRng installation is not very up to date. In fact, I have updated our source code manually on at least one occasion. The information here should work with the newest LPRng installation. Consult the documentation which comes with LPRng when considering the information here.     Turning on accounting 
Each printer on our system has an /etc/printcap file entry on our main file server. Here is an example (the lp entry is actually different of course):     lj_dl_772_a|lj_dl_772|lj772|lj772a
:lp=111.222.333.444‘00
:rw
:sf
:fx=flpv
:sd=/export/0/spool/lpd/lj_dl_772_a
:as=|/usr/local/lprng/lib/filters/accounting.pl start
:ae=|/usr/local/lprng/lib/filters/accounting.pl end
:bp=/usr/local/lprng/lib/filters/cis_banner.sh
:if=/usr/local/lprng/lib/filters/ifhp -Tmodel=hp4simx
:of=/usr/local/lprng/lib/filters/ofhp.sh -Tmodel=hp4simx
:vf=/usr/local/lprng/lib/filters/ifhp -c -Tmodel=hp4simx
:lf=/export/0/spool/lpd/logs/lj_dl_772_a
:ps=/export/0/spool/lpd/logs/lj_dl_772_a.status
:af=/export/0/spool/lpd/logs/lj_dl_772_a.acct    The print job accounting information is stored in the lj_dl_772_a.acct file. The accounting.pl script is run before and after each file is printed. The accounting.pl script can stop a job before it is printed due to lack of print quota and at the end of a job decrease the user's quota by the appropriate amount. I have included our accounting.pl script for reference.     The START and END sections 
The print-quota program is used in the START section. If there is not enough print quota the print job is aborted. The accounting.pl script is fairly straight forward. To remove a job from the print queue one simply does exit $JREMOVE;. The pqadmin program is used in the END section. It decreases the user's quota by the amount of pages they printed. The accounting.pl script is avaliable as an example with the LPRng package (and assosicated print filters). The pqadmin package should be integrated into the example account.pl script. Note that our example accounting.pl script could do with a lot of improvement, but again the time factors have not allowed for this, especially since some Perl modules were not available at the time. It does work however.     About this document ... 
Pquotad: The LPRng print quota daemon
This document was generated using the LaTeX2HTML translator Version 99.2beta8 (1.46)     Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds. 
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.     The command line arguments were: 
latex2html -split 0 pquotad.tex     The translation was initiated by Shaun Rowland on 2001-05-06         
系統時間:2024-05-04 19:29:33
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!