Prometheus monitoring: printing exporter

We should monitor printing stuff with Prometheus. It’s a good thing to start with, and once it’s done, it’ll be a fun and easy opportunity to mess with alerting (which we currently don’t use). It would be great to have an alert for when we are running low on toner/paper. (we have scripts for this already, but this is better suited for Prometheus)

We have a mechanism for getting this data in ocflib-- see https://github.com/ocf/ocflib/blob/master/ocflib/printing/printers.py

However, instead of using ocflib for this, a better option would be using the snmp_exporter tool made by the Prometheus team. If we set up the SNMP exporter, we could also potentially use it to look at network traffic on our switches (which uses the same protocol as the printers).

The SNMP exporter is done, but I’d still like to get more stats with Prometheus.

I’d like to get stats from CUPS. There’s a CUPS exporter here https://github.com/ThoreKr/cups_exporter but I don’t think it’s actually necessary for us to use that.

I think our best option is to have a cronjob that writes to a text file, then use the Prometheus textfile exporter to scrape that. Things to find from the text file would be:

  • Current number of print jobs and total print jobs (already in the CUPS exporter, but maybe we should rewrite it to be a cronjob)
  • Which printers are in rotation (not yet sure how to do this)
  • Maybe something else I’m not thinking of atm

I wrote a CUPS exporter, it is running here: https://github.com/ocf/puppet/blob/master/modules/ocf_printhost/files/monitor-cups

We currently only use this to see if printers are in rotation or not, but it’s possible for us to check for more metrics here-- for example, we could see if print queues are growing too fast (which would indicate that printers are failing to print).