Script to find paused printers

tep
Contributor II

We've experienced some trouble with our smb printers pausing, and would like a way to be alerted when they do. I've got a potential fix in place, but with hundreds of computers, located in several different buildings, it's hard to know if the problem is persisting. Does anyone know of a way to poll printers, and see if they are paused? Maybe a script of some kind? Any help would be much appreciated.

Tanya Pfeffer
Macalester College

4 REPLIES 4

mm2270
Legendary Contributor III

You could make an Extension Attribute that just runs an lpstat -p command.
It will pull all local printers and their respective status.

You could also do something like:

lpstat -p | grep -EB1 "Paused"

You'd have to experiment with that in your environment, but it should return something like the following, provided any printers are disabled, otherwise will return a null value:

printer Phaser_8500DT disabled since Tue Apr  2 17:55:31 2013 -
    Paused

HTH.

Edit: Just one other thought, if you decided to use the above as an EA, you could set up a Smart Group for any Macs reporting in with any non blank value in the Extension Attribute and have the JSS email you on changes to that group. That should, in theory get you close to what you're looking for.

Nix4Life
Valued Contributor

!/bin/bash

scutil --get LocalHostName > paused.txt
lpstat -p | awk '{print $2}'| while read printer
do
if sudo lpstat -p | grep disabled > /dev/null; then
cancel -a-
cupsdisable $printer
sleep 2
cupsenable $printer
sleep 2
echo $printer >> paused.txt
mailx -s "A Printer has been Reset on the following iMac/Macbook" someemailaddress < paused.txt
else

exit
fi
done

hth LSinNY

tep
Contributor II

Thanks for the input! I've never really used extension attributes, but that seems like an interesting way to go. I like the idea of using a Smart Group to monitor changes. Would the input type be "populated by script"?

tep
Contributor II

LSinNY: awesome, thanks so much!

Does your scrip actually reset the printer?