<?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>herbertm.ca &#187; Linux</title>
	<atom:link href="http://blog.herbertm.ca/articles/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.herbertm.ca</link>
	<description></description>
	<lastBuildDate>Thu, 04 Mar 2010 20:23:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Mercurial Central Repository with fastcgi and nginx</title>
		<link>http://blog.herbertm.ca/archives/334</link>
		<comments>http://blog.herbertm.ca/archives/334#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:23:41 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=334</guid>
		<description><![CDATA[Documentation in this arena being slim, I felt it would [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Documentation in this arena being slim, I felt it would be helpful to write a short article on my configuration. FastCGI examples are generally documented in about <a href="http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/">two</a> or <a href="http://geeksharp.com/2010/01/20/mercurial-web-with-fastcgi-nginx/">three</a> blog posts on the subject, all of which have become dated. For the basic ground work take a look at <a href="http://streamhacker.com/2009/07/28/how-to-deploy-hgwebdir-fcgi-behind-nginx-with-fab/comment-page-1">streamhacker</a>.</p>

<p>Firstly, the fastcgi process is unaware whether you are using <span class="caps">HTTP </span>or <span class="caps">HTTPS, </span>another fastcgi_param must be passed to solve the following error:</p>


<pre>
searching for changes
ssl required
</pre>




<pre>
fastcgi_param   HTTPS           on;
</pre>



<p>If you are having the following error, and you have ensured that <span class="caps">HTTPS </span>is functioning and allow_push = username is specified in the repo&#8217;s <em>.hg/hgrc</em>:</p>


<pre>
searching for changes
27 changesets found
abort: authorization failed
</pre>



<p>Then the fastcgi process isn&#8217;t receiving the username from nginx. Ensure that the following lines are added to your nginx config:</p>


<pre>
fastcgi_param   AUTH_USER       $remote_user;
fastcgi_param   REMOTE_USER     $remote_user;
</pre>



<p>Nginx is also liable to spit out a:</p>


<pre>413 Request Entity Too Large</pre>


<p>on your first major commit. This is because the max_body_size is set low by default and is unacceptable for a mercurial application. Ensure to add and modify this line to your needs:</p>


<pre>
client_max_body_size    100M;
</pre>


<p><strong>my entire nginx vhost.conf</strong></p>


<pre>
server {
    listen      443;
    server_name hg.DOMAIN.COM;

    ssl                  on;
    ssl_certificate      server.crt;
    ssl_certificate_key  server.key;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;

        # Increase transfer size to accommodate large pushes
        client_max_body_size    100M;

        location / {
                auth_basic &quot;Restricted Access&quot;;
                auth_basic_user_file /repo/sites/hg.DOMAIN.COM/mercurial_passwd;
                fastcgi_pass    127.0.0.1:9001;
                fastcgi_param   PATH_INFO       $fastcgi_script_name;
                fastcgi_param   AUTH_USER       $remote_user;
                fastcgi_param   REMOTE_USER     $remote_user;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;
                fastcgi_param   SERVER_PROTOCOL $server_protocol;
                fastcgi_param   SERVER_PORT     $server_port;
                fastcgi_param   SERVER_NAME     $server_name;
                fastcgi_param   HTTPS           on;
        }
        location ~ /\.ht {
            deny  all;
        }
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/334/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mercurial clone from ssh with spaces</title>
		<link>http://blog.herbertm.ca/archives/331</link>
		<comments>http://blog.herbertm.ca/archives/331#comments</comments>
		<pubDate>Tue, 23 Feb 2010 20:45:54 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=331</guid>
		<description><![CDATA[
hg clone ssh://user@host/path/to/repo

Is simple en [...]]]></description>
			<content:encoded><![CDATA[<p></p><pre>
hg clone ssh://user@host/path/to/repo
</pre>


<p>Is simple enough&#8230;</p>

<p>But what about when you have a repo called &#8220;big repo&#8221;. Took me a while to figure out (with ssh verbosity) that a combination of the regular special character &#8216;\&#8217; and quotes is required for hg to call the right ssh command.</p>


<pre>
hg clone &quot;ssh://user@host/path/to/big\ repo&quot;
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Simple Test</title>
		<link>http://blog.herbertm.ca/archives/327</link>
		<comments>http://blog.herbertm.ca/archives/327#comments</comments>
		<pubDate>Sat, 13 Feb 2010 01:16:40 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=327</guid>
		<description><![CDATA[A simple test this evening between two FreeBSD 8.0-RELE [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>A simple test this evening between two FreeBSD 8.0-RELEASE machines. OpenVPN 2.1.1 compile from ports (source).</p>

<p><strong>gen2</strong> <em>i386, Pentium 4 2.0GHz 2.0GB circa 2003</em></p>


<pre>
[root@gen2 /usr/ports/security/openvpn]# make install
real	4m11.491s
user	1m46.402s
sys	0m26.863s
</pre>



<p><strong>blackbox</strong> <em>i386, Athlon Thunderbird 1.0GHz 512MB circa 2001</em></p>


<pre>
[root@blackbox /usr/ports/security/openvpn]# make install
real	6m9.970s
user	3m15.515s
sys	0m43.739s
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/327/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FreeBSD 8.0 ZFS Tuning</title>
		<link>http://blog.herbertm.ca/archives/315</link>
		<comments>http://blog.herbertm.ca/archives/315#comments</comments>
		<pubDate>Sat, 06 Feb 2010 19:43:33 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=315</guid>
		<description><![CDATA[I recently migrated my RAID-5 home storage array to "RA [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I recently migrated my <span class="caps">RAID</span>-5 home storage array to <a href="http://en.wikipedia.org/wiki/Non-standard_RAID_levels#RAID-Z"><span class="caps">RAIDZ</span></a> using <span class="caps">ZFS </span>on FreeBSD 8.0-RELEASE. FreeBSD&#8217;s latest release includes <span class="caps">ZFS </span>v13 with many tuning patches, making <span class="caps">ZFS </span>not only more stable but easier to tune.</p>

<p>It is noted that on 64-bit systems with over 2GB <span class="caps">RAM, </span>default auto-tuning settings will be quite stable. However in any other configuration some tuning is still necessary to achieve a stable system.</p>

<p>On 32-bit you still have to compile a custom kernel per these <a href="http://www.freebsd.org/doc/handbook/kernelconfig-building.html">instructions</a>. If it is your first time compiling a custom kernel, don&#8217;t worry it is a very short procedure. Kernel <span class="caps">KVA</span>_PAGES (virtual address space) must be increased to allow for <span class="caps">ZFS </span>to use more kernel memory. The setting for this value depends on other userland applications that will be running on the server, and how much memory they require. <span class="caps">KVA</span>_PAGES value must be a multiple of 4 and that is how you can determine the kernel memory allocation, in my case:</p>


<pre>
KVA_PAGES=384 -&gt; 384 * 4 -&gt; 1536MB (1.5GB)
</pre>



<p>System configuration:</p>


<pre>
FreeBSD/i386 8.0 (Pentium 4)
2GB RAM
965GB ZFS RAID-Z over 3 drives
</pre>



<p>The general guideline I followed for setting tuning values was:</p>


<pre>
vm.kmem_size -&gt; 1/2 of total RAM
vm.kmem_size_max -&gt; 1/2 of total RAM
vfs.zfs.arc_max -&gt; 1/2 of vm.kmem_size_max
</pre>



<p>However when testing at high transfer load (1000mbit <span class="caps">LAN</span>) with arc_max set to 512MB I still experienced kernel panics. I still suggest starting at 1/2 of kmem_size and working down from there. </p>

<p>Final stable tuning values:</p>


<pre>
# /boot/loader.conf
vm.kmem_size=&quot;1024M&quot;
vm.kmem_size_max=&quot;1024M&quot;
vfs.zfs.arc_max=&quot;256M&quot;

# /etc/sysctl.conf
kern.maxvnodes=&quot;400000&quot;

# Custom Kernel Options
options    KVA_PAGES=384    # increase kernel virtual address space for ZFS
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/315/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asterisk 1.6 CDR &#8211; CSV to PgSQL</title>
		<link>http://blog.herbertm.ca/archives/260</link>
		<comments>http://blog.herbertm.ca/archives/260#comments</comments>
		<pubDate>Wed, 09 Dec 2009 21:06:54 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[asterisk]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=260</guid>
		<description><![CDATA[Damn, perl is ugly by today's standards, but I found th [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Damn, perl is ugly by today&#8217;s standards, but I found this old script <a href="http://www.voip-info.org/wiki/view/Asterisk+CDR+Master.csv+postgresql+Perl+import">kicking about</a> so I decided to dust it off and make it useable. This happens alot with asterisk code posted on the various wikis.</p>

<p>Using the newer <a href="http://search.cpan.org/~hmbrand/Text-CSV_XS-0.70/CSV_XS.pm">Text::CSV_XS</a> library and the latest asterisk <a href="http://www.packtpub.com/article/quality-assurance-in-asterisk-1-6">column structure</a> I&#8217;ve made it work as below to import about 4500 rows from cdr_csv on a production system. Enjoy! Glad to be back.</p>

<p><strong>Pre-requisites:</strong></p>


<pre>DBD::Pg
Text::CSV_XS</pre>




<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;"># Asterisk 1.6 CDR_CSV import to PGSQL</span>
<span style="color: #666666; font-style: italic;"># Herbert Molenda &lt;me at herbertm.ca&gt; - 2009-12-09</span>
<span style="color: #666666; font-style: italic;"># updated from original by StÃ©phane HENRY stephane.henry (=at=) heberge.net - 2007-03-20</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> DBI<span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">use</span> Text<span style="color: #339933;">::</span><span style="color: #006600;">CSV_XS</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this script import asterisk cdr log Master.csv into a postgresql table</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cdr_log_file</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: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_db</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_pwd</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$csv</span> <span style="color: #339933;">=</span> Text<span style="color: #339933;">::</span><span style="color: #006600;">CSV_XS</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> quote_char <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'&quot;'</span><span style="color: #339933;">,</span> always_quote <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">&amp;usage</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Connect to database </span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Connecting to database...<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dsn</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;DBI:Pg:dbname=$pg_db;host=$pg_host;port=5432&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">=</span>DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dsn</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$pg_user</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$pg_pwd</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;">$dbh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Successfully connected to $dsn<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">open</span> cdr_log<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt; $cdr_log_file&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Cannot open cdr_log_file<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;cdr_log&gt;</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;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</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: #009900;">&#40;</span><span style="color: #0000ff;">@fields</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$insert_str</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;insert into $pg_table (src, dst, dcontext, clid, channel, dstchannel, lastapp, lastdata, calldate, duration, billsec, disposition, uniqueid, userfield) values (<span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">14</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">16</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">17</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>);&quot;</span><span style="color: #339933;">;</span> 
		<span style="color: #000066;">print</span> <span style="color: #0000ff;">$insert_str</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: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$insert_str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</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>
	        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$err</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">error_input</span><span style="color: #339933;">;</span>
        	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Failed to parse line: $err&quot;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> 
	<span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000066;">close</span> <span style="color: #009900;">&#40;</span>cdr_log<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>
	<span style="color: #000066;">die</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Problem connecting to : $dsn<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;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>End.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000066;">exit</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
       print_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
       <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Usage: perl cdr_csv2pgsql.pl &lt;cdr_log_file&gt; &lt;pg_hostname&gt; &lt;database&gt; &lt;table&gt; &lt;username&gt; &lt;password&gt;<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: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> print_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
       <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>cdr_csv2pgsql.pl - Asterisk 1.6 CDR_CSV import to PGSQL<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: #339933;">&lt;/</span>password<span style="color: #339933;">&gt;&lt;/</span>username<span style="color: #339933;">&gt;&lt;/</span>table<span style="color: #339933;">&gt;&lt;/</span>database<span style="color: #339933;">&gt;&lt;/</span>pg_hostname<span style="color: #339933;">&gt;&lt;/</span>cdr_log_file<span style="color: #339933;">&gt;&lt;/</span>me<span style="color: #339933;">&gt;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/260/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetworkManager PPTP Windows-based VPN</title>
		<link>http://blog.herbertm.ca/archives/258</link>
		<comments>http://blog.herbertm.ca/archives/258#comments</comments>
		<pubDate>Mon, 07 Dec 2009 15:24:16 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=258</guid>
		<description><![CDATA[Getting connected:

Configure the connection as you w [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>Getting connected:</strong></p>

<p>Configure the connection as you would normally: hostname, username, password, domain (usually blank). Now lets get to the advanced settings that are not so well documented.</p>

<p>Default settings will likely result in <span class="caps">LCP </span>(host refused authentication) errors, which indicate that your authentication request is being denied by the server. Windows <span class="caps">VPN</span>s can be tricky to connect to, but with the right settings there&#8217;s no issue.</p>



<pre>Dec  7 10:16:50 chater pppd[3919]: CHAP authentication succeeded
Dec  7 10:16:50 chater pppd[3919]: MPPE 128-bit 40-bit stateless compression enabled
Dec  7 10:16:50 chater pppd[3919]: LCP terminated by peer</pre>



<p>Lets disable compression algorithms we know can&#8217;t be used in this case. To connect to Windows <span class="caps">PPTP </span>servers you need to enable <span class="caps">MPPE </span>encryption, easy; but problems above arise if you leave it to networkmanager to determine whether to use 40-bit or 128-bit. Force 128-bit encryption and make sure your advanced configuration looks like this:</p>

<div id="attachment_274" class="wp-caption center" style="width: 287px">
	<a href="http://blog.herbertm.ca/wp-content/uploads/Screenshot-PPTP.png"><img src="http://blog.herbertm.ca/wp-content/uploads/Screenshot-PPTP.png" alt="nm-pptp vpn advanced configuration" title="Screenshot-PPTP" width="287" height="452" class="size-full wp-image-274" /></a>
	<p class="wp-caption-text">nm-pptp vpn advanced configuration</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/258/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lest we forget Ontario scams</title>
		<link>http://blog.herbertm.ca/archives/252</link>
		<comments>http://blog.herbertm.ca/archives/252#comments</comments>
		<pubDate>Thu, 12 Nov 2009 13:50:53 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=252</guid>
		<description><![CDATA[Just in time for remembrance day! Reading an article to [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://blog.herbertm.ca/archives/252" title="Permanent link to Lest we forget Ontario scams"><img class="post_image alignright frame" src="http://www.mto.gov.on.ca/graphics/english/dandv/vehicle/veteran.gif" width="144" height="74" alt="Personalized Plates" /></a>
</p><p>Just in time for remembrance day! Reading an <a href="http://cnews.canoe.ca/CNEWS/Canada/2009/11/12/11718396-sun.html">article</a> today reveals another epic scam by our provincial politicians. With public support for our military finally gaining ground, it seems anyone will take advantage to make an extra buck. A popular way seems to be claiming that buying expensive, useless stuff is going to support various CF charities; the claim is not completely untrue but it is quite misleading when the fact of the matter is:</p>

<blockquote>&#8230;the charity [Canadian Forces Personnel Assistance Fund] gets 1.43% of the sale of the $314 plates and 2.89% on the $77.75 set.</blockquote>

<p>Not much more to say on that one. Buy a personalized plate if you want, but don&#8217;t buy it thinking you&#8217;re actually making a difference to military families.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/252/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check or Change I/O Scheduler (elevator)</title>
		<link>http://blog.herbertm.ca/archives/34</link>
		<comments>http://blog.herbertm.ca/archives/34#comments</comments>
		<pubDate>Wed, 09 Jan 2008 17:01:59 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[openSUSE]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A not-so-well known feature of Linux (aside from server [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>A not-so-well known feature of Linux (aside from server administrators and gentoo tweekers probably) is the kernel&#8217;s I/O scheduler. I believe as of 2.6.18, <a href="http://en.wikipedia.org/wiki/CFQ"><span class="caps">CFQ</span></a> (Complete Fair Queuing) has become the default for most distributions as it is well suited to low-latency desktop use. Previously <a href="http://en.wikipedia.org/wiki/Anticipatory">anticipatory</a> (which is better on slower drives) seemed to be the preferred choice. As computing power increased and hard drive seek times decreased other, more aggressive, schedulers became more efficient. I am not going to go into detail on how these schedulers work since it is quite a good read on  <a href="http://en.wikipedia.org/wiki/I/O_scheduling">wikipedia</a>.</p>
 <p>If you are curious here are some commands to check what is running:</p>
<h4>Replace <em>sda</em> with your block device:</h4>


<pre># cat /sys/block/sda/queue/scheduler 
noop anticipatory deadline [cfq] 
</pre>


<h4>Changing to a different scheduler</h4>
<p>1. Some distributions compile all the schedulers into the kernel and let you select using a kernel option at boot. Add the following to your kernel line in grub.conf (cfq,as,deadline,noop):


<pre> elevator=cfq</pre>


<p>2. The recommended way seems to be using a grub kernel setting at boot, but it can also be done hastily by simply echoing the scheduler to the /sys object.</p>


<pre># echo deadline &gt; /sys/block/sda/queue/scheduler</pre>


3. In a source-based or more minimalist distribution it is possible to compile a kernel and specify the default/installed schedulers directly.</p>


<pre>
Device Drivers --&gt;
          Block Devices --&gt;
                   IO Schedulers --&gt;
                         CFQ I/O Scheduler
</pre>


<p>It seems the default OpenSUSE 10.3 system installs all 4 schedulers, and defaults to <span class="caps">CFQ.</span> This works great for me in desktop applications, however if you are running a very task-specific server (such as database or file serving only) one of the other schedulers tailored for that task would be better. Similarly on older hardware (laptops, slow drives &lt;7200rpm), a <span class="caps">CFQ </span>scheduler may be causing too much head movement and degrade performance noticeably.</p>
<img src="http://blog.herbertm.ca/files/scheduler.jpg" alt="" height="197" width="473" />
<h6>Figure 1.1 Care of <a href="http://www.redhat.com/magazine/008jun05/features/schedulers/">RedHat</a> tests conducted for an Oracle database server.</h6>
<img src="http://blog.herbertm.ca/files/scheduler2.jpg" alt="" height="197" width="317" />
<h6>Figure 1.2 Another Oracle database benchmark comparing all 4 schedulers from <a href="http://oraclesponge.wordpress.com/2006/10/02/linux-26-kernel-io-schedulers-for-oracle-data-warehousing-part-ii/">OracleSponge</a></h6>
<h4>Further discussion</h4>
Schedulers/Elevators were designed with traditional hard disks in mind (seeking heads). Now that <span class="caps">SSD</span>s are becoming more available and large <span class="caps">USB </span>flash memory common, there is no need to worry about scheduling the head movement efficiently, since there is none. A preliminary <a href="http://ubuntuforums.org/showthread.php?t=509989">discussion</a> didn&#8217;t get the attention it deserved. I will be able to test once I get access to some <span class="caps">SSD </span>media myself, but it would seem that the <a href="http://en.wikipedia.org/wiki/Noop_scheduler">noop</a> scheduler (i.e no advanced scheduling) would probably be the fastest on these types of media.]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/34/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolution 2.12.0 Scalix Connector</title>
		<link>http://blog.herbertm.ca/archives/33</link>
		<comments>http://blog.herbertm.ca/archives/33#comments</comments>
		<pubDate>Wed, 10 Oct 2007 16:35:17 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[openSUSE]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[evolution-scalix from Gnome SVN:

checking Checking f [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>evolution-scalix from <a href="http://svn.gnome.org">Gnome <span class="caps">SVN</span></a>:</p>


<pre>
checking Checking for Evolution version 2.10... not found
checking Checking for Evolution version 2.8... not found
checking Checking for Evolution version 2.6... not found
checking Checking for Evolution version 2.4... not found
configure: error: No compatible Evolution version found or missing development headers
</pre>


<p>We know that the connector <a href="http://svn.gnome.org/svn/evolution-scalix/trunk/">trunk</a> is stuck back in the days of Evo 2.10, so unless you are still around with &lt;2.8 where it works flawlessly you need to do a little tweaking to get up and running. Some people <a href="http://www.scalix.com/forums/viewtopic.php?p=40665#40665">claim</a> that the older versions are more stable anyway, so that may be a valid choice.<br /><br /></p>

I&#8217;ve included a <a href="http://blog.herbertm.ca/files/openSUSE-10.3-evo2.12.patch">patch</a> for newer distros (i.e openSUSE 10.3, Fedora 7/8, Gentoo) which will get you through the autogen/configure stage when running Evolution 2.12 (latest).<br /><br /><br />
Patch line:<br />
<code># patch -p0 &lt; openSUSE-10.3-evo2.12.patch</code><br />
Autogen line:<br />
</code><code># ./autogen.sh --prefix=/usr --disable-more-warnings</code><br />
Back to debugging, I may have answers regarding possible make errors soon.<br /><br /><br />
<h3><em>Note:</em> Further discussion and eventual resolution at <a href="http://www.scalix.com/forums/viewtopic.php?t=9003">trunk openSUSE 10.3 Evo 2.12 [RESOLVED <span class="caps">EVO</span> 2.12 <span class="caps">STABLE</span>]</a></h3><br />
I now have a reasonable Linux Desktop client.]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/33/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extracting DID&#8217;s from the SIP Header</title>
		<link>http://blog.herbertm.ca/archives/32</link>
		<comments>http://blog.herbertm.ca/archives/32#comments</comments>
		<pubDate>Mon, 03 Sep 2007 20:04:28 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[SIP]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Most providers these days won't offer DID announcement  [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Most providers these days won&#8217;t offer <span class="caps">DID </span>announcement if you have several virtual numbers under the same account (separate logins are fine, but gets messy with register statements). The solution is to extract the TO: line from the <span class="caps">SIP </span>invite header and use that to discriminate <span class="caps">DID</span>s.</p>
<h4>Provider <span class="caps">SIP </span>message (viewable from asterisk by using the <em>sip debug</em> command at the <span class="caps">CLI</span>):</h4>


<pre>
&lt; -- SIP read from 216.18.125.7:5065: 
BYE sip:s@192.168.2.4 SIP/2.0
To: &lt;sip:xxxxxxxxxxx@216.18.125.3;user=phone&gt;;tag=as6370c3aa
From: &quot;CID NAME&quot;&lt;sip :xxxxxxxxxx@sip.babytel.ca&gt;;tag=650a2e00
...
&lt;/sip&gt;</pre>


<p>The dialplan below is designed to be used in an <span class="caps">AMP</span>/FreePBX scenario inside the <em>extensions_custom.conf</em> file. You can enter your additional <span class="caps">DID</span>s/virtual numbers in here and to be parsed before proceeding with the other dialplans configured in the web admin.</p>
<p>Since my provider&#8217;s TO: header has a bunch of junk surrounding the number, I use asterisk&#8217;s <a href="http://www.voip-info.org/wiki/index.php?page=Asterisk+variables#Substrings">string functions</a> to create a substring and evaluate against the <span class="caps">DID </span>number only. Makes the code easier to read, especially when further additions are made. <em>Note:</em> The offset may differ for you, depending on how the TO line is sent in the header above.
<h4>Modified dialplan to include header <span class="caps">DID</span>s:</h4>


<pre>
[ext-did-custom]
exten =&gt; s,1,Set(DID_TO=&quot;${SIP_HEADER(TO)}&quot;)
exten =&gt; s,2,GotoIf($[&quot;${DID_TO:6:11}&quot; = &quot;xxxxxxxxxxx&quot;]?ext-local,205,1)
</pre>

</p>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/32/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
