IT/Procedures/Printer Maintenance/Script to prevent printhead drying out: Difference between revisions

From msgwiki
< IT‎ | Procedures
Jump to navigation Jump to search
Access restrictions were established for this page. If you see this message, you have no access to this page.
(added notifications)
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Printer Maintenance Script =
= Printer Maintenance Script =
This script tries to print out pages every few days on all inkjet printers.


=== About the Issue ===
This should prevent the ink drying out which would render the printer unusable.
A lot of effort has been taken by several people to create a reliable script that prints a test page on all printers every few days.
 
This should prevent the ink drying out which renders the printer unusable.
 
So far this feat has not been fully achieved yet :(


=== How is it setup? ===
=== How is it setup? ===


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


=== Scripts Overview ===
* there's a script that prints over the access point mode of the printers
* 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
** caveat is that the printer need to be set to ap mode, then back again for normal use
Line 23: Line 19:
* the other scripts try to print over wlan connected to the router
* 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
** this seems to work "mostly" well, at least with the MG3670 printer models
** depending on the mood of the printer, it will not print anything at all
** depending on the configured drivers in CUPS it will not print anything at all
* send a Telegram notification if any print job ist unfinished


=== The Issues ===
=== Issues ===


* some printers occasionally just don't print anymore and pile up jobs (check <code>lpstat</code>)
* some printers occasionally just don't print anymore and pile up jobs (check <code>lpstat</code>)
** though this also happens with "legit" reasons, e.g. no paper or printer error
** 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. <code>lpstat -v</code>
* printers sometimes "dissapear" from the network and are no longer visible through e.g. <code>lpstat -v</code>
* so far no reliable way has been found to resolve the issues automatically
** so far this has been mitigated by setting the printers up in cups with a static IP address over ipp


=== New Approaches ===
=== 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 [[IT/Procedures/Printer Maintenance/Configure Printer Driver-Model|Configure Printer Driver/Model]]
* printer-maintenance.sh
* printer-maintenance.sh
** uses a static list of all printers (so no printer is "forgotten" if it dissapears from the network)
** 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 (<code>lprm [PRINTER] -</code>)
** checks if a printer has any unfinished jobs and deletes them (<code>lprm [PRINTER] -</code>)
** sends a new job
** checks if a printer has the correct driver/model configured, searches for the ColorModel attribute  (<code>lpoptions -p [PRINTER_NAME] -l | grep ColorModel | grep CMYK</code>)
** waits 1 min, then checks for unfinished jobs again
*** could probably also be done with e.g. <code>lpoptions -p [PRINTER_NAME] | grep "Canon MX920 series - CUPS+Gutenprint v5.3.3"</code> 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
*** if there are some, this will be logged
*** those printers then need manual maintenance (or just more paper)
*** those printers then need manual maintenance (probably mechanical issue, wrong driver, or just missing paper)
*** sends notification to telegram webhook
*** sends a notification to telegram and/or line webhook with output of lpstat
** if it works well, will merge with printerPurge.sh
**** could be extended to send to e-mail or other messengers if needed


==== Telegram Notifications ====
==== Telegram Notifications ====
In Telegram
How to setup Telegram notifications.


* contact "BotFather" to create a new telegram bot send: /newbot
In Telegram:
 
* contact "BotFather" to create a new telegram bot and send: /newbot


* follow the instructions
* follow the instructions
Line 55: Line 59:


* contact "IDBot" and send: /getid (in a group chat, add IDBot to group and send: /getgroupid@myidbot)
* 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
** <code>TELEGRAM_API_TOKEN</code>
** <code>TELEGRAM_CHAT_ID</code>


* copy ID (include "-" with group chat IDs")
==== Line Notifications ====
* paste the API key and ID into the script
How to setup Line notifications.
 
* visit https://notify-bot.line.me/my/
* click Generate token
** choose a name
** choose the group chat to where the notifications will be sent to
* save the token and paste it to <code>LINE_ACCESS_TOKEN</code>
* add the account "LINE Notify" to the group chat
* more information: https://notify-bot.line.me/doc/en/


=== Useful Commands ===
=== Useful Commands ===
Line 66: Line 83:
** <code>-v</code>
** <code>-v</code>
* <code>lprm [PRINTER] -</code>
* <code>lprm [PRINTER] -</code>
* <code>lpoptions -p [PRINTER_NAME] -l</code>

Latest revision as of 14:45, 27 May 2024

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