printer accounting

Seth Vidal skvidal at
Fri Sep 25 18:49:03 GMT 1998

>Date: Wed, 23 Sep 1998 21:40:38 -0500
>From: "Daryl L. Biberdorf" <darylb at>
>To: samba at
>Subject: Pages printed
>Message-ID: < at>
>We have the need to track printer usage (pages used).
>Right now, my Samba printer share defines the print command
>as "print command = lpr -r %s"
>(The printer is a LaserJet 4000N, with the JetDirect card and
>its built-in LPD server.)
>What is the best way to figure out how much paper a given 
>user printed?
>Daryl Biberdorf         darylb at

Hi daryl,
	ok here's the problem. The number of pages printed is a pain b/c
nothing knows that until the printer's has finished. you can setup a
print command to log the file size the user printed and you can do some
guestimations on that but if you are using samba as a printing pass thru
(meaning your lpd just redirects to the lpd of the hp4000N) then there
aren't many good ways of knowing how much someone is printing.

if you are using linux there might be one way to do it.

there is a program called npadmin. (it's available under the GPL from cisco)
It can get the pagecount number from the printer (direct over snmp)
you can set up a script that gets the current num of pages printed, then
gets prints the doc, then gets the num of pages printed and subtracts b/t
the two to check how many pages were printed. The reason this will work is
that the lpd on the hp only allows 1 connection at a time. So you do all
this work at one point. You may have to play around with delays and such but
I see no reason why it shouldn't work.
it would look at little like this.

BEFOREPAGES=`npadmin --pagecount {printer ipaddress)`
lpr -Pprintername -r %s
AFTERPAGES=`npadmin --pagecount {printer ipaddress)`

then you echo out TOTAL with usersnames etc etc to a log (with logger

that should help somewhat.

good luck


More information about the samba mailing list