BUG: Printer Supply Check for Toner Levels incorrect interpretation of description

Hello @Iancomline,

we stumbled across the same problem with our 1.6.0p18 sites. In our case we had this broken output for all cartridges on the printers.
It seems that the problem is a non printable character in the value of the OID which is used for the color of the cartridge.
The check has two possible OIDs from which it pulls the name for the color of the cartridge. In our case the SNMPwalk for these OIDs looked like this:

.1.3.6.1.2.1.43.12.1.1.4.1.1 "62 6C 61 63 6B 00 " → black
.1.3.6.1.2.1.43.12.1.1.4.1.2 "63 79 61 6E 00 " → cyan
.1.3.6.1.2.1.43.12.1.1.4.1.3 "6D 61 67 65 6E 74 61 00 " → magenta
.1.3.6.1.2.1.43.12.1.1.4.1.4 "79 65 6C 6C 6F 77 00 " → yellow

As you can see the printer sends the names in hex and checkmk is converting it on the server side to “human readable” text. However, you can see that all these values end with 00 which when interpreted as hex is the representation for the NULL-byte and that is a non printable character. This apparently breaks the output in the webinterface, it curioulsy is not a problem for the output on the commandline.

Our temporary fix was to copy the printer_supply-check from ~/share/check_mk/checks/printer_supply to the local-hierarchy ~/local/share/check_mk/checks/printer_supply and add one line (line 152) to strip the NULL-byte from the end of corresponding string:

150             color_info = ""
151             if color and color.lower() not in item.lower():
152                 color = color.rstrip('\0')
153                 color_info = "[%s] " % color

After this change the check on the webinterface shows the full output and the performace-data again.

I assume this bug was somehow introduced in this commit: 11277 FIX Fix wrong allocation of colorant for printer supplies · Checkmk/checkmk@934e48c · GitHub

Hope this helps!

Cheers,
Lorenz

1 Like