Brother Printers not reporting Ink Levels (Always 50%)

Hello,

So I’m trying to add a MFC-J5945DW and a MFC-J6520DW however the ink levels are always reported as 50%.

After digging a little bit I found this article that explains how it’s possible to get exact readings:

http://2tazasdelinux.blogspot.com/2021/05/

It’s in spanish but it basically says that you can get the correct readings from:

iso.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8
snmpwalk -v 2c -c public 172.a.b.c iso.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8
iso.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8.0 = Hex-STRING: 76 01 04 00 00 00 01 77 01 04 00 00 00 01 78 01 
04 00 00 00 01 7F 01 04 00 00 00 01 68 01 04 00 
00 00 01 55 01 04 00 00 00 01 31 01 04 00 00 00 
01 32 01 04 00 00 00 02 33 01 04 00 00 00 01 34 
01 04 00 00 00 01 70 01 04 00 00 01 F4 82 01 04 
00 00 00 0A 71 01 04 00 00 22 60 83 01 04 00 00 
00 5A 72 01 04 00 00 19 64 84 01 04 00 00 00 46 
6F 01 04 00 00 25 1C 81 01 04 00 00 00 64 79 01 
04 00 00 0C 1C 7A 01 04 00 00 0C 1C 7B 01 04 00 
00 0C 1C 80 01 04 00 00 0C 1C 69 01 04 00 00 25 
E4 73 01 04 00 00 28 FA 74 01 04 00 00 28 FA 75 
01 04 00 00 28 FA 7E 01 04 00 00 28 FA 54 01 04 
00 00 00 01 35 01 04 00 00 00 01 6A 01 04 00 00 
21 34 6D 01 04 00 00 26 AC FF 

You should group these in groups of 7 values:

# snmpwalk -v 2c -c public 172.a.b.c iso.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8.0 | tr -d "\n" | cut -c54- |  fold -w 21
76 01 04 00 00 00 01 
77 01 04 00 00 00 01 
78 01 04 00 00 00 01 
7F 01 04 00 00 00 01 
68 01 04 00 00 00 01 
55 01 04 00 00 00 01 
31 01 04 00 00 00 01 
32 01 04 00 00 00 02 
33 01 04 00 00 00 01 
34 01 04 00 00 00 01 
70 01 04 00 00 01 F4 
82 01 04 00 00 00 0A 
71 01 04 00 00 22 60 
83 01 04 00 00 00 5A 
72 01 04 00 00 19 64 
84 01 04 00 00 00 46 
6F 01 04 00 00 25 1C 
81 01 04 00 00 00 64 
79 01 04 00 00 0C 1C 
7A 01 04 00 00 0C 1C 
7B 01 04 00 00 0C 1C 
80 01 04 00 00 0C 1C 
69 01 04 00 00 25 E4 
73 01 04 00 00 28 FA 
74 01 04 00 00 28 FA 
75 01 04 00 00 28 FA 
7E 01 04 00 00 28 FA 
54 01 04 00 00 00 01 
35 01 04 00 00 00 01 
6A 01 04 00 00 21 34 
6D 01 04 00 00 26 AC 
FF 

Now this is what matters:

"6f": VAL_BLACK_TONER_REMAIN
"70": VAL_CYAN_TONER_REMAIN
"71": VAL_MAGENTA_TONER_REMAIN
"72": VAL_YELLOW_TONER_REMAIN

Where, for instance:

71 01 04 00 00 23 F0

The “71” is VAL_MAGENTA_TONER_REMAIN, magenta remaining toner. The “01 04” we ignore. And the “00 00 23 F0” is the hexadecimal number 0x23F0, which in decimal is 9200. That 9200 must be divided by 100 and gives us the percentage of magenta toner remaining: 9200/100=92% toner.

Some additional info:

Is this something that can be introduced in librenms?

Maybe something doable on librenms/LibreNMS/Modules/PrinterSupplies.php at master · librenms/librenms · GitHub ?

This simple code reads the ink levels correctly.

Is it possible to adapt to librenms?

<?php
// Execute SNMP command and capture the output
$command = 'snmpget -v 2c -c COMMUNITY 192.168.1.1 iso.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8.0';
$output = shell_exec($command);

// Extract the hexadecimal value from SNMP output
if (preg_match('/Hex-STRING:\s((?:\b[0-9A-Fa-f]{2}\b\s*)+)/', $output, $matches)) {
    $hexString = $matches[1];
    $hexValues = preg_split('/\s+/', $hexString, -1, PREG_SPLIT_NO_EMPTY);

    $tonerLevels = [];

    // Process each septet and calculate the percentage level for values starting with "6F", "70", "71", and "72"
    $septets = array_chunk($hexValues, 7);
    foreach ($septets as $septet) {
        $hexCode = $septet[0];
        if (in_array($hexCode, ['6F', '70', '71', '72'])) {
            $hexValue = implode('', array_slice($septet, -4)); // Get the last four values of the septet
            $tonerLevel = hexdec($hexValue) / 100;

            // Get the toner name based on the code
            $tonerName = '';
            switch ($hexCode) {
                case '6F':
                    $tonerName = 'VAL_BLACK_TONER_REMAIN';
                    break;
                case '70':
                    $tonerName = 'VAL_CYAN_TONER_REMAIN';
                    break;
                case '71':
                    $tonerName = 'VAL_MAGENTA_TONER_REMAIN';
                    break;
                case '72':
                    $tonerName = 'VAL_YELLOW_TONER_REMAIN';
                    break;
            }

            // Display the toner name and toner level on separate lines
            echo "$tonerName: $tonerLevel%<br>";
        }
    }
} else {
    echo "Error extracting hexadecimal value from SNMP<br>";
}
?>

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.