IT/Procedures/Printer Maintenance/Script to prevent printhead drying out

From msgwiki
< IT‎ | Procedures
Revision as of 14:45, 27 May 2024 by Stefan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Printer Maintenance Script

This script tries to print out pages every few days on all inkjet printers.

This should prevent the ink drying out which would render the printer unusable.

How is it setup?

  • the script runs every few days as a cron job on the cnx server
  • several similar/other scripts are under /home/walt/.scripts/PrinterMaintenance
    • the most current script is named printer-maintenance.sh
  • crontab -e to check which one is active at the moment
  • the current cronjob creates logs in the same folder (*.log)
  • most if not all of the scripts try to print with lp and check somewhat with lpstat what's around (printers and/or open print jobs)

Scripts Overview

  • there's a script that prints over the access point mode of the printers
    • caveat is that the printer need to be set to ap mode, then back again for normal use
    • so far this was used as a "holiday setup"
  • the other scripts try to print over wlan connected to the router
    • this seems to work "mostly" well, at least with the MG3670 printer models
    • depending on the configured drivers in CUPS it will not print anything at all

Issues

  • some printers occasionally just don't print anymore and pile up jobs (check lpstat)
    • though this also happens for "legit" reasons, e.g. no paper or printer error
    • mainly this happens if the correct driver is not configured in cups
  • printers sometimes "dissapear" from the network and are no longer visible through e.g. lpstat -v
    • so far this has been mitigated by setting the printers up in cups with a static IP address over ipp

printer-maintenance.sh

  • configured a specific printer driver/model in CUPS
    • the default/driverless model doesn't support duplex and CMYK printing
    • set address from dnssd (bonjour) to static ip of the printer so that they don't suddenly dissappear (to the next volunteer: just change it back if you think this should be done with bonjour ;)
    • see Configure Printer Driver/Model
  • printer-maintenance.sh
    • uses a static list of all printers (so no printer is "forgotten" if it dissapears from the network)
    • checks if a printer has any unfinished jobs and deletes them (lprm [PRINTER] -)
    • checks if a printer has the correct driver/model configured, searches for the ColorModel attribute (lpoptions -p [PRINTER_NAME] -l | grep ColorModel | grep CMYK)
      • could probably also be done with e.g. lpoptions -p [PRINTER_NAME] | grep "Canon MX920 series - CUPS+Gutenprint v5.3.3" but would need a different string compare for every printer model
    • sends a new print job
    • waits 3 min for the page to print, then checks for unfinished jobs again
      • if there are some, this will be logged
      • those printers then need manual maintenance (probably mechanical issue, wrong driver, or just missing paper)
      • sends a notification to telegram and/or line webhook with output of lpstat
        • could be extended to send to e-mail or other messengers if needed

Telegram Notifications

How to setup Telegram notifications.

In Telegram:

  • contact "BotFather" to create a new telegram bot and send: /newbot
  • follow the instructions
  • copy the API key
  • contact "IDBot" and send: /getid (in a group chat, add IDBot to group and send: /getgroupid@myidbot)
    • this will show you your chat ID or the one of a group chat
    • copy the ID (include "-" with group chat IDs")
  • paste the API key and ID into the script
    • TELEGRAM_API_TOKEN
    • TELEGRAM_CHAT_ID

Line Notifications

How to setup Line notifications.

Useful Commands

  • lp
  • lpstat
    • -e
    • -v
  • lprm [PRINTER] -
  • lpoptions -p [PRINTER_NAME] -l