- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script to report total print jobs for each q...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2003 11:50 AM
тАО05-30-2003 11:50 AM
Shell Script to report total print jobs for each que
I would like to create a script to run periodically that gives me the total number of print jobs on an HP-UX server, and also the total number of print jobs by printq. There would be a threshold for the total number as well as a threshold for each queue. If a threshold is reached, I want to send an e-mail. If it is exceeded, I want to send a page. Any assistance is appreciated. Thanks for your time.
Mike Kapsak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2003 11:58 AM
тАО05-30-2003 11:58 AM
Re: Shell Script to report total print jobs for each que
As a compromise, you may want to lpstat -a [queue] for each print queue. You'll want to grep for "down" as well as doing the wc -l to check the number of enqueued jobs.
HTH
mark
- Tags:
- lpstat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2003 12:19 PM
тАО06-01-2003 12:19 PM
Re: Shell Script to report total print jobs for each que
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2003 08:09 PM
тАО06-01-2003 08:09 PM
Re: Shell Script to report total print jobs for each que
#! /usr/bin/sh
program="usr_prt"
# purpose: Interface for retrieving HPUX Online Printers Info
# creator: tommy
# date: 14/11/2000
ver="1.0.1"
MESS1="Insert a printer_name (q/Q to quit): \c"
MESS2="Insert an option (q/Q to quit): \c"
while : ; do
clear
echo "#########################################
HPUX Online Printers Info
`date |awk '{print $3"-"$2"-"$6}'` version:$ver
Anytime enter Q/q to quit!!
#########################################
Current Online Printers:
"
lpstat -a |sort
echo ""
echo $MESS1
read PRTID
if test "$PRTID" = "q"
# or "$PRTID" = "Q"]
then
echo ""
exit_code=$?
echo "$program: exiting with status $exit_code"
exit 1
else
if test "$PRTID" = "Q"
then
echo ""
exit_code=$?
echo "$program: exiting with status $exit_code"
echo ""
exit 1
else
RETURN=""
while [ test $RETURN != "yes" ]
do
clear
lpstat -d $PRTID
exit_code=$?
echo "-------SubMenu-------"
echo "T/t : print testprt"
echo "C/c : cancel all jobs"
echo "R/r : reset this printer"
echo "M/m : return to Main Menu"
resp=*
echo $MESS1
read resp
case $resp in
[T,t])
lp -d $PRTID testprt
exit_code=$?
;;
[C,c])
cancel -e $PRTID
exit_code=$?
;;
[R,r])
disable $PRTID
sleep 1
enable $PRTID
sleep 1
lpstat -d $PRTID
exit_code=$?
;;
[M,m])
RETURN="yes"
;;
[q,Q])
echo ""
echo "$program: exiting with status $exit_code"
echo ""
exit 0
;;
*)
echo Invalid Responce
sleep 1
;;
esac
done
fi
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2003 01:56 AM
тАО06-02-2003 01:56 AM
Re: Shell Script to report total print jobs for each que
lpsched writes a log file:
/var/adm/lp/log
For reporting copy the file to another place and truncate the logfile to 0 for further reporting.
With a wc -l of the logfile you will have the total amount of print jobs since last truncate and with a little bit of awk ... you can sort out the print job counts by queue name.
Regards
- Tags:
- lpsched
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2003 04:01 AM
тАО06-02-2003 04:01 AM
Re: Shell Script to report total print jobs for each que
#!/usr/bin/ksh
# Variables
TOTALPRTLIST="/home/mkapsak/prtlist"
PRINTQUEUES= "/home/mkapsak/prtqueues"
# List all print queues
ll /var/spool/lp/request > $TOTALPRTLIST
# Create printer list
awk '{print $9}' /home/mkapsak/prtlist > $PRINTQUEUES
I'm not very familiar with variables, looping and reading the printer file using a while stmt.
Mike Kapsak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2003 07:01 AM
тАО06-02-2003 07:01 AM
Re: Shell Script to report total print jobs for each que
#!/usr/bin/sh
# Count print requests by printer
export PATH=/usr/bin
ACTIVE=0
JOBS=0
for PRINTQ in $(echo /var/spool/lp/request/*)
do
QUEUENAME=$(basename $PRINTQ)
QTY=$(ls $PRINTQ/d* 2>/dev/null | wc -l | cut -d \ -f 1)
if [ $QTY -gt 0 ]
then
let ACTIVE=$ACTIVE+1
print "Printer $QUEUENAME = \c"
print "$QTY request\c"
[[ $QTY -ne 1 ]] && print "s\c"
let JOBS=$JOBS+$QTY
print ""
fi
done
print "\nTotal jobs=$JOBS, printers with a queue=$ACTIVE"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2003 07:19 AM
тАО06-03-2003 07:19 AM
Re: Shell Script to report total print jobs for each que
I tried running the script you supplied but I'm geting a usage message from the cut command:
Usage: cut -b List [-n] [File...]
or: cut -c List [File...]
or: cut -f List [-d Character] [-s] [File...]
itrcscript[11]: test: Specify a parameter with this command.
Mike Kapsak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2003 06:44 AM
тАО07-23-2003 06:44 AM
Re: Shell Script to report total print jobs for each que
Use a single quote '\' around the backslash after the cut command.
QTY=$(ls $PRINTQ/d* 2>/dev/null | wc -l | cut -d '\' -f 1)
Cheers
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2003 05:33 AM
тАО07-24-2003 05:33 AM
Re: Shell Script to report total print jobs for each que
#!/bin/sh
#
# check printer status
# Geoff Wild
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "lpst \"printer\""
echo "Example:"
echo "lpst W052"
exit 1
fi
echo " "
/usr/sbin/ping $1 -n 2
echo " "
lpstat -p$1 -v$1
echo " "
echo "Output Requests"
echo "-----------------------------------------------------------"
lpstat -o$1
echo " "
lpstat -r
echo " "
Example:
lpst W052
PING myprinter.mydomain.com: 64 byte packets
64 bytes from 192.168.2.101: icmp_seq=0. time=7. ms
64 bytes from 192.168.2.101: icmp_seq=1. time=7. ms
----myprinter.mydomain.com PING Statistics----
2 packets transmitted, 2 packets received, 0% packet loss
round-trip (ms) min/avg/max = 7/7/7
printer W052 is idle. enabled since May 14 10:00
fence priority : 0
device for W052: /dev/null
Output Requests
-----------------------------------------------------------
no entries
scheduler is running
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2003 06:55 PM
тАО07-24-2003 06:55 PM
Re: Shell Script to report total print jobs for each que
cut -d \space space -f ...
so leave out the apostrophes and just add an extra space after the \ char. The \ escapes the special meaning of the first space and the missing second space separates -d char from the -f option. Another way is:
cut -d ' ' -f ...
which is probably more intuitive and translates cleanly:
#!/usr/bin/sh
# Count print requests by printer
export PATH=/usr/bin
ACTIVE=0
JOBS=0
for PRINTQ in $(echo /var/spool/lp/request/*)
do
QUEUENAME=$(basename $PRINTQ)
QTY=$(ls $PRINTQ/d* 2>/dev/null | wc -l | cut -d ' ' -f 1)
if [ $QTY -gt 0 ]
then
let ACTIVE=$ACTIVE+1
print "Printer $QUEUENAME = \c"
print "$QTY request\c"
[[ $QTY -ne 1 ]] && print "s\c"
let JOBS=$JOBS+$QTY
print ""
fi
done
print "\nTotal jobs=$JOBS, printers with a queue=$ACTIVE"
(I checked a cut-n-paste from the above and it works OK)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 03:01 PM
тАО11-03-2004 03:01 PM
Re: Shell Script to report total print jobs for each que
[[ $QTY -ne 1 ]] && print "s\c"
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 12:00 PM
тАО11-04-2004 12:00 PM
Re: Shell Script to report total print jobs for each que
Bill Hassell, sysadmin