Operating System - HP-UX
1833170 Members
3450 Online
110051 Solutions
New Discussion

Re: Printer Queue Management - recording usage stats

 
SOLVED
Go to solution
TheJuiceman
Super Advisor

Printer Queue Management - recording usage stats

Hi everyone!!!

I was just wondering if anyone has any suggestions for monitoring printer activity (such as recording the number of print jobs, recording user activity on a printer, recording byte count, etc). I know there are a lot of packaged software available to manage queues, but I would rather keep it simple (and cheap LOL). Has anyone written any scripts they would be willing to share? Any thoughts?

As always, thank you all for the help!!!

Bobby
11 REPLIES 11
A. Clay Stephenson
Acclaimed Contributor

Re: Printer Queue Management - recording usage stats

It should be rather simple to add a line or two to every interface file in /var/spool/lp/interface. Byte coults are easy when the lp command is given a regular file but you will also have to detect when lp is fed from a pipe and basically cat to a temp file and then do a byte count of the temp file and send the temp file to the printer. I'm glad you didn't mention pages because with modern printers (eg Laserjets) page breaks only have meaning to the print device.

Plan B. If these are all Laserjets, you might instead query the printers themselves for statistics periodically rather than relying upon the lp subsystem.
If it ain't broke, I can fix that.
Sam McKnight
Frequent Advisor

Re: Printer Queue Management - recording usage stats

Following up on Clay's suggestions:

In my browser, I have bookmarked my hp2600 inkjet network printer. At the end of the year and after each ink cartridge and printhead replacement, I print a usage report. I also get the same reports from a lj4m printer but I have to go to the printer to get it since the information is not available on the network.

You do not get user information this way but you can keep up with the printer pretty well.
Geoff Wild
Honored Contributor

Re: Printer Queue Management - recording usage stats

Use mrtg...

Fron cron I run:

# mrtg
3,8,13,18,23,28,33,38,43,48,53,58 * * * * [ -d /var/adm/lp/XEBEC ] && /usr/local/bin/mrtg-stats >/dev/null 2>&1


# cat /usr/local/bin/mrtg-stats
#!/bin/sh
# generate mrtg file for stats
SERVER=`uname -n`
MRTGLP=/tmp/iprprt.lp.stats.mrtg
mv /tmp/LPSTATCUR /tmp/LPSTATOLD
LPSTATOLD=`cat /tmp/LPSTATOLD`
LPSTATCUR=`/usr/bin/grep End /var/adm/lp/log |wc |awk '{print $1}'`

echo $LPSTATCUR>/tmp/LPSTATCUR

LPSTATNEW=`expr $LPSTATCUR - $LPSTATOLD`

echo $LPSTATNEW > $MRTGLP
echo 0 >> $MRTGLP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGLP
echo $SERVER >>$MRTGLP


MRTGFTP=/tmp/prodbci.ftp.stats.mrtg
mv /tmp/FTPSTATCUR /tmp/FTPSTATOLD
FTPSTATOLD=`cat /tmp/FTPSTATOLD`
FTPSTATCUR=`/usr/bin/grep FTP /var/adm/syslog/syslog.log |wc |awk '{print $1}'`

echo $FTPSTATCUR>/tmp/FTPSTATCUR

FTPSTATNEW=`expr $FTPSTATCUR - $FTPSTATOLD`

echo $FTPSTATNEW > $MRTGFTP
echo 0 >> $MRTGFTP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGFTP
echo $SERVER >>$MRTGFTP

Then, from the server where mrtg is running, grab those files...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
TheJuiceman
Super Advisor

Re: Printer Queue Management - recording usage stats

Clay, Thanks for the input (as always!!!). Since I have 200 printers to keep up with, going around to each one is really something I don't want to do if I can help it. We are also wanting to get data on a "per server" usage. Any thoughts?

Sam, thanks for the suggestion, but checking printers is really something I want to avoid.

Geoff, interesting script. However, could you decipher some of it for me? For example I don't understand the mrtg file where the first line is a list of numbers. I am also assuming that XEBEC is your printer. Sorry if I seem a bit dumb with this, but unfortunately scripting is not my strength.

Thanks everyone for the help.
Geoff Wild
Honored Contributor
Solution

Re: Printer Queue Management - recording usage stats

The "[ -d /var/adm/lp/XEBEC ] && " in cron just checks to see if the directory /var/adm/lp/XEBEC exists - I do that cause my print spool is in a MC/SG cluster....so you can drop that part...

The mrtg file - the first line is the number of print requests the last 5 minutes...

The 0 is a place holder (required by mrtg)...

I'm not at work right now - but if you want - I can post my mrtg.cfg file...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
A. Clay Stephenson
Acclaimed Contributor

Re: Printer Queue Management - recording usage stats

I never suggested that you visit each printer to gather statistics. My idea would be to use a Web scraper to gather the data from each printer. Note that HP printers (the newer ones at least) have built in web servers and actually gather the statistics you are interested in.
If it ain't broke, I can fix that.
TheJuiceman
Super Advisor

Re: Printer Queue Management - recording usage stats

Geoff,

Any info you can give on how you have this set up I greatly appreciate!!!

Clay,

Unfortunately we have a ton of old printers here. Like I said we work on a shoe-string budget with printing. I need a way to incorporate older printers too.

Thanks you guys for the help!!!
Geoff Wild
Honored Contributor

Re: Printer Queue Management - recording usage stats

Well, after you install mrtg, add this to you mrtg.cfg file:



#------------------------------------------

Target[iprprt.lp]: `cat /tmp/iprprt.lp.stats.mrtg`
Options[iprprt.lp]: nopercent,growright,perhour
Title[iprprt.lp]: LP: Spool Requests per hour on IPRPRT
PageTop[iprprt.lp]:

LP: Spool Requests per hour on IPRPRT


MaxBytes[iprprt.lp]: 1000000000
YLegend[iprprt.lp]: reqs/hour
ShortLegend[iprprt.lp]: per hour
LegendI[iprprt.lp]:  Requests:
Legend1[iprprt.lp]: Requests per hour
LegendO[iprprt.lp]:

#------------------------------------------

Target[iprdbci.ftp]: `cat /tmp/iprdbci.ftp.stats.mrtg`
Options[iprdbci.ftp]: nopercent,growright,perhour
Title[iprdbci.ftp]: FTP: Requests per hour on IPR
PageTop[iprdbci.ftp]:

FTP: Requests per hour on IPR


MaxBytes[iprdbci.ftp]: 1000000000
YLegend[iprdbci.ftp]: reqs/hour
ShortLegend[iprdbci.ftp]: per hour
LegendI[iprdbci.ftp]:  Requests:
Legend1[iprdbci.ftp]: Requests per hour
LegendO[iprdbci.ftp]:

#------------------------------------------


I run from cron like so (AIX):

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/mrtg-2/bin/mrtg /htdocs/mambo/mrtg/mrtg.cfg --logging /var/adm/mrtg.log >/dev/null 2>&1

On my test server (HP) I run it like so:

#0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/mrtg /opt/hpws/apache/mrtg/mrtg.cfg --logging /var/adm/mrtg.log >/dev/null 2>&1

All depends where mrtg is installed...

More info on MRTG:

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/

Latest package for MRTG on HP-UX:

http://hpux.ee.ualberta.ca/hppd/hpux/Networking/Admin/mrtg-2.12.2/


Extra: How to monitor HP-UX via snmp and MRTG - add to your mrtg.cfg file:

######################################################################


Target[sha1.myinternaldomain.comcpup]:.1.3.6.1.4.1.11.2.3.1.1.15.0&.1.3.6.1.4.1.11.2.3.1.1.13.0:mycommunityname@sha1.
myinternaldomain.com + .1.3.6.1.4.1.11.2.3.1.1.16.0&.1.3.6.1.4.1.11.2.3.1.1.14.0:mycommunityname@sha1.myinternaldomain.com
Title[sha1.myinternaldomain.comcpup]: CPU Load on sha1.myinternaldomain.com
MaxBytes[sha1.myinternaldomain.comcpup]: 100
Ylegend[sha1.myinternaldomain.comcpup]: CPU Load
ShortLegend[sha1.myinternaldomain.comcpup]: %
PageTop[sha1.myinternaldomain.comcpup]:

CPU Load on sha1.myinternaldomain.com


Options[sha1.myinternaldomain.comcpup]: integer, growright, nopercent
WithPeak[sha1.myinternaldomain.comcpup]: wmy
LegendO[sha1.myinternaldomain.comcpup]: User/System:  
LegendI[sha1.myinternaldomain.comcpup]: Idle/Nice:  
Legend1[sha1.myinternaldomain.comcpup]: Idle/Nice CPU Time
Legend2[sha1.myinternaldomain.comcpup]: User/System CPU Time
Legend3[sha1.myinternaldomain.comcpup]: Maximal Idle/Nice CPU Time
Legend4[sha1.myinternaldomain.comcpup]: Maximal User/System CPU Time

######################################################################

Target[sha1.myinternaldomain.commem]: .1.3.6.1.4.1.11.2.3.1.1.7.0&.1.3.6.1.4.1.11.2.3.1.1.8.0:mycommunityname@sha1.pc
acorp.net
Title[sha1.myinternaldomain.commem]: Memory on sha1.myinternaldomain.com
MaxBytes[sha1.myinternaldomain.commem]: 100000000
Ylegend[sha1.myinternaldomain.commem]: Memory Usage
ShortLegend[sha1.myinternaldomain.commem]:  
PageTop[sha1.myinternaldomain.commem]:

Memory on sha1.myinternaldomain.com


Options[sha1.myinternaldomain.commem]: integer, gauge, growright, nopercent
kilo[sha1.myinternaldomain.commem]: 1024
WithPeak[sha1.myinternaldomain.commem]: wmy
LegendO[sha1.myinternaldomain.commem]: Total:  
LegendI[sha1.myinternaldomain.commem]: Free:  
Legend1[sha1.myinternaldomain.commem]: Free System Memory
Legend2[sha1.myinternaldomain.commem]: Total Available System Memory
Legend3[sha1.myinternaldomain.commem]: Maximal Available System Memory
Legend4[sha1.myinternaldomain.commem]: Maximal Free System Memory


Rgds...Geoff



Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
TheJuiceman
Super Advisor

Re: Printer Queue Management - recording usage stats

Are there any "gotchas" I should be aware of with mrtg with HP-UX 11.i?
TheJuiceman
Super Advisor

Re: Printer Queue Management - recording usage stats

Also, I see that it requires libpng, zlib, and gd. Do you know of any HP ready versions of these? Thanks.
Geoff Wild
Honored Contributor

Re: Printer Queue Management - recording usage stats

No gotchas - should be able to get thos depots on the Porting Centre...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.