{"id":240,"date":"2008-02-29T16:00:16","date_gmt":"2008-02-29T16:00:16","guid":{"rendered":"http:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/"},"modified":"2014-05-20T09:09:46","modified_gmt":"2014-05-20T08:09:46","slug":"print-job-failure-alerts","status":"publish","type":"post","link":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/","title":{"rendered":"Print job failure alerts"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png\" class=\"alignleft\" alt=\"Print Error\" \/>I&#8217;ve just added print job failure alert messages to the <a href=\"https:\/\/cyberelk.net\/tim\/software\/system-config-printer\/trackback\/\">system-config-printer<\/a> applet, and this is what one looks like.  Part of the work involved in doing this was to switch from repeatedly polling the CUPS server for the entire job list (which can be slow and resource-intensive) to using IPP notifications to find out what&#8217;s changed.<\/p>\n<p><!--more--><\/p>\n<h3>Using IPP notifications<\/h3>\n<p>The API for this provided by <a href=\"https:\/\/cyberelk.net\/tim\/software\/pycups\/trackback\/\">pycups<\/a> is fairly straightforward, and follows the IPP model:<\/p>\n<ul>\n<li>createSubscription, where you specify which IPP events you are interested in, and get given a subscription ID,<\/li>\n<li>getNotifications, where you provide your list of subscription IDs and sequence numbers, and get given a list of events, and<\/li>\n<li>cancelSubscription, where you provide your subscription ID.<\/li>\n<\/ul>\n<p>Each subscription has a lease time, after which the subscription is automatically cancelled. (Hmm, I ought to add renewSubscription, seeing as there is an IPP operation for it that CUPS supports&#8230;)  Here is an example of an event:<\/p>\n<p><code>{'job-impressions-completed': 0,<br \/>\n'job-name': u'badprint.ps',<br \/>\n'job-state': 6,<br \/>\n'job-state-reasons': u'job-stopped',<br \/>\n'notify-charset': u'utf-8',<br \/>\n'notify-job-id': 284,<br \/>\n'notify-natural-langugage': u'en-us',<br \/>\n'notify-printer-uri': u'ipp:\/\/cyberelk.elk:631\/printers\/DESKJET_990C',<br \/>\n'notify-sequence-number': 8,<br \/>\n'notify-subscribed-event': u'job-stopped',<br \/>\n'notify-subscription-id': 391,<br \/>\n'notify-text': u'Job stopped due to filter errors; please consult the error_log file for details.',<br \/>\n'printer-is-accepting-jobs': True,<br \/>\n'printer-name': u'DESKJET_990C',<br \/>\n'printer-state': 3,<br \/>\n'printer-state-reasons': [u'marker-supply-low-warning'],<br \/>\n'printer-up-time': 1204303952}<\/code><\/p>\n<p>This shows where you get the sequence number (&#8220;notify-sequence-number&#8221;) for keeping track of which events you&#8217;ve already seen, the event name (&#8220;notify-subscribed-event&#8221;, in this case &#8220;job-stopped&#8221;), and also shows what looks like a really useful field: notify-text, where it says exactly what went wrong with the job.<\/p>\n<h3>CUPS limitations<\/h3>\n<p>Unfortunately, this &#8220;Job stopped due to filter errors&#8221; string is given to us untranslated.  Even if we have set the attributes-natural-language field to show that we can only understand French, we&#8217;ll get exactly the same string.  Not only that, but it&#8217;s not a particularly helpful message anyway &#8212; if you don&#8217;t know much about CUPS, or how your computer does what it does, being told about something called error_log isn&#8217;t much good.<\/p>\n<p>Anyway, the possibilities for that string are fairly limited.  In the applet, I get it to look for &#8220;filter errors&#8221; and &#8220;backend errors&#8221;, leading to these translatable strings:<\/p>\n<ul>\n<li>&#8220;There was a problem processing document `%s&#8217; (job %d).&#8221; for filter errors<\/li>\n<li>&#8220;There was a problem sending document `%s&#8217; (job %d) to the printer.&#8221; for backend errors<\/li>\n<li>&#8220;There was a problem printing document `%s&#8217; (job %d).&#8221; for anything else.<\/li>\n<\/ul>\n<p>To try to be helpful in this situation, I&#8217;ve added a &#8220;Diagnose&#8221; button.  This fires up the <a href=\"https:\/\/cyberelk.net\/tim\/2008\/02\/20\/trouble-shooting-screenshots\/trackback\/\">trouble-shooter<\/a> to try to find out what the problem is.<\/p>\n<p>Still to do: make the trouble-shooter allow callers to pre-select which printer is having problems.<\/p>\n<h3>Remote IPP jobs<\/h3>\n<p>All of the above only works for locally printed jobs.  This is because local jobs use the IPP backend, which does not relay enough information from the remote CUPS instance to be useful even for discovering that a job has failed, let alone giving any indication of why it has failed.<\/p>\n<p>Yes, that&#8217;s right, you read that correctly: if a remote CUPS job has failed, there is no indication from the local CUPS that it is the case.  Instead, the job still shows locally as &#8220;Processing&#8221;.  This is because the IPP backend does not stop itself when the remote job stops, and so the local &#8220;job&#8221; (i.e. the IPP backend watching the remote job) is still running.<\/p>\n<p>The only thing that can give a clue as to whether the remote job is even running at all is to watch the printer-state-message attribute, which <em>might<\/em> say something like &#8220;foomatic-rip failed&#8221; &#8212; but there is no way to distinguish an error message from, say, a progress report.<\/p>\n<p>Still, job failure reports for local printers only is better than nothing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve just added print job failure alert messages to the system-config-printer applet, and this is what one looks like. Part of the work involved in doing this was to switch from repeatedly polling the CUPS server for the entire job list (which can be slow and resource-intensive) to using IPP notifications to find out what&#8217;s [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-software"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Print job failure alerts - PRINT HEAD<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Print job failure alerts - PRINT HEAD\" \/>\n<meta property=\"og:description\" content=\"I&#8217;ve just added print job failure alert messages to the system-config-printer applet, and this is what one looks like. Part of the work involved in doing this was to switch from repeatedly polling the CUPS server for the entire job list (which can be slow and resource-intensive) to using IPP notifications to find out what&#8217;s [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/\" \/>\n<meta property=\"og:site_name\" content=\"PRINT HEAD\" \/>\n<meta property=\"article:published_time\" content=\"2008-02-29T16:00:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-05-20T08:09:46+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png\" \/>\n<meta name=\"author\" content=\"Tim Waugh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tim Waugh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/\"},\"author\":{\"name\":\"Tim Waugh\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#\\\/schema\\\/person\\\/23b749f30a67f1b1c6af17024fc94bf6\"},\"headline\":\"Print job failure alerts\",\"datePublished\":\"2008-02-29T16:00:16+00:00\",\"dateModified\":\"2014-05-20T08:09:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/\"},\"wordCount\":572,\"publisher\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#\\\/schema\\\/person\\\/23b749f30a67f1b1c6af17024fc94bf6\"},\"image\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/printerror.png\",\"articleSection\":[\"Software\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/\",\"url\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/\",\"name\":\"Print job failure alerts - PRINT HEAD\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/printerror.png\",\"datePublished\":\"2008-02-29T16:00:16+00:00\",\"dateModified\":\"2014-05-20T08:09:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#primaryimage\",\"url\":\"http:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/printerror.png\",\"contentUrl\":\"http:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/printerror.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/2008\\\/02\\\/29\\\/print-job-failure-alerts\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Print job failure alerts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#website\",\"url\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/\",\"name\":\"PRINT HEAD\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#\\\/schema\\\/person\\\/23b749f30a67f1b1c6af17024fc94bf6\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/#\\\/schema\\\/person\\\/23b749f30a67f1b1c6af17024fc94bf6\",\"name\":\"Tim Waugh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/printhead.png\",\"url\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/printhead.png\",\"contentUrl\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/printhead.png\",\"width\":731,\"height\":140,\"caption\":\"Tim Waugh\"},\"logo\":{\"@id\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/printhead.png\"},\"sameAs\":[\"http:\\\/\\\/cyberelk.net\\\/tim\"],\"url\":\"https:\\\/\\\/cyberelk.net\\\/tim\\\/author\\\/twaugh\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Print job failure alerts - PRINT HEAD","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/","og_locale":"en_GB","og_type":"article","og_title":"Print job failure alerts - PRINT HEAD","og_description":"I&#8217;ve just added print job failure alert messages to the system-config-printer applet, and this is what one looks like. Part of the work involved in doing this was to switch from repeatedly polling the CUPS server for the entire job list (which can be slow and resource-intensive) to using IPP notifications to find out what&#8217;s [&hellip;]","og_url":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/","og_site_name":"PRINT HEAD","article_published_time":"2008-02-29T16:00:16+00:00","article_modified_time":"2014-05-20T08:09:46+00:00","og_image":[{"url":"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png","type":"","width":"","height":""}],"author":"Tim Waugh","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tim Waugh","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#article","isPartOf":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/"},"author":{"name":"Tim Waugh","@id":"https:\/\/cyberelk.net\/tim\/#\/schema\/person\/23b749f30a67f1b1c6af17024fc94bf6"},"headline":"Print job failure alerts","datePublished":"2008-02-29T16:00:16+00:00","dateModified":"2014-05-20T08:09:46+00:00","mainEntityOfPage":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/"},"wordCount":572,"publisher":{"@id":"https:\/\/cyberelk.net\/tim\/#\/schema\/person\/23b749f30a67f1b1c6af17024fc94bf6"},"image":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#primaryimage"},"thumbnailUrl":"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png","articleSection":["Software"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/","url":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/","name":"Print job failure alerts - PRINT HEAD","isPartOf":{"@id":"https:\/\/cyberelk.net\/tim\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#primaryimage"},"image":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#primaryimage"},"thumbnailUrl":"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png","datePublished":"2008-02-29T16:00:16+00:00","dateModified":"2014-05-20T08:09:46+00:00","breadcrumb":{"@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#primaryimage","url":"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png","contentUrl":"http:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2008\/02\/printerror.png"},{"@type":"BreadcrumbList","@id":"https:\/\/cyberelk.net\/tim\/2008\/02\/29\/print-job-failure-alerts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cyberelk.net\/tim\/"},{"@type":"ListItem","position":2,"name":"Print job failure alerts"}]},{"@type":"WebSite","@id":"https:\/\/cyberelk.net\/tim\/#website","url":"https:\/\/cyberelk.net\/tim\/","name":"PRINT HEAD","description":"","publisher":{"@id":"https:\/\/cyberelk.net\/tim\/#\/schema\/person\/23b749f30a67f1b1c6af17024fc94bf6"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cyberelk.net\/tim\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/cyberelk.net\/tim\/#\/schema\/person\/23b749f30a67f1b1c6af17024fc94bf6","name":"Tim Waugh","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2023\/01\/printhead.png","url":"https:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2023\/01\/printhead.png","contentUrl":"https:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2023\/01\/printhead.png","width":731,"height":140,"caption":"Tim Waugh"},"logo":{"@id":"https:\/\/cyberelk.net\/tim\/wp-content\/uploads\/2023\/01\/printhead.png"},"sameAs":["http:\/\/cyberelk.net\/tim"],"url":"https:\/\/cyberelk.net\/tim\/author\/twaugh\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pnnS2-3S","_links":{"self":[{"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":1,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":1085,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/posts\/240\/revisions\/1085"}],"wp:attachment":[{"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cyberelk.net\/tim\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}