[cups] Do not send jobs if printer is unhealthy (paper out/network/etc)

Horváth Szabolcs Horvath.Szabolcs at t-systems.hu
Fri Jun 8 06:27:47 PDT 2018


Hello,

We'd like to use highly available printing solution. 
We have two LaserJets defined (hp_printer_1 and hp_printer_2) and a printing class (hp_printer_prod) which provides round-robin style load balancing.
That works perfectly if both printers are online and ready to accept jobs (have paper and cartridge).

Imagine when the next available printer ("hp_printer_1") has a recent issue (paper is *just*out*).
"Job #1" sent to "hp_printer_prod" will be forwarded to "hp_printer_1" (state=idle).
In the tcpdump we see the job sent through port 9100. "Job #1" removed from hp_printer_1 queue (because cups handed over to the laserjet). But the paper doesn't come out (no paper in the printer). Job stucked in the printer's memory.

At this very moment, CUPS detects that there is something wrong with hp_printer_1, and marks unavailable.

"Job #2" sent to "hp_printer_prod" will be forwarded to "hp_printer_2" (because this is the only printer which is available).
Subsequent jobs also will be forwarded to "hp_printer_2".

When "hp_printer_1" goes back in production, "job #1" is printed out on "hp_printer_1" (from memory).

We're looking for a method to check printer hardware status before printing.
Printing jobs should only be sent to printer if it is healthy.

Configuration goes like this:

<Class hp_printer_prod>
Info
Location
State Idle
StateTime 1528459526
Accepting Yes
Shared Yes
JobSheets none none
Printer hp_printer_1
Printer hp_printer_2
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-current-job
</Class>

<Printer hp_printer_1>
Info hp_printer_1
MakeModel HP LaserJet 600 M601 M602 M603 Postscript (recommended)
DeviceURI hp:/net/HP_LaserJet_600_M602?ip=10.5.50.2
State Idle
StateTime 1528459608
Type 8425668
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 0 hpps
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
<Printer hp_printer_2>
Info hp_printer_2
MakeModel HP LaserJet 600 M601 M602 M603 Postscript (recommended)
DeviceURI hp:/net/HP_LaserJet_600_M602?ip=10.5.50.4
State Idle
StateTime 1528459601
Type 8425668
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 0 hpps
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

I know that the printer can tell its exact status via the web interface or the more standardized web interface:
In fact there a lot of SNMP status changes when something goes wrong (diff between two snmpwalks):
< HOST-RESOURCES-MIB::hrDeviceStatus.1 = INTEGER: running(2)
> HOST-RESOURCES-MIB::hrDeviceStatus.1 = INTEGER: warning(3)
< HOST-RESOURCES-MIB::hrPrinterDetectedErrorState.1 = Hex-STRING: 00
> HOST-RESOURCES-MIB::hrPrinterDetectedErrorState.1 = Hex-STRING: 81
< SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.2.0 = INTEGER: 0
> SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.2.0 = INTEGER: 1
< SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.3.0 = INTEGER: 0
> SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.3.0 = INTEGER: 1
< SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.8.0 = INTEGER: 0
> SNMPv2-SMI::enterprises.11.2.3.9.1.1.2.8.0 = INTEGER: 1
< SNMPv2-SMI::enterprises.11.2.4.3.1.2.0 = STRING: "ready to print"
> SNMPv2-SMI::enterprises.11.2.4.3.1.2.0 = STRING: "paper out"

Is there any method to detect printer issues before sending out jobs (health check before every print job)?
I'd like to handle this in CUPS, if it is possible. Do not send jobs if paper is out/network issue/ etc.
(Also I wouldn't want to do this with keepalived and custom check scripts :()

Thanks for your kind help in advance.

Best regards
  Szabolcs Horvath


More information about the cups mailing list