<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nxnt.org</title>
	<atom:link href="http://www.nxnt.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nxnt.org</link>
	<description>New eXperiences, New Technologies</description>
	<lastBuildDate>Tue, 04 Oct 2011 15:04:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>tifftopdf on cups, enhanced</title>
		<link>http://www.nxnt.org/2011/10/tifftopdf-on-cups-enhanced/</link>
		<comments>http://www.nxnt.org/2011/10/tifftopdf-on-cups-enhanced/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 15:02:27 +0000</pubDate>
		<dc:creator>nicola</dc:creator>
				<category><![CDATA[Sysadmin]]></category>

		<guid isPermaLink="false">http://www.nxnt.org/?p=60</guid>
		<description><![CDATA[Hi, trying to print some tiff I got tons of resize errors&#8230; so I decided to write a simple wrapper for tiff2pdf and pdftopdf for CUPS. #!/bin/sh TMP_FILE=$&#40;mktemp&#41; tiff2pdf &#34;$6&#34; &#62; $TMP_FILE 2&#62; /dev/null /usr/lib/cups/filter/pdftopdf &#34;$1&#34; &#34;$2&#34; &#34;$3&#34; &#34;$4&#34; &#34;$5&#34; &#34;$TMP_FILE&#34; rm -f &#34;$TMP_FILE&#34; 2&#62; /dev/null Name this file &#8220;tifftopdf&#8221; and put it in /usr/lib/cups/filter. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
trying to print some tiff I got tons of resize errors&#8230; so I decided to write a simple wrapper for tiff2pdf and pdftopdf for CUPS.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">TMP_FILE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">mktemp</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
tiff2pdf <span style="color: #ff0000;">&quot;$6&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMP_FILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cups<span style="color: #000000; font-weight: bold;">/</span>filter<span style="color: #000000; font-weight: bold;">/</span>pdftopdf <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> <span style="color: #ff0000;">&quot;$3&quot;</span> <span style="color: #ff0000;">&quot;$4&quot;</span> <span style="color: #ff0000;">&quot;$5&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TMP_FILE</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TMP_FILE</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<p>Name this file &#8220;tifftopdf&#8221; and put it in /usr/lib/cups/filter. Make it executable and modify your /usr/share/cups/mime/mime.conv in order to use it instead of imagetopdf.</p>
<p>Enjoy!</p>
<p>Nicola</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nxnt.org/2011/10/tifftopdf-on-cups-enhanced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cupsmail</title>
		<link>http://www.nxnt.org/2011/03/cupsmail/</link>
		<comments>http://www.nxnt.org/2011/03/cupsmail/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 13:03:06 +0000</pubDate>
		<dc:creator>nicola</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[cups notifier email perl]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[notifier]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://www.nxnt.org/?p=41</guid>
		<description><![CDATA[Hi all, i was developing this perl script with te aim to substitute cups native (and poor) email notifier. you should place this file (depending on your distro) on: /usr/lib/cups/notifier and rename it to: cupsmail. Now when invoking lp job with option: lp -d &#60;printer&#62; -o notify-recipient-uri=cupsmail://err:&#60;destination_email&#62; &#60;file_to_print&#62; this notify by email only printing errors [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>i was developing this perl script with te aim to substitute cups native (and poor) email notifier.</p>
<p>you should place this file (depending on your distro) on: <strong>/usr/lib/cups/notifier</strong> and rename it to: <strong>cupsmail</strong>.</p>
<p>Now when invoking lp job with option:</p>
<p><strong>lp -d &lt;printer&gt; -o notify-recipient-uri=cupsmail://err:&lt;destination_email&gt; &lt;file_to_print&gt;</strong></p>
<p>this notify by email only printing errors</p>
<p>or</p>
<p><strong>lp -d &lt;printer&gt; -o notify-recipient-uri=cupsmail://all:&lt;destination_email&gt; &lt;file_to_print&gt;</strong></p>
<p>this notify by email all printing job status</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Catch all notifier</span>
<span style="color: #666666; font-style: italic;"># based on Net::IPP::IPPRequest by Matthias Hilbig</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Nicola Ruggero 2011 &lt;nicola.ruggero@gmail.com&gt;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># ====================================================================</span>
<span style="color: #666666; font-style: italic;"># This program is free software: you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;"># it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;"># the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #666666; font-style: italic;"># (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;"># GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;"># along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #666666; font-style: italic;"># ====================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Data<span style="color: #339933;">::</span><span style="color: #006600;">Dumper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> MIME<span style="color: #339933;">::</span><span style="color: #006600;">Lite</span><span style="color: #339933;">::</span><span style="color: #006600;">TT</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Sys<span style="color: #339933;">::</span><span style="color: #006600;">Hostname</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">######## Globals and Constants ########</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$local_hostname</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$local_hostname</span> <span style="color: #339933;">=</span> hostname<span style="color: #339933;">;</span>
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$VERSION</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$debug</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$notification_level</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$email</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cmd_argument</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#### CONSTANTS ####</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###</span>
<span style="color: #666666; font-style: italic;"># register constants</span>
<span style="color: #666666; font-style: italic;"># (modified standard perl constant.pm without all the checking)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">sub</span> registerConstants <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$tableref</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%constants</span> <span style="color: #339933;">=</span> <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span><span style="color: #339933;">+</span><span style="color: #000066;">shift</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$name</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066;">keys</span> <span style="color: #0000ff;">%constants</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pkg</span> <span style="color: #339933;">=</span> <span style="color: #000066;">caller</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066;">no</span> strict <span style="color: #ff0000;">'refs'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$full_name</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;${pkg}::$name&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$scalar</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$constants</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$name</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">*$full_name</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$scalar</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #0000ff;">$tableref</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$scalar</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$name</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># IPP Version</span>
<span style="color: #000000; font-weight: bold;">use</span> constant IPP_MAJOR_VERSION <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> constant IPP_MINOR_VERSION <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># IPP Types</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%type</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%type</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     DELETE_ATTRIBUTE <span style="color: #339933;">=&gt;</span> 0x16<span style="color: #339933;">,</span> 
     INTEGER <span style="color: #339933;">=&gt;</span> 0x21<span style="color: #339933;">,</span>
     BOOLEAN <span style="color: #339933;">=&gt;</span> 0x22<span style="color: #339933;">,</span>
     ENUM <span style="color: #339933;">=&gt;</span> 0x23<span style="color: #339933;">,</span>
     OCTET_STRING <span style="color: #339933;">=&gt;</span> 0x30<span style="color: #339933;">,</span>
     DATE_TIME <span style="color: #339933;">=&gt;</span> 0x31<span style="color: #339933;">,</span>
     RESOLUTION <span style="color: #339933;">=&gt;</span> 0x32<span style="color: #339933;">,</span>
     RANGE_OF_INTEGER <span style="color: #339933;">=&gt;</span> 0x33<span style="color: #339933;">,</span>
     BEG_COLLECTION <span style="color: #339933;">=&gt;</span> 0x34<span style="color: #339933;">,</span>
     TEXT_WITH_LANGUAGE <span style="color: #339933;">=&gt;</span> 0x35<span style="color: #339933;">,</span>
     NAME_WITH_LANGUAGE <span style="color: #339933;">=&gt;</span> 0x36<span style="color: #339933;">,</span>
     END_COLLECTION <span style="color: #339933;">=&gt;</span> 0x37<span style="color: #339933;">,</span>
     TEXT_WITHOUT_LANGUAGE <span style="color: #339933;">=&gt;</span> 0x41<span style="color: #339933;">,</span>
     NAME_WITHOUT_LANGUAGE <span style="color: #339933;">=&gt;</span> 0x42<span style="color: #339933;">,</span>
     KEYWORD <span style="color: #339933;">=&gt;</span> 0x44<span style="color: #339933;">,</span>
     URI <span style="color: #339933;">=&gt;</span> 0x45<span style="color: #339933;">,</span>
     URI_SCHEME <span style="color: #339933;">=&gt;</span> 0x46<span style="color: #339933;">,</span>
     CHARSET <span style="color: #339933;">=&gt;</span> 0x47<span style="color: #339933;">,</span>
     NATURAL_LANGUAGE <span style="color: #339933;">=&gt;</span> 0x48<span style="color: #339933;">,</span>
     MIME_MEDIA_TYPE <span style="color: #339933;">=&gt;</span> 0x49<span style="color: #339933;">,</span>
     MEMBER_ATTR_NAME <span style="color: #339933;">=&gt;</span> 0x4A<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># IPP Group tags</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%group</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%group</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
	OPERATION_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x01<span style="color: #339933;">,</span>
	JOB_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x02<span style="color: #339933;">,</span>
	END_OF_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x03<span style="color: #339933;">,</span>
	PRINTER_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x04<span style="color: #339933;">,</span>
	UNSUPPORTED_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x05<span style="color: #339933;">,</span>
	SUBSCRIPTION_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x06<span style="color: #339933;">,</span>
	EVENT_NOTIFICATION_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x07
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># IPP Operations</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%operation</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%operation</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    IPP_PRINT_JOB <span style="color: #339933;">=&gt;</span> 0x0002<span style="color: #339933;">,</span>
    IPP_PRINT_URI <span style="color: #339933;">=&gt;</span> 0x0003<span style="color: #339933;">,</span>
    IPP_VALIDATE_JOB <span style="color: #339933;">=&gt;</span> 0x0004<span style="color: #339933;">,</span>
    IPP_CREATE_JOB <span style="color: #339933;">=&gt;</span> 0x0005<span style="color: #339933;">,</span>
    IPP_SEND_DOCUMENT <span style="color: #339933;">=&gt;</span> 0x0006<span style="color: #339933;">,</span>
    IPP_SEND_URI <span style="color: #339933;">=&gt;</span> 0x0007<span style="color: #339933;">,</span>
    IPP_CANCEL_JOB <span style="color: #339933;">=&gt;</span> 0x0008<span style="color: #339933;">,</span>
    IPP_GET_JOB_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x0009<span style="color: #339933;">,</span>
    IPP_GET_JOBS <span style="color: #339933;">=&gt;</span> 0x000a<span style="color: #339933;">,</span>
    IPP_GET_PRINTER_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x000b<span style="color: #339933;">,</span>
    IPP_HOLD_JOB <span style="color: #339933;">=&gt;</span> 0x000c<span style="color: #339933;">,</span>
    IPP_RELEASE_JOB <span style="color: #339933;">=&gt;</span> 0x000d<span style="color: #339933;">,</span>
    IPP_RESTART_JOB <span style="color: #339933;">=&gt;</span> 0x000e<span style="color: #339933;">,</span>
&nbsp;
    IPP_PAUSE_PRINTER <span style="color: #339933;">=&gt;</span> 0x0010<span style="color: #339933;">,</span>
    IPP_RESUME_PRINTER <span style="color: #339933;">=&gt;</span> 0x0011<span style="color: #339933;">,</span>
    IPP_PURGE_JOBS <span style="color: #339933;">=&gt;</span> 0x0012<span style="color: #339933;">,</span>
    IPP_SET_PRINTER_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x0013<span style="color: #339933;">,</span>
    IPP_SET_JOB_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x0014<span style="color: #339933;">,</span>
    IPP_GET_PRINTER_SUPPORTED_VALUES <span style="color: #339933;">=&gt;</span> 0x0015<span style="color: #339933;">,</span>
    IPP_CREATE_PRINTER_SUBSCRIPTION <span style="color: #339933;">=&gt;</span> 0x0016<span style="color: #339933;">,</span>
    IPP_CREATE_JOB_SUBSCRIPTION <span style="color: #339933;">=&gt;</span> 0x0017<span style="color: #339933;">,</span>
    IPP_GET_SUBSCRIPTION_ATTRIBUTES <span style="color: #339933;">=&gt;</span> 0x0018<span style="color: #339933;">,</span>
    IPP_GET_SUBSCRIPTIONS <span style="color: #339933;">=&gt;</span> 0x0019<span style="color: #339933;">,</span>
    IPP_RENEW_SUBSCRIPTION <span style="color: #339933;">=&gt;</span> 0x001a<span style="color: #339933;">,</span>
    IPP_CANCEL_SUBSCRIPTION <span style="color: #339933;">=&gt;</span> 0x001b<span style="color: #339933;">,</span>
    IPP_GET_NOTIFICATIONS <span style="color: #339933;">=&gt;</span> 0x001c<span style="color: #339933;">,</span>
    IPP_SEND_NOTIFICATIONS <span style="color: #339933;">=&gt;</span> 0x001d<span style="color: #339933;">,</span>
&nbsp;
    IPP_GET_PRINT_SUPPORT_FILES <span style="color: #339933;">=&gt;</span> 0x0021<span style="color: #339933;">,</span>
    IPP_ENABLE_PRINTER <span style="color: #339933;">=&gt;</span> 0x0022<span style="color: #339933;">,</span>
    IPP_DISABLE_PRINTER <span style="color: #339933;">=&gt;</span> 0x0023<span style="color: #339933;">,</span>
    IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB <span style="color: #339933;">=&gt;</span> 0x0024<span style="color: #339933;">,</span>
    IPP_HOLD_NEW_JOBS <span style="color: #339933;">=&gt;</span> 0x0025<span style="color: #339933;">,</span>
    IPP_RELEASE_HELD_NEW_JOBS <span style="color: #339933;">=&gt;</span> 0x0026<span style="color: #339933;">,</span>
    IPP_DEACTIVATE_PRINTER <span style="color: #339933;">=&gt;</span> 0x0027<span style="color: #339933;">,</span>
    IPP_ACTIVATE_PRINTER <span style="color: #339933;">=&gt;</span> 0x0028<span style="color: #339933;">,</span>
    IPP_RESTART_PRINTER <span style="color: #339933;">=&gt;</span> 0x0029<span style="color: #339933;">,</span>
    IPP_SHUTDOWN_PRINTER <span style="color: #339933;">=&gt;</span> 0x002a<span style="color: #339933;">,</span>
    IPP_STARTUP_PRINTER <span style="color: #339933;">=&gt;</span> 0x002b<span style="color: #339933;">,</span>
    IPP_REPROCESS_JOB <span style="color: #339933;">=&gt;</span> 0x002c<span style="color: #339933;">,</span>
    IPP_CANCEL_CURRENT_JOB <span style="color: #339933;">=&gt;</span> 0x002d<span style="color: #339933;">,</span>
    IPP_SUSPEND_CURRENT_JOB <span style="color: #339933;">=&gt;</span> 0x002e<span style="color: #339933;">,</span>
    IPP_RESUME_JOB <span style="color: #339933;">=&gt;</span> 0x002f<span style="color: #339933;">,</span>
    IPP_PROMOTE_JOB <span style="color: #339933;">=&gt;</span> 0x0030<span style="color: #339933;">,</span>
    IPP_SCHEDULE_JOB_AFTER <span style="color: #339933;">=&gt;</span> 0x0031<span style="color: #339933;">,</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># IPP private Operations start at 0x4000</span>
    CUPS_GET_DEFAULT <span style="color: #339933;">=&gt;</span> 0x4001<span style="color: #339933;">,</span>
    CUPS_GET_PRINTERS <span style="color: #339933;">=&gt;</span> 0x4002<span style="color: #339933;">,</span>
    CUPS_ADD_PRINTER <span style="color: #339933;">=&gt;</span> 0x4003<span style="color: #339933;">,</span>
    CUPS_DELETE_PRINTER <span style="color: #339933;">=&gt;</span> 0x4004<span style="color: #339933;">,</span>
    CUPS_GET_CLASSES <span style="color: #339933;">=&gt;</span> 0x4005<span style="color: #339933;">,</span>
    CUPS_ADD_CLASS <span style="color: #339933;">=&gt;</span> 0x4006<span style="color: #339933;">,</span>
    CUPS_DELETE_CLASS <span style="color: #339933;">=&gt;</span> 0x4007<span style="color: #339933;">,</span>
    CUPS_ACCEPT_JOBS <span style="color: #339933;">=&gt;</span> 0x4008<span style="color: #339933;">,</span>
    CUPS_REJECT_JOBS <span style="color: #339933;">=&gt;</span> 0x4009<span style="color: #339933;">,</span>
    CUPS_SET_DEFAULT <span style="color: #339933;">=&gt;</span> 0x400a<span style="color: #339933;">,</span>
    CUPS_GET_DEVICES <span style="color: #339933;">=&gt;</span> 0x400b<span style="color: #339933;">,</span>
    CUPS_GET_PPDS <span style="color: #339933;">=&gt;</span> 0x400c<span style="color: #339933;">,</span>
    CUPS_MOVE_JOB <span style="color: #339933;">=&gt;</span> 0x400d<span style="color: #339933;">,</span>
    CUPS_ADD_DEVICE <span style="color: #339933;">=&gt;</span> 0x400e<span style="color: #339933;">,</span>
    CUPS_DELETE_DEVICE <span style="color: #339933;">=&gt;</span> 0x400f<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Finishings</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%finishing</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%finishing</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
  FINISHINGS_NONE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
  FINISHINGS_PUNCH <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
  FINISHINGS_COVER <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>
  FINISHINGS_BIND <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span>
  FINISHINGS_SADDLE_STITCH <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span>
  FINISHINGS_EDGE_STITCH <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span>
  FINISHINGS_FOLD <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>
  FINISHINGS_TRIM <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">,</span>
  FINISHINGS_BALE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span>
  FINISHINGS_BOOKLET_MAKER <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">,</span>
  FINISHINGS_JOB_OFFSET <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">14</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_TOP_LEFT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_BOTTOM_LEFT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">21</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_TOP_RIGHT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">22</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_BOTTOM_RIGHT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">23</span><span style="color: #339933;">,</span>
  FINISHINGS_EDGE_STITCH_LEFT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">24</span><span style="color: #339933;">,</span>
  FINISHINGS_EDGE_STITCH_TOP <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span>
  FINISHINGS_EDGE_STITCH_RIGHT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26</span><span style="color: #339933;">,</span>
  FINISHINGS_EDGE_STITCH_BOTTOM <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">27</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_DUAL_LEFT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">28</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_DUAL_TOP <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">29</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_DUAL_RIGHT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span>
  FINISHINGS_STAPLE_DUAL_BOTTOM <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">31</span><span style="color: #339933;">,</span>
  FINISHINGS_BIND_LEFT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span>
  FINISHINGS_BIND_TOP <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">51</span><span style="color: #339933;">,</span>
  FINISHINGS_BIND_RIGHT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">52</span><span style="color: #339933;">,</span>
  FINISHINGS_BIND_BOTTOM <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">53</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># IPP Printer state</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%printerState</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%printerState</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    STATE_IDLE<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
    STATE_PROCESSING <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
    STATE_STOPPED <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Job state</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%jobState</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%jobState</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    JOBSTATE_PENDING <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
    JOBSTATE_PENDING_HELD <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
    JOBSTATE_PROCESSING <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
    JOBSTATE_PROCESSING_STOPPED <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>
    JOBSTATE_CANCELED <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span>
    JOBSTATE_ABORTED <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span>
    JOBSTATE_COMPLETED <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Orientations</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%orientation</span><span style="color: #339933;">;</span>
registerConstants<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\%orientation</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
	ORIENTATION_PORTRAIT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>          <span style="color: #666666; font-style: italic;"># no rotation</span>
	ORIENTATION_LANDSCAPE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>         <span style="color: #666666; font-style: italic;"># 90 degrees counter-clockwise</span>
	ORIENTATION_REVERSE_LANDSCAPE <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;"># 90 degrees clockwise</span>
	ORIENTATION_REVERSE_PORTRAIT <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;"># 180 degrees</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">%statusCodes</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
                 0x0000 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok&quot;</span><span style="color: #339933;">,</span>
                 0x0001 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-ignored-or-substituted-attributes&quot;</span><span style="color: #339933;">,</span>
                 0x0002 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-conflicting-attributes&quot;</span><span style="color: #339933;">,</span>
                 0x0003 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-ignored-subscriptions&quot;</span><span style="color: #339933;">,</span>
                 0x0004 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-ignored-notifications&quot;</span><span style="color: #339933;">,</span>
                 0x0005 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-too-many-events&quot;</span><span style="color: #339933;">,</span>
                 0x0006 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;successful-ok-but-cancel-subscription&quot;</span><span style="color: #339933;">,</span>
		    <span style="color: #666666; font-style: italic;"># Client errors</span>
                 0x0400 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-bad-request&quot;</span><span style="color: #339933;">,</span>
                 0x0401 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-forbidden&quot;</span><span style="color: #339933;">,</span>
                 0x0402 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-not-authenticated&quot;</span><span style="color: #339933;">,</span>
                 0x0403 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-not-authorized&quot;</span><span style="color: #339933;">,</span>
                 0x0404 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-not-possible&quot;</span><span style="color: #339933;">,</span>
                 0x0405 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-timeout&quot;</span><span style="color: #339933;">,</span>
                 0x0406 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-not-found&quot;</span><span style="color: #339933;">,</span>
                 0x0407 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-gone&quot;</span><span style="color: #339933;">,</span>
                 0x0408 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-request-entity-too-large&quot;</span><span style="color: #339933;">,</span>
                 0x0409 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-request-value-too-long&quot;</span><span style="color: #339933;">,</span>
                 0x040a <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-document-format-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x040b <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-attributes-or-values-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x040c <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-uri-scheme-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x040d <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-charset-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x040e <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-conflicting-attributes&quot;</span><span style="color: #339933;">,</span>
                 0x040f <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-compression-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x0410 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-compression-error&quot;</span><span style="color: #339933;">,</span>
                 0x0411 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-document-format-error&quot;</span><span style="color: #339933;">,</span>
                 0x0412 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-document-access-error&quot;</span><span style="color: #339933;">,</span>
                 0x0413 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-attributes-not-settable&quot;</span><span style="color: #339933;">,</span>
                 0x0414 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-ignored-all-subscriptions&quot;</span><span style="color: #339933;">,</span>
                 0x0415 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-too-many-subscriptions&quot;</span><span style="color: #339933;">,</span>
                 0x0416 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-ignored-all-notifications&quot;</span><span style="color: #339933;">,</span>
                 0x0417 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;client-error-print-support-file-not-found&quot;</span><span style="color: #339933;">,</span>
		    <span style="color: #666666; font-style: italic;">#Server errors</span>
                 0x0500 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-internal-error&quot;</span><span style="color: #339933;">,</span>
                 0x0501 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-operation-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x0502 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-service-unavailable&quot;</span><span style="color: #339933;">,</span>
                 0x0503 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-version-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x0504 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-device-error&quot;</span><span style="color: #339933;">,</span>
                 0x0505 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-temporary-error&quot;</span><span style="color: #339933;">,</span>
                 0x0506 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-not-accepting-jobs&quot;</span><span style="color: #339933;">,</span>
                 0x0507 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-busy&quot;</span><span style="color: #339933;">,</span>
                 0x0508 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-job-canceled&quot;</span><span style="color: #339933;">,</span>
                 0x0509 <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-multiple-document-jobs-not-supported&quot;</span><span style="color: #339933;">,</span>
                 0x050a <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;server-error-printer-is-deactivated&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Parse command line</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$cmd_argument</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">or</span> usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$cmd_argument</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/cupsmail:\/\/(\w{3}):(.*\@.*)/</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$notification_level</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$email</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> 
  <span style="color: #009900;">&#123;</span>
    usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$email</span> <span style="color: #339933;">!~</span> <span style="color: #009966; font-style: italic;">/\@/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$notification_level</span> <span style="color: #339933;">!~</span> <span style="color: #009966; font-style: italic;">/(?:err|all)/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Starting Cupsmail notification service $VERSION on $local_hostname<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Command line dump: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">join</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Initialize IPP response structure</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	HTTP_CODE <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'200'</span><span style="color: #339933;">,</span>
	HTTP_MESSAGE <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'OK'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Read IPP bytes from STDIN</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Reading raw IPP data from stdin...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;STDIN&gt;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Decode IPP bytes and convert to perl structure</span>
<span style="color: #000066;">print</span> hexdump<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
decodeIPPHeader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
decodeIPPGroups<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;IPP Perl Structure Dump:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> Dumper<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'job-state'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">==</span> 0x9<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$notification_level</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/all/</span><span style="color: #009900;">&#41;</span>
	  <span style="color: #009900;">&#123;</span>
		do_send_mail<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ok&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$email</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">warn</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Unable to send mail<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
  <span style="color: #009900;">&#123;</span>
	do_send_mail<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ko&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$email</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">warn</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Unable to send mail<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">######## Functions ########</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> usage <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Usage: $0  [all|err]:username<span style="color: #000099; font-weight: bold;">\@</span>domain.com notify-user-data<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> decodeIPPHeader <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span> <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$majorVersion</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$minorVersion</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$status</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$requestId</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CCnN&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>VERSION<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$majorVersion</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$minorVersion</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>STATUS<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$status</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>REQUEST_ID<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$requestId</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> decodeIPPGroups <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># begin directly after IPPHeader (length 8 byte)</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$currentGroup</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span>
			<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Expected Group Tag at begin of IPP response. Not enough bytes.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$offset</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #0000ff;">$offset</span><span style="color: #339933;">++;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$group</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$type</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;group $type found<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$currentGroup</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">push</span> <span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$currentGroup</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&amp;END_OF_ATTRIBUTES</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #0000ff;">$currentGroup</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
					TYPE <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$type</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$currentGroup</span> <span style="color: #b1b100;">eq</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Expected Group Tag at begin of IPP response.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			decodeAttribute<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$type</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$currentGroup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&amp;END_OF_ATTRIBUTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> hexdump <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;c*&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#how many bytes to print per line</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hexWidth</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #0000ff;">*$width</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$offset</span> <span style="color: #0000ff;">*$width</span> <span style="color: #339933;">&lt;</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hexString</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
    	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$charString</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span> 
    	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$width</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$offset</span><span style="color: #0000ff;">*$width</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$char</span><span style="color: #339933;">;</span>
    			<span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span><span style="color: #0000ff;">$char</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$offset</span><span style="color: #0000ff;">*$width</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    			<span style="color: #0000ff;">$hexString</span> <span style="color: #339933;">.=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%02X &quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$char</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/[\w\-\:]/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    				<span style="color: #0000ff;">$charString</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$char</span><span style="color: #339933;">;</span>
    			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    				<span style="color: #0000ff;">$charString</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #339933;">;</span>
    			<span style="color: #009900;">&#125;</span>
    		<span style="color: #009900;">&#125;</span>
    	<span style="color: #009900;">&#125;</span>
&nbsp;
    	<span style="color: #0000ff;">$string</span> <span style="color: #339933;">.=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%-${hexWidth}s%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$hexString</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$charString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #0000ff;">$offset</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066;">return</span> <span style="color: #0000ff;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$previousKey</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># used for 1setOf values</span>
<span style="color: #000000; font-weight: bold;">sub</span> decodeAttribute <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$offsetref</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$group</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$$offsetref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$addValue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	testLengths<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$$offsetref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;n/a* n/a*&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	testKey<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$$offsetref</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">+</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;decoding attribute <span style="color: #000099; font-weight: bold;">\&quot;</span>$key<span style="color: #000099; font-weight: bold;">\&quot;</span> =&gt; $type{$type}(&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%#x&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$type</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$value</span> <span style="color: #339933;">=</span> transformValue<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># if key empty, attribute is 1setOf</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">ref</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$previousKey</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$arrayref</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$previousKey</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #0000ff;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$previousKey</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$arrayref</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> 
		<span style="color: #000066;">push</span> <span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$previousKey</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$key</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$previousKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$key</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> testLengths <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">use</span> bytes<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$bytes</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$keyLength</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$offset</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$offset</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$keyLength</span> <span style="color: #339933;">&gt;</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dump</span> <span style="color: #339933;">=</span> hexdump<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">&quot;---IPP RESPONSE DUMP (current offset: $offset):---<span style="color: #000099; font-weight: bold;">\n</span>$dump<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ERROR: IPP response is not RFC conform.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$valueLength</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$offset</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$keyLength</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$offset</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$keyLength</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$valueLength</span> <span style="color: #339933;">&gt;</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dump</span> <span style="color: #339933;">=</span> hexdump<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">&quot;---IPP RESPONSE DUMP (current offset: $offset):<span style="color: #000099; font-weight: bold;">\n</span>---$dump<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ERROR: IPP response is not RFC conform.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> testKey <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #0000ff;">$key</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^[\w\-]*$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Probably wrong attribute key: $key<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> transformValue <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;TEXT_WITHOUT_LANGUAGE</span> 
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;NAME_WITHOUT_LANGUAGE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  textWithoutLanguage,  LOCALIZED-STRING.</span>
				<span style="color: #666666; font-style: italic;">#RFC:  nameWithoutLanguage</span>
				<span style="color: #000066;">return</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;TEXT_WITH_LANGUAGE</span> 
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;NAME_WITH_LANGUAGE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  textWithLanguage      OCTET-STRING consisting of 4 fields:</span>
				<span style="color: #666666; font-style: italic;">#RFC:                          a. a SIGNED-SHORT which is the number of</span>
				<span style="color: #666666; font-style: italic;">#RFC:                             octets in the following field</span>
				<span style="color: #666666; font-style: italic;">#RFC:                          b. a value of type natural-language,</span>
				<span style="color: #666666; font-style: italic;">#RFC:                          c. a SIGNED-SHORT which is the number of</span>
				<span style="color: #666666; font-style: italic;">#RFC:                             octets in the following field,</span>
				<span style="color: #666666; font-style: italic;">#RFC:                          d. a value of type textWithoutLanguage.</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        The length of a textWithLanguage value MUST be</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        4 + the value of field a + the value of field c.</span>
				<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$language</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;n/a*n/a*&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;$language, $text&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;CHARSET</span>
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;NATURAL_LANGUAGE</span>
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;MIME_MEDIA_TYPE</span>
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;KEYWORD</span>
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;URI</span>
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;URI_SCHEME</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  charset,              US-ASCII-STRING.</span>
				<span style="color: #666666; font-style: italic;">#RFC:  naturalLanguage,</span>
				<span style="color: #666666; font-style: italic;">#RFC:  mimeMediaType,</span>
				<span style="color: #666666; font-style: italic;">#RFC:  keyword, uri, and</span>
				<span style="color: #666666; font-style: italic;">#RFC:  uriScheme</span>
				<span style="color: #000066;">return</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;BOOLEAN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  boolean               SIGNED-BYTE  where 0x00 is 'false' and 0x01 is</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        'true'.</span>
				<span style="color: #000066;">return</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;INTEGER</span> 
			<span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;ENUM</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  integer and enum      a SIGNED-INTEGER.</span>
				<span style="color: #000066;">return</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;N&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;DATE_TIME</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  dateTime              OCTET-STRING consisting of eleven octets whose</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        contents are defined by &quot;DateAndTime&quot; in RFC</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        1903 [RFC1903].</span>
				<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$year</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$month</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$day</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$minute</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$seconds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$deciSeconds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$direction</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$utcHourDiff</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$utcMinuteDiff</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;nCCCCCCaCC&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;$month-$day-$year,$hour:$minute:$seconds.$deciSeconds,$direction$utcHourDiff:$utcMinuteDiff&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;RESOLUTION</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  resolution            OCTET-STRING consisting of nine octets of  2</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        SIGNED-INTEGERs followed by a SIGNED-BYTE. The</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        first SIGNED-INTEGER contains the value of</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        cross feed direction resolution. The second</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        SIGNED-INTEGER contains the value of feed</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        direction resolution. The SIGNED-BYTE contains</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        the units				</span>
				<span style="color: #666666; font-style: italic;">#                        unit: 3 = dots per inch</span>
				<span style="color: #666666; font-style: italic;">#                              4 = dots per cm</span>
				<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$crossFeedResolution</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$feedResolution</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$unit</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;NNc&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$unitText</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$unit</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #0000ff;">$unitText</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;dpi&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$unit</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #0000ff;">$unitText</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;dpc&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Unknown Unit value: $unit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #0000ff;">$unitText</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$unit</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;$crossFeedResolution, $feedResolution $unitText&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;RANGE_OF_INTEGER</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  rangeOfInteger        Eight octets consisting of 2 SIGNED-INTEGERs.</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        The first SIGNED-INTEGER contains the lower</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        bound and the second SIGNED-INTEGER contains</span>
				<span style="color: #666666; font-style: italic;">#RFC:                        the upper bound.</span>
				<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lowerBound</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$upperBound</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;NN&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;$lowerBound:$upperBound&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;OCTET_STRING</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">#RFC:  octetString           OCTET-STRING</span>
				<span style="color: #000066;">return</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;BEG_COLLECTION</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;WARNING: Collection Syntax not supported. Attribute <span style="color: #000099; font-weight: bold;">\&quot;</span>$key<span style="color: #000099; font-weight: bold;">\&quot;</span> will have invalid value.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;END_COLLECTION</span>
	      <span style="color: #339933;">||</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&amp;MEMBER_ATTR_NAME</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">return</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Unknown Value type &quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%#lx&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$type</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot; for key <span style="color: #000099; font-weight: bold;">\&quot;</span>$key<span style="color: #000099; font-weight: bold;">\&quot;</span>. Performing no transformation.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">return</span> <span style="color: #0000ff;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> do_send_mail <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$email_type</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dest_email</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$template</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$subject</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sysadmin_cc</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$email_type</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/ok/i</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
	    <span style="color: #0000ff;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'[OK] Printing job completed'</span><span style="color: #339933;">;</span>
	    <span style="color: #0000ff;">$sysadmin_cc</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">;</span>
	    <span style="color: #0000ff;">$template</span> <span style="color: #339933;">=</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;TEMPLATE;
&nbsp;
Print job successfully completed by your printer.
&nbsp;
-- Details --------------------------------------------------------
job-id            : [% job_id %]
printer-name      : [% printer_name %]
job-name          : [% job_name %]
job-state         : [% job_state %]
job-state-reasons : [% job_state_reasons %]
&nbsp;
TEMPLATE</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
      <span style="color: #009900;">&#123;</span>
      	    <span style="color: #0000ff;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'[WARN] Printing service alert'</span><span style="color: #339933;">;</span>
	    <span style="color: #0000ff;">$sysadmin_cc</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'myemail@mydomain.it'</span><span style="color: #339933;">;</span>
	    <span style="color: #0000ff;">$template</span> <span style="color: #339933;">=</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;TEMPLATE;
&nbsp;
Error printing the following job.
Please recover such job or contact your system administrator.
&nbsp;
-- Details --------------------------------------------------------
job-id            : [% job_id %]
printer-name      : [% printer_name %]
job-name          : [% job_name %]
job-state         : [% job_state %]
job-state-reasons : [% job_state_reasons %]
&nbsp;
TEMPLATE</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%params</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
		job_id <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'notify-job-id'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		printer_name <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'printer-name'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		job_name <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'job-name'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		job_state <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$jobState</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'job-state'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; (%#x)&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'job-state'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		job_state_reasons <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>GROUPS<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'job-state-reasons'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%options</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EVAL_PERL<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$msg</span> <span style="color: #339933;">=</span> MIME<span style="color: #339933;">::</span><span style="color: #006600;">Lite</span><span style="color: #339933;">::</span><span style="color: #006600;">TT</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>
		From <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'Batch Printing Service &lt;root@'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$local_hostname</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">'&gt;'</span><span style="color: #339933;">,</span>
		To <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$dest_email</span><span style="color: #339933;">,</span>
		Cc <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$sysadmin_cc</span><span style="color: #339933;">,</span>
		Subject <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$subject</span><span style="color: #339933;">,</span>
		Template <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\$template</span><span style="color: #339933;">,</span>
		TmplParams <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\%params</span><span style="color: #339933;">,</span>
		TmplOptions <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\%options</span><span style="color: #339933;">,</span>
	    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Sending notification mail to: $dest_email - type: <span style="color: #000099; font-weight: bold;">\&quot;</span>$email_type<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000066;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nxnt.org/2011/03/cupsmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RedHat Cluster howto</title>
		<link>http://www.nxnt.org/2010/09/redhat-cluster-howto/</link>
		<comments>http://www.nxnt.org/2010/09/redhat-cluster-howto/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 13:55:57 +0000</pubDate>
		<dc:creator>nicola</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Gnu/Linux]]></category>
		<category><![CDATA[RHCS]]></category>

		<guid isPermaLink="false">http://www.nxnt.org/?p=21</guid>
		<description><![CDATA[Introduction Here I wrote up a little tutorial how to configure a standard RHEL cluster. Configuring a RHEL cluster is quite easy but documentation is sparse and not well organized. We will configure a 4 nodes cluster with shared storage and Heatbeat over a different NIC (not the main data link). Cluster configuration goals Shared [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Here I wrote up a little tutorial how to configure a standard RHEL cluster. Configuring a RHEL cluster is quite easy but documentation is sparse and not well organized. We will configure a 4 nodes cluster with shared storage and Heatbeat over a different NIC (not the main data link).</p>
<p><a name="Cluster_configuration_goals"></a></p>
<h2>Cluster configuration goals</h2>
<ul>
<li>Shared storage</li>
<li>HA-LVM: lvm failover configuration (like HP ServiceGuard) is different from clustered logical volume manager (clvm)!!</li>
<li>Bonded main data link (eg. bond0 &#8211;&gt; eth0 + eth1)</li>
<li>Hearthbeat on a different data link (eg. eth2)</li>
</ul>
<p><a name="Cluster_installation_steps"></a></p>
<h1>Cluster installation steps</h1>
<p><a name="OS_installation"></a></p>
<h2>OS installation</h2>
<p>First we performed a full CentOS 5.5 installation using kickstart, we also installed cluster packages like:</p>
<ul>
<li>cman</li>
<li>rgmanager</li>
<li>qdiskd</li>
<li>ccs_tools</li>
</ul>
<p>or</p>
<ul>
<li>@clustering (kickstart group)</li>
</ul>
<p><a name="Networking_configuration"></a></p>
<h2>Networking configuration</h2>
<p>We configure 2 different data link:</p>
<ol>
<li>Main data link (for applications)</li>
<li>Heartbeat data link (for cluster communication)</li>
</ol>
<p>Main data link (bond0) uses ethernet bonding over 2 phisycal eth (eth0, eth1). This configuration assures network high availability when some network paths fail.</p>
<p>Cluster communication (heartbeat) uses a dedicated ethernet link (eth2), configured in a diffentent network and vlan.</p>
<p>To obtain such configuration cerate this file <code>/etc/sysconfig/network-scripts/ifcfg-bond0</code> from scratch and fill it as below:</p>
<pre>DEVICE=bond0
IPADDR=&lt;your server main IP address (eg. 10.200.56.41)&gt;
NETMASK=&lt;your server main network mask (eg. 255.255.255.0)&gt;
NETWORK=&lt;your server main network (eg. 10.200.56.0)&gt;
BROADCAST=&lt;your server main network broadcast (eg. 10.200.56.255)&gt;
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS='miimon=100 mode=1'
GATEWAY=&lt;your server main default gateway (eg. 10.200.56.1)&gt;
TYPE=Ethernet</pre>
<p>You can customize <code>BONDING_OPT</code>. Please see bonding documentation.</p>
<p>Modify <code>/etc/sysconfig/network-scripts/ifcfg-eth{0,1}</code>:</p>
<pre>DEVICE=&lt;eth0 or eth1, etc...&gt;
USECTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
HWADDR=&lt;your eth MAC address (eg. 00:23:7d:3c:18:40)&gt;
ONBOOT=yes
TYPE=Ethernet</pre>
<p>Modify heartbeat nic <code>/etc/sysconfig/network-scripts/ifcfg-eth2</code>:</p>
<pre>DEVICE=eth2
HWADDR=&lt;your eth MAC address (eg. 00:23:7D:3C:CE:96)&gt;
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
NETMASK=&lt;your server heartbeat network mask (eg. 255.255.255.0)&gt;
IPADDR=&lt;your server main IP address (eg. 192.168.133.41)&gt;</pre>
<p>Note that heartbeat <code>eth2</code> has no default gateway configured. Normally this is not required unless this node is outside other node&#8217;s network and there are not specific static routes.</p>
<p>Add this line to <code>/etc/modprobe.conf</code>:</p>
<pre>alias bond0 bonding</pre>
<p>Add to <code>/etc/hosts</code> the informations about <strong>each</strong> cluster node and replicate the file among the nodes:</p>
<pre># These are example!!!
10.200.56.41            artu.yourdomain.com artu
192.168.133.41          h-artu.yourdomain.com h-artu

10.200.56.42            ginevra.yourdomain.com ginevra
192.168.133.42          h-ginevra.yourdomain.com h-ginevra

10.200.56.43            morgana.yourdomain.com morgana
192.168.133.43          h-morgana.yourdomain.com h-morgana

10.200.56.44            lancelot.yourdomain.com lancelot
192.168.133.44          h-lancelot.yourdomain.com h-lancelot</pre>
<p><a name="Logical_Volume_Manager_configuration"></a></p>
<h2>Logical Volume Manager configuration</h2>
<p>We choose not to use clustered logical volume manager (clvmd, sometimes called LVMFailover) but to use HA-LVM instead. HA-LVM is totally different from clvmd and it is quite similar di HP ServiceGuard behaviour.</p>
<p><a name="HA-LVM_features"></a></p>
<h3>HA-LVM features</h3>
<ul>
<li>No needs to run any daemon (like clvmd aka LVMFailover)</li>
<li>Each volume group can be activated exclusively on one node at a time</li>
<li>Volume group configuration is not replicated automatically among the nodes (need to run vgscan on the nodes)</li>
<li>Implementation not dipendent of the cluster status (can work without cluster running at all)</li>
</ul>
<p><a name="HA-LVM_howto"></a></p>
<h3>HA-LVM howto</h3>
<p>Configure <code>/etc/lvm/lvm.conf</code> as below:</p>
<p>Substitute existing <code>filter</code> with:</p>
<pre>filter = [ "a/dev/mpath/.*/", "a/c[0-9]d[0-9]p[0-9]$/", "a/sd*/", "r/.*/" ]</pre>
<p>check <code>locking_type</code>:</p>
<pre>locking_type = 1</pre>
<p>substitute existing <code>volume_list</code> with:</p>
<pre>volume_list = [ "vg00", "&lt;quorum disk volume group&gt;", "@&lt;hostname related to heartbeat nic&gt;" ]</pre>
<p>Where:</p>
<ul>
<li>vg00 is the name of the root volume group (always active)</li>
<li>&lt;quorum disk volume group&gt; is the name of the quorum disk volume group (always active)</li>
<li>@&lt;hostname related to heartbeat nic&gt; is a tag. Each volume group can have one tag at a time. Cluster lvm agents tag the volume groups with the hostname (present into configuration) in order to activate them. LVM activate only volume groups that contain such tag. In this way each volume group tagged can be activated and accessed by one node at a time (because of volume_list settings)</li>
</ul>
<p>At the end remember to regenerate initrd!</p>
<pre># mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)</pre>
<p><a name="Storage_configuration"></a></p>
<h2>Storage configuration</h2>
<p>Depending of your storage system, you should configure multipath, and <strong>each</strong> should be able to access to the same luns.</p>
<p><a name="Quorum_disk"></a></p>
<h2>Quorum disk</h2>
<p>Quorum disk is a 20MB LUN shared on the storage to all cluster nodes. This disk is used by the cluster to tie-break in case of split-brain events. Each node update its own information to the quorum disk. If some nodes experience network problems, the quorum disk assures that only the <strong>right</strong> group of nodes form the cluster but <strong>not</strong> both (split-brain)!</p>
<p><a name="Quorum_disk_creation"></a></p>
<h3>Quorum disk creation</h3>
<p>First be sure that <strong>each</strong> node can see the same 20MB LUN. Then, on the first node, create a physical volume:</p>
<pre># pvcreate /dev/mpath1</pre>
<p>create a dedicated volume group:</p>
<pre># vgcreate -s 8 vg_qdisk /dev/mpath1</pre>
<p>create a logical volume and extend it to maximun volume group size:</p>
<pre># lvcreate -l &lt;max_vg_pe&gt; -n lv_qdisk vg_qdisk</pre>
<p><strong>Make sure that this volume group is present into <code>volume_list</code> inside <code>/etc/lvm/lvm.conf</code>. It should be activated on all nodes!</strong></p>
<p>On the other nodes perform a:</p>
<pre># vgscan</pre>
<p>Should appear the quorum disk volume group.</p>
<p><a name="Quorum_disk_configuration"></a></p>
<h3>Quorum disk configuration</h3>
<p>Now we have to populate quorum disk space with the right information. To perform this type:</p>
<pre># mkqdisk -c /dev/vg_qdisk/lv_qdisk -l &lt;your_cluster_name&gt;</pre>
<p>Note that is not required to use your cluster name as quorum disk label, but it is recommended.</p>
<p>You need also to create a heuristic script to help qdisk when acting as tie-breaker. Create <code>/usr/share/cluster/check_eth_link.sh</code>:</p>
<pre>#!/bin/sh
# Network link status checker

ethtool $1 | grep -q "Link detected.*yes"
exit $?</pre>
<p>Now activate the quorum disk:</p>
<pre># service qdiskd start
# chkconfig qdiskd on</pre>
<p><a name="Logging_configuration"></a></p>
<h2>Logging configuration</h2>
<p>In order to assure a good logging you can choose to log the rgmanager to a specific file.</p>
<p>Add this lines to <code>/etc/syslog.conf</code>:</p>
<pre># Red Hat Cluster
local4.* /var/log/rgmanager</pre>
<p>Add <code>/var/log/rgmanager</code> to logrotate syslog settings in <code>/etc/logrotate.d/syslog</code>:</p>
<pre>/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/rgmanager {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2&gt; /dev/null` 2&gt; /dev/null || true
        /bin/kill -HUP `cat /var/run/rsyslogd.pid 2&gt; /dev/null` 2&gt; /dev/null || true
    endscript
}</pre>
<p>Modify this line in <code>/etc/cluster/cluster.conf</code>:</p>
<pre>&lt;rm log_facility="local4" log_level="5"&gt;</pre>
<p>Increment <code>/etc/cluster/cluster.conf</code> version and update on all nodes:</p>
<pre># ccs_tool update /etc/cluster/cluster.conf</pre>
<p><a name="Cluster_configuration"></a></p>
<h2>Cluster configuration</h2>
<p>For configuring cluster you can choose to use:</p>
<ul>
<li>Luci web interface</li>
<li>Manual xml configuration</li>
</ul>
<p><a name="Configuring_cluster_using_luci"></a></p>
<h3>Configuring cluster using luci</h3>
<p>In order to use luci web interface you need to activate service <code>ricci</code> on <strong>all</strong> nodes and <code>luci</code> on one node only:</p>
<pre>(on all nodes)
# chkconfig ricci on
# service ricci start</pre>
<pre>(choose only a node)
# chkconfig luci on
# luci_admin init
# service luci restart</pre>
<p>Please note that <code>luci_admin init</code> must be executed only the first time and <strong>before</strong> starting luci service, otherwise luci will be unusable.</p>
<p>now connect to luci: <a title="https://node_with_luci.mydomain.com:8084" rel="nofollow" href="https://node_with_luci.mydomain.com:8084">https://node_with_luci.mydomain.com:8084</a> Here you can create a cluster, add nodes, create services, failover domains etc&#8230;</p>
<p>See <a title="Recommended cluster configuration" href="#Recommended_cluster_configuration">Recommended cluster configuration</a> to learn the right settings for the cluster.</p>
<p><a name="Configuring_cluster_editing_the_XML"></a></p>
<h3>Configuring cluster editing the XML</h3>
<p>You can also manually configure a cluster editing its main config file <code>/etc/cluster/cluster.conf</code>. To create the config skeleton use:</p>
<pre># ccs_tool create</pre>
<p>now the just created config file is not yet usable, you should configure cluster settings, add nodes, create services, failover domains etc&#8230;</p>
<p>When config file is complete, <strong>copy the file on all nodes</strong> and start the cluster in this way:</p>
<pre>(on all nodes)
# chkconfig cman on
# chkconfig rgmanager on
# service cman start
# service rgmanager start</pre>
<p>See <a title="Recommended cluster configuration" href="#Recommended_cluster_configuration">Recommended cluster configuration</a> to learn the right settings for the cluster.</p>
<p>See <a title="Useful cluster commands" href="#Useful_cluster_commands">Useful cluster commands</a> to learn some useful console cluster commands to use.</p>
<p><a name="Configuring_cluster_editing_the_XML"></a><br />
<a name="Recommended_cluster_configuration"></a></p>
<h3>Recommended cluster configuration</h3>
<p>Here is attached a <code>/etc/cluster/cluster.conf</code> file of a fully configured cluster.</p>
<p>For commenting purposes, the file is splitted into several consecutive parts:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cluster</span> <span style="color: #000066;">alias</span>=<span style="color: #ff0000;">&quot;jcaps_prd&quot;</span> <span style="color: #000066;">config_version</span>=<span style="color: #ff0000;">&quot;26&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jcaps_prd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fence_daemon</span> <span style="color: #000066;">clean_start</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">post_fail_delay</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">post_join_delay</span>=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clusternodes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clusternode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-lancelot.yourdomain.com&quot;</span> <span style="color: #000066;">nodeid</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">votes</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fence</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clusternode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clusternode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-artu.yourdomain.com&quot;</span> <span style="color: #000066;">nodeid</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">votes</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fence</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clusternode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clusternode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-morgana.yourdomain.com&quot;</span> <span style="color: #000066;">nodeid</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">votes</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fence</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clusternode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clusternodes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cman</span> <span style="color: #000066;">expected_votes</span>=<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fencedevices</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>This is the first part of the XML cluster config file.</p>
<ul>
<li>First line describes the cluster name and the <code>config_version</code>. Each time you modify the XML you must increment the config_version by 1 prior to update the config on all nodes.</li>
<li>Fence deamon line is the default one.</li>
<li>Cluster node stanza contains the nodes of the cluster. Note that <code>name</code> property contains the FQDN of the name. This name determines the eth used for cluster communication. In this example we don&#8217;t use the main hostname but the hostname related to the eth we choose to use as cluster communication channel.</li>
<li>Note also that the line <code>&lt;fence/&gt;</code> is required. Note that here we <strong>do not</strong> use any fence device. Due to the nature of HA-LVM the access to the data sould be exclusive by one node at a time.</li>
<li>Cman <code>expected_votes</code> is 4 because each node give 1 vote each.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rm</span> <span style="color: #000066;">log_facility</span>=<span style="color: #ff0000;">&quot;local4&quot;</span> <span style="color: #000066;">log_level</span>=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failoverdomains<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failoverdomain</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jcaps_prd&quot;</span> <span style="color: #000066;">nofailback</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">ordered</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">restricted</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failoverdomainnode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-lancelot.yourdomain.com&quot;</span> <span style="color: #000066;">priority</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failoverdomainnode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-artu.yourdomain.com&quot;</span> <span style="color: #000066;">priority</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failoverdomainnode</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;h-morgana.yourdomain.com&quot;</span> <span style="color: #000066;">priority</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/failoverdomain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/failoverdomains<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>This section <strong>begins</strong> resource manager configuration (<code>&lt;rm ...&gt;</code>).</p>
<ul>
<li>Resource manager section can be configured for logging. Rm logs to syslog, here we configured the <code>log_facility</code> and the logging level. The facility we specified allows us to log to a separate file (see <a title="Logging configuration" href="#Logging_configuration">logging configuration</a>)</li>
<li>We configured also a failover domain containing all cluster node. We want that a service can switch to all cluster nodes, but you can also configure different behaviours here.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">autostart</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">domain</span>=<span style="color: #ff0000;">&quot;jcaps_prd&quot;</span> <span style="color: #000066;">exclusive</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;subversion&quot;</span> <span style="color: #000066;">recovery</span>=<span style="color: #ff0000;">&quot;relocate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ip</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;10.200.56.60&quot;</span> <span style="color: #000066;">monitor_link</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lvm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;vg_subversion_apps&quot;</span> <span style="color: #000066;">vg_name</span>=<span style="color: #ff0000;">&quot;vg_subversion_apps&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lvm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;vg_subversion_data&quot;</span> <span style="color: #000066;">vg_name</span>=<span style="color: #ff0000;">&quot;vg_subversion_data&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fs</span> <span style="color: #000066;">device</span>=<span style="color: #ff0000;">&quot;/dev/vg_subversion_apps/lv_apps&quot;</span> <span style="color: #000066;">force_fsck</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">force_unmount</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">fsid</span>=<span style="color: #ff0000;">&quot;61039&quot;</span> <span style="color: #000066;">fstype</span>=<span style="color: #ff0000;">&quot;ext3&quot;</span> <span style="color: #000066;">mountpoint</span>=<span style="color: #ff0000;">&quot;/apps/subversion&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;svn_apps&quot;</span> <span style="color: #000066;">self_fence</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fs</span> <span style="color: #000066;">device</span>=<span style="color: #ff0000;">&quot;/dev/vg_subversion_data/lv_repositories&quot;</span> <span style="color: #000066;">force_fsck</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">force_unmount</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">fsid</span>=<span style="color: #ff0000;">&quot;3193&quot;</span> <span style="color: #000066;">fstype</span>=<span style="color: #ff0000;">&quot;ext3&quot;</span> <span style="color: #000066;">mountpoint</span>=<span style="color: #ff0000;">&quot;/apps/subversion/repositories&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;svn_repositories&quot;</span> <span style="color: #000066;">self_fence</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;/my_cluster_scripts/subversion/subversion.sh&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;subversion&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This section contains the services in the cluster (like HP ServiceGuard packages)</p>
<ul>
<li>We choose the failover domain (in this case our failover domain contains all nodes so the service can run on all nodes)</li>
<li>We add a ip address resource (use always monitor link!)</li>
<li>We use also a HA-LVM resource (<code>&lt;lvm ...&gt;</code>). Here all VG specified will be tagged with the node name when activating. This means that they can be activated <strong>only</strong> on the node where the service is running (only on that node!). <strong>Note: If you do not specify any LV, all the LVs inside the VG will be activated!</strong></li>
<li>Next there are also <code>&lt;fs ...&gt;</code> tags for mounting filesystem resources. It is recommended to use <code>force_unmount</code> and <code>force_fsck</code>.</li>
<li>You can specify also a custom script for starting application/services and so on. Please note that the script must be LSB compliant. This means that it must handle <em>start|stop|status</em>. Note also that default cluster behaviour is to run the script with <em>status</em> parameter every 30 seconds. If the script status does not return 0, the service will be marked as failed (and probably will be restarted/relocated).</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This section closes the resource manager configuration (closes XML tag).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;totem</span> <span style="color: #000066;">consensus</span>=<span style="color: #ff0000;">&quot;4800&quot;</span> <span style="color: #000066;">join</span>=<span style="color: #ff0000;">&quot;60&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;20000&quot;</span> <span style="color: #000066;">token_retransmits_before_loss_const</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>This is a crucial part of cluster configuration. Here you specify the failure detection time of cluster.</p>
<ul>
<li>RedHat recommends to the CMAN membership (token) timeout value to be at least times that of the qdiskd timeout value. Here the value is 20 seconds.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;quorumd</span> <span style="color: #000066;">interval</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;jcaps_prd_qdisk&quot;</span> <span style="color: #000066;">min_score</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">tko</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">votes</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;heuristic</span> <span style="color: #000066;">interval</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">program</span>=<span style="color: #ff0000;">&quot;/usr/share/cluster/check_eth_link.sh bond0&quot;</span> <span style="color: #000066;">score</span>=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/quorumd<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Here we configure the quorum disk to be used by the cluster.</p>
<ul>
<li>We choose a quorum timeout value of 10 seconds (quorumd interval * quorumd tko) which is a half of token timeout (20 seconds).</li>
<li>We insert also a heuristic script to determine the network health. This will help qdisk to take a decision when split-brain happens.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cluster<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This concludes the configuration file closing XML tags still opened.</p>
<p><a name="Useful_cluster_commands"></a></p>
<h3>Useful cluster commands</h3>
<ul>
<li>ccs_tool update /etc/cluster/cluster.conf (update cluster.conf among all nodes)</li>
<li>clustat (see cluster status)</li>
<li>clusvcadm -e &lt;service&gt; (enable/start a service)</li>
<li>clusvcadm -d &lt;service&gt; (disable/stop service)</li>
<li>vgs -o vg_name,vg_size,vg_tags (show all volume groups names, size and tags)</li>
</ul>
<p><a name="Resources"></a></p>
<h1>Resources</h1>
<ul>
<li>RedHat Cluster Suite developer wiki: <a title="http://sources.redhat.com/cluster/wiki" rel="nofollow" href="http://sources.redhat.com/cluster/wiki">http://sources.redhat.com/cluster/wiki</a></li>
<li>RHCS Configuration guide: <a title="http://www.redhat.com/docs/manuals/csgfs" rel="nofollow" href="http://www.redhat.com/docs/manuals/csgfs">http://www.redhat.com/docs/manuals/csgfs</a></li>
<li>Migrating HP Serviceguard to RedHat Cluster Suite: <a title="http://docs.hp.com" rel="nofollow" href="http://docs.hp.com">4AA1-xxxxENN (May 2009)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nxnt.org/2010/09/redhat-cluster-howto/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Multipath linux and EMC CLARiiON</title>
		<link>http://www.nxnt.org/2010/08/multipath-linux-and-emc-clariion/</link>
		<comments>http://www.nxnt.org/2010/08/multipath-linux-and-emc-clariion/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 10:28:20 +0000</pubDate>
		<dc:creator>nicola</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Gnu/Linux]]></category>
		<category><![CDATA[Storage]]></category>

		<guid isPermaLink="false">http://www.nxnt.org/?p=8</guid>
		<description><![CDATA[Configuring CentOS 5 and EMC2 CLARiiON CX4-480 with linux multipath]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>today I want to post here my experience configuring multipath on CentOS 5.5 for using a EMC2 CLARiiON box.</p>
<h2>Introduction</h2>
<p>Native multipath on GNU/Linux is made up of different components, kernel modules, userspace tools that allow you to manage multiple path on SAN with a enterpise storage. This tutorial explains how to configure CentOS 5.5 x86_64 for connecting to a EMC2 CLARiiON CX4-480 box using multipath.</p>
<h2>Architecture</h2>
<p>Kernel components:</p>
<ul>
<li>hardware handler (manage failover/failback on particular hardware)</li>
<li>generic device-mapper modules (dm_*)</li>
<li>multipath module (dm_multipath)</li>
</ul>
<p>Userspace components:</p>
<ul>
<li>multipath utility (manages path)</li>
<li>multipathd daemon (monitors path and applies failback rules)</li>
</ul>
<h2>Configuration</h2>
<p>Multipath configuration is done exclusively via <code>/etc/multipath.conf</code> configuration file. For a comprehensive review of this configuration file please see <a title="multipath home" href="http://sources.redhat.com/lvm2/wiki/MultipathUsageGuide">http://sources.redhat.com/lvm2/wiki/MultipathUsageGuide</a>. <strong>Next paragraphs assume that you know a little bit the multipath configuration file structure.</strong></p>
<h2><strong>CentOS 5.5</strong></h2>
<p>CentOS 5.5 (aka RHEL 5.x) blacklist all devices by default. This means that multipath command will return no multipath device connected.</p>
<p>In order to activate device scanning for multipath you should comment out the default blacklist section on the top of config file:</p>
<pre># Blacklist all devices by default. Remove this to enable multipathing
# on the default devices.
#blacklist {
#        devnode "*"
#}</pre>
<p>Then add a new black list section (I want multipath to scan ony few devices):</p>
<pre>blacklist {
       devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
       devnode "^hd[a-z]"
       devnode "^cciss!c[0-9]d[0-9]*"
}</pre>
<p>Next we add a dedicated configuration stanza for EMC storage:</p>
<pre>devices {
        # Configurazione specifica EMC CLARiiON
        device {
                vendor "DGC"
                product "*"
                product_blacklist "LUNZ"
                prio_callout "/sbin/mpath_prio_emc /dev/%n"
                path_grouping_policy group_by_prio
                features "1 queue_if_no_path"
                failback immediate
                hardware_handler "1 alua"
        }
}</pre>
<p>Please note that not inserting such stanza, multipath will use default settings from</p>
<pre>/usr/share/doc/device-mapper-multipath-0.4.7/multipath.conf.defaults</pre>
<p>At the end we should activate multipathd daemon using the following commands:</p>
<pre># chkconfig multipathd on
# service multipathd start</pre>
<p>It is also recommended to recreate initrd:</p>
<pre># mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)</pre>
<p>Check multipath command output:</p>
<pre># multipath -ll
mpath2 (36006016047c022002a3cc7a948afde11) dm-9 DGC,RAID 5
[size=80G][features=1 queue_if_no_path][hwhandler=1 alua][rw]
\_ round-robin 0 [prio=100][enabled]
 \_ 1:0:1:1 sdac 65:192 [active][ready]
 \_ 0:0:0:1 sdb  8:16   [active][ready]
\_ round-robin 0 [prio=20][enabled]
 \_ 0:0:1:1 sdk  8:160  [active][ready]
 \_ 1:0:0:1 sdt  65:48  [active][ready]
mpath1 (36006016047c022000cb4a4bd48afde11) dm-8 DGC,RAID 5
[size=30G][features=1 queue_if_no_path][hwhandler=1 alua][rw]
\_ round-robin 0 [prio=100][enabled]
 \_ 1:0:1:0 sdab 65:176 [active][ready]
 \_ 0:0:0:0 sda  8:0    [active][ready]
\_ round-robin 0 [prio=20][enabled]
 \_ 0:0:1:0 sdj  8:144  [active][ready]
 \_ 1:0:0:0 sds  65:32  [active][ready]</pre>
<h2>CLARiiON CX4-480</h2>
<p>In order to work correcty you must register hosts in this way:</p>
<ul>
<li>Manually register host WWN (I don&#8217;t like naviagent)</li>
<li>Register initators group as:
<ul>
<li>type: Clariion Open</li>
<li>Failover mode: 4</li>
</ul>
</li>
</ul>
<h2>Cluster</h2>
<p>If you are configuring more nodes in a CentOS/RHEL cluster to access the same storage you can configure one node and replicate configuration to others.</p>
<p>Files to replicate are:</p>
<ul>
<li>/etc/multipath.conf (main config file)</li>
<li>/var/lib/multipath/bindings (maps WWN to dev-mapper devices like mpath1, etc&#8230;)</li>
</ul>
<h2>Maintenance</h2>
<p>Multipathd daemon and dm_multipath kernel module write to syslog the paths status, each time the status changes (eg. the path deads) they do specific tasks and they log informations to syslog.</p>
<p>To see a real time status of multipath use &#8220;multipath -ll&#8221; command.</p>
<p>Output has to be read as below:</p>
<pre>mydev1 (3600a0b800011a1ee0000040646828cc5) dm-1 IBM,1815      FAStT
------  ---------------------------------  ---- --- ---------------
   |               |                         |    |          |-------&gt; Product
   |               |                         |    |------------------&gt; Vendor
   |               |                         |-----------------------&gt; sysfs name
   |               |-------------------------------------------------&gt; WWID of the device
   |------------------------------------------------------ ----------&gt; User defined Alias name

[size=512M][features=1 queue_if_no_path][hwhandler=1 rdac]
 ---------  ---------------------------  ----------------
     |                 |                        |--------------------&gt; Hardware Handler, if any
     |                 |---------------------------------------------&gt; Features supported
     |---------------------------------------------------------------&gt; Size of the DM device

Path Group 1:
\_ round-robin 0 [prio=6][active]
-- -------------  ------  ------
 |    |              |      |----------------------------------------&gt; Path group state
 |    |              |-----------------------------------------------&gt; Path group priority
 |    |--------------------------------------------------------------&gt; Path selector and repeat count
 |-------------------------------------------------------------------&gt; Path group level

First path on Path Group 1:
 \_ 29:0:0:1 sdf 8:80  [active][ready]
    -------- --- ----   ------  -----
      |      |     |        |      |---------------------------------&gt; Physical Path state
      |      |     |        |----------------------------------------&gt; DM Path state
      |      |     |-------------------------------------------------&gt; Major, minor numbers
      |      |-------------------------------------------------------&gt; Linux device name
      |--------------------------------------------------------------&gt; SCSI information: host, channel, scsi_id and lun

Second path on Path Group 1:
 \_ 28:0:1:1 sdl 8:176 [active][ready]

Path Group 2:
\_ round-robin 0 [prio=0][enabled]
 \_ 28:0:0:1 sdb 8:16  [active][ghost]
 \_ 29:0:1:1 sdq 65:0  [active][ghost]</pre>
<h3>Useful commands</h3>
<ul>
<li><code>multipath -v2</code> scans devices and reload devices maps (dev mapper)</li>
<li><code>multipath -v2 -d</code> as above but runs in &#8220;dry run mode&#8221; (does not update device maps)</li>
<li><code>multipath -F</code> flushes all WWN &lt;-&gt; mpath&lt;nnn&gt; bindings</li>
</ul>
<h2>Resources</h2>
<ul>
<li><a title="http://sources.redhat.com/lvm2/wiki/MultipathUsageGuide" rel="nofollow" href="http://sources.redhat.com/lvm2/wiki/MultipathUsageGuide">http://sources.redhat.com/lvm2/wiki/MultipathUsageGuide</a></li>
<li><a title="http://powerlink.emc.com" rel="nofollow" href="http://powerlink.emc.com">Host Connectivity Guide for Linux (P/N 300-003-865)</a></li>
</ul>
<p><del datetime="2010-09-03T15:16:06+00:00"><strong>NOTE: This configuration seems not to detect new added LUNS, even scanning all HBA and flushing multipath, the only way is (still) rebooting&#8230; <img src='http://www.nxnt.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </strong></del></p>
<p><strong>NOTE (Sep 03): Emc Host Connectivity Guide recommends to use:</strong></p>
<pre>prio_callout "/sbin/mpath_prio_alua /dev/%n"</pre>
<p><strong>but this configuration cannot detect new added LUNS! Please use instead this line (already fixed in this article, tnx to deeb):</strong></p>
<pre>prio_callout "/sbin/mpath_prio_emc /dev/%n"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nxnt.org/2010/08/multipath-linux-and-emc-clariion/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>nxnt.org is back</title>
		<link>http://www.nxnt.org/2010/08/hello-world/</link>
		<comments>http://www.nxnt.org/2010/08/hello-world/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 06:57:30 +0000</pubDate>
		<dc:creator>nicola</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.nxnt.org/?p=1</guid>
		<description><![CDATA[Welcome back to my blog! Hope to have time to write down some useful]]></description>
			<content:encoded><![CDATA[<p>Welcome back to my blog! Hope to have time to write down some useful <img src='http://www.nxnt.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nxnt.org/2010/08/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

