Skip to content

Commit f5302d7

Browse files
committed
18274 FIX Printer Supply: Upturn option failed for receptacles
This Werk fixes a regression that occurs since Checkmk 2.4.0. At the _Printer cartridge levels_ ruleset, you can enable the option _Upturn supply levels_ (Previously called _Upturn toner levels_) to fix values from a device that reports its levels in an unusual way. This fix, while being effective for Containers like ink cartridges and toners, failed to apply for receptacles like waste boxes. Alongside this Werk, the wording around the _Upturn supply levels_ option and the Check's manpage has been adapted slightly to clarify the scope and meaning of this feature. CMK-24095 Change-Id: Ia53995820af3c80c6181aea537b82524c6d38d80
1 parent 3d2e271 commit f5302d7

5 files changed

Lines changed: 75 additions & 21 deletions

File tree

.werks/18274.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[//]: # (werk v2)
2+
# Printer Supply: Upturn option failed for receptacles
3+
4+
key | value
5+
---------- | ---
6+
date | 2025-07-25T07:47:01+00:00
7+
version | 2.4.0p9
8+
class | fix
9+
edition | cre
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
This Werk fixes a regression that occurs since Checkmk 2.4.0.
15+
16+
At the _Printer cartridge levels_ ruleset, you can enable the option _Upturn supply levels_ (Previously called _Upturn toner levels_) to fix values from a device that reports its levels in an unusual way.
17+
This fix, while being effective for Containers like ink cartridges and toners, failed to apply for receptacles like waste boxes.
18+
19+
Alongside this Werk, the wording around the _Upturn supply levels_ option and the Check's manpage has been adapted slightly to clarify the scope and meaning of this feature.
20+

cmk/gui/plugins/wato/check_parameters/printer_supply.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,15 @@ def _parameter_valuespec_printer_supply() -> Migrate:
9999
(
100100
"upturn_toner",
101101
Checkbox(
102-
title=_("Upturn toner levels"),
103-
label=_("Printer sends <i>used</i> material instead of <i>remaining</i>"),
102+
title=_("Upturn supply levels"),
103+
label=_("Printer sends <i>used</i> supply instead of <i>remaining</i>"),
104104
help=_(
105-
"Some Printers (e.g. Konica for Drum Cartdiges) returning the available"
106-
" fuel instead of what is left. In this case it's possible"
107-
" to upturn the levels to handle this behavior"
105+
"Some printers (e.g. Konica for drum cartridges) return"
106+
"<ul>"
107+
"<li>in case of a container: The used instead of the available supply</li>"
108+
"<li>in case of a receptacle: The available instead of the used space</li>"
109+
"<ul>"
110+
"Enable this option to handle this behavior."
108111
),
109112
),
110113
),

cmk/plugins/collection/agent_based/printer_supply.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,14 @@ def _get_partial_data_results(
297297
def _get_fill_level_percentage(supply: PrinterSupply, upturn_toner: bool) -> float:
298298
fill_level_percentage = 100.0 * supply.level / supply.max_capacity
299299

300-
# Some printers handle the used / remaining material differently
301-
# With the upturn option we can toggle the point of view (again)
302-
if supply.supply_class is SupplyClass.RECEPTACLE or upturn_toner:
300+
if supply.supply_class is SupplyClass.RECEPTACLE:
301+
# We expect a receptacle (like a waste container) to display used space that counts up.
302+
# Since we handle all percentages as "supply left", we turn the percentage upside down.
303+
fill_level_percentage = 100 - fill_level_percentage
304+
305+
if upturn_toner:
306+
# This option must always upturn the applying logic.
307+
# Otherwise, we wouldn't catch a receptacle that shows space left instead of space used.
303308
return 100 - fill_level_percentage
304309

305310
return fill_level_percentage

cmk/plugins/collection/checkman/printer_supply

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@ catalog: hw/printer
44
license: GPLv2
55
distribution: check_mk
66
description:
7-
This check monitors the remaining filling level in percent of a printers
8-
supplys like toner or fuser. The printer has to support the generic
9-
PRINTER-MIB.
10-
The default check levels are 20% (warning) and 10% of the full level
11-
(critical).
12-
According the PRINTER-MIB it's possible that a printer couldn't determine
13-
how much is remaining in a supply, so the printer says "some remaining".
14-
This value produces a warning.
7+
This check monitors the remaining level of a printer's supplies, such as toner, fuser, or waste box.
8+
The printer must support the generic PRINTER-MIB.
9+
The default check levels are 20% (warning) and 10% (critical) of the full supply level.
10+
According to the PRINTER-MIB, it is possible that a printer cannot determine the exact remaining amount in a supply and instead reports "some remaining."
11+
This status will result in a warning. However, this is customizable via service parameter.
12+
Some printers may report a supply level in an unsusual way, e.g., used ink instead of remaining, or space left in waste box instead of space used.
13+
The check can't detect this situation, but you can correct the value by applying the service parameter {Upturn supply levels}.
1514

16-
In case of OKI c5900 devices the name of the supply units ins not unique.
17-
One example is {Toner Cartridge OKI DATA CORP}. In this case the color of
18-
the supply unit is added to the beginning of the name to get a unique
19-
item name.
15+
For OKI c5900 devices, the names of the supply units are not unique.
16+
For example, one supply might be named {Toner Cartridge OKI DATA CORP}. In such cases, the color of the supply unit is added to the beginning of the name to create a unique item name.
2017

2118
item:
22-
The description of the printer
19+
The description of the printer supply unit.
2320

2421
discovery:
2522
One service is created for each supply unit with a unique name.
23+
The service always shows remaining supply. E.g., remaining ink, remaining space in waste box.

tests/unit/cmk/plugins/collection/agent_based/test_printer_supply.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,34 @@ def test_inventory_printer_supply(
350350
Metric("supply_toner_magenta", 75.0),
351351
],
352352
),
353+
(
354+
"Waste box that shows space used",
355+
DEFAULT_PARAMETERS,
356+
[
357+
[["1.1", "waste"]],
358+
[
359+
["Waste box that shows space used", "19", "5000", "1000", "4", "1"],
360+
],
361+
],
362+
[
363+
Result(state=State.OK, summary="Supply level remaining: 80.00%"),
364+
Metric("supply_toner_other", 80.0),
365+
],
366+
),
367+
(
368+
"Waste box that shows space left",
369+
DEFAULT_PARAMETERS | {"upturn_toner": True},
370+
[
371+
[["1.1", "waste"]],
372+
[
373+
["Waste box that shows space left", "19", "5000", "1000", "4", "1"],
374+
],
375+
],
376+
[
377+
Result(state=State.OK, summary="Supply level remaining: 20.00%"),
378+
Metric("supply_toner_other", 20.0),
379+
],
380+
),
353381
],
354382
)
355383
def test_check_printer_supply(

0 commit comments

Comments
 (0)