Automated printer queue check.
Script to automatically check and restart printer queues if needed.This script requires GNU bash to be installed on your AIX server.
Please replace 'REPLACE' and 'EMAIL' in the following script as per the requirement.
#!/usr/local/bin/bash
#
# check_printers.sh
# Automatically checks printer queues:
# 1) Kill all queues if one is marked as DOWN
# 2) Restart all queues
# 3) Warn administrators about queue problems
#
# This is designed for a system with many printer queues,
# using distant (networked) printers. Add as many printers
# as needed in the different 'enq' commands below.
#
# Modify as follows:
# ==================
# REPLACE -> name of printer queues
# EMAIL -> email of admins to be informed.
#
check=$(lpstat | grep -i ^REPLACE.*DOWN | grep -vi HOST | wc -l | awk '{print $1}')
system=`uname -n`
case ${check} in
"0")
# No 'DOWN' queue: exit
exit 0
;;
*)
# At least one DOWN queue:
# kill, restart and inform.
# Kill ------------------------
enq -K -P 'REPLACE'
# add more printers here if needed.
# Restart ---------------------
enq -U -P 'REPLACE'
# add more printers here if needed.
# Inform ----------------------
echo "At least one printer queue DOWN on ${system}. Printer queue restarted. Please check printer status." |\
mail -s "Printer queues on ${system}" EMAIL -c EMAIL
;;
esac
exit 0
# end of script.
Put this in the
root
crontab, it will work on his own.
No comments:
Post a Comment