Get Zabbix statistics from Kyocera devices

Hi Habr!

With such a seemingly straightforward device from Kyocera, I wanted to get various statistics on the use of the printer and scanner. It would seem that everything is simple: take SNMP and get it, but ...


Having made sure that our device is sending something via SNMP, I went to Google in order to find the MIB for our device. However, it was possible to find information only that it was not there. Kyocera does not want to share such information, for some reason. Naturally, the idea of ​​a slightly routine search for the necessary values ​​on their own comes to mind. The algorithm is not the most difficult - snmpwalk, printing, snmpwalk, diff.
Here's what happened:

user@host:~# snmpwalk -v 2c -c public
iso. = Counter32: 242

And here is the first oddity: the value is slightly different from that specified in the web panel of the device itself (and in the printer menu):

A search in the SNMP-issuing numbers, at least somehow similar to what is written in the device’s web panel, did not yield the slightest result. Attempts to catch a change in a counter, such as a scan, have failed. Nothing has changed. There was a slight suspicion that the necessary data through SNMP simply could not be obtained.
But if there is value, then someone needs it! It turns out that Kyocera has its own software for monitoring and managing their devices - KYOCERA Net Viewer.
Fill out the form, enter the email, get an email with a one-time link ... If I knew why such difficulties, oh well.
The program is quite simple and shows us the same numbers as in the web face. And if she somehow gets them, then we can.
The first Wireshark combin came to my mind, so I'll use it.

And here weirdness number two: in addition to exchanging SNMP traffic, we also have HTTP here!


Further investigation leads us to the fact that the printer and software communicate with XML through SOAP.
The principle is extremely simple: a POST request to the printer sends a special XML containing the request. In our case, the request is "ALL_COUNTER", that is, we want to get all the counters. The printer can in response send meter readings or the message “DEEP_SLEEP_NOW_ERROR”, which is clear from without translation. It’s not necessary to wake up the printer somehow. He has already woken up from our request, just send the request again and get XML with counters.
All values ​​are indicated as <parameter> number . We make a small parser and get a script ( mirror ) that gives us the necessary numbers in a convenient way.

For M2535dn I was interested in the following counters:
  • accounting_print_black_and_white_copy_counter : Number of b / w pages printed using the copier
  • accounting_print_black_and_white_printer_counter : Number of b / w pages printed using a printer
  • accounting_print_combine_none_counter : Total counter for printed pages
  • accounting_scan_copy_counter : Number of pages scanned using a copier
  • accounting_scan_other_counter : The number of other scanned pages (on a USB flash drive, on the network, etc.)
  • device_life_counter : (?) The total counter of printed pages for the entire life of the device

The difference between the counters accounting_scan_copy_counter and accounting_print_black_and_white_copy_counter is explained simply: 2 copies of one original were made. One page went from the scanner to the copier, and the printer from the copier printed two. In addition to these counters, you can still get a lot of interesting things: the number of printed a4, a5, letter, etc. pages, the number of pages printed using duplex, copied in 2in1 and 4in1 modes, for color devices you can get the number of color and color copies separately . Device_life_counter counterthe printer sends us via SNMP, but this value is not displayed in the web interface or in special software. I do not quite understand the meaning of this parameter. Yesterday it differed from the total counter by 3, today it is already 8. I am waiting for your ideas in the comments.


Now you need to connect this to our monitoring in Zabbix. We will use an external check. You need to put the script in the ExternalScripts directory , give it permission to execute and slightly increase the timeout for running scripts, by default it is 3s:

user@host:~# cat /etc/zabbix/zabbix_server.conf | grep Timeout | grep -v ^#

Now you need to figure out a new template and fill it with data elements:

Template for Zabbix (Settings → Templates → Import): tyts and mirror .

A small remark: do not set the scan interval too short; this can lead to a decrease in the performance of the monitoring system as a whole. We apply to network nodes, configure graphs, reports and further on the mood.
That's all, all good Friday and a great weekend!

PS Not all of us are perfect and please notify about errors in the text in the LAN.

Also popular now: