<?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</title>
	<atom:link href="http://blog.herbertm.ca/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>Last Tribute to Facebook</title>
		<link>http://blog.herbertm.ca/archives/37</link>
		<comments>http://blog.herbertm.ca/archives/37#comments</comments>
		<pubDate>Thu, 31 Jan 2008 20:21:18 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I recently completed the lengthy process of removing a  [...]]]></description>
			<content:encoded><![CDATA[<p></p>I recently completed the lengthy process of removing a <a href="http://www.facebook.com">Facebook</a> account. If you are reading this and think:<br />
<blockquote>&#8220;Why on earth would you delete a Facebook account?!?! <span class="caps">ITS THE BESTEST THING EVER</span>!</blockquote>
<p>You have some catching up to do, the rest of you skip down:</p>


<ol>
<li><a href="http://www.sophos.com/security/topic/facebook.html"><span class="caps">SOPHOS</span> Facebook Study</a> &#8211; good facts, interesting experiment</li>
<li><a href="http://www.facebook.com/policy.php">Facebook Privacy Policy</a> &#8211; I don&#8217;t suggest reading the whole thing, its quite lame.</li>
<li><a href="http://www.danah.org/papers/FacebookAndPrivacy.html">Facebook&#8217;s Privacy Trainwreck</a> &#8211; You remember people freaking out when the News Feeds came in?</li>
<li><a href="http://www-swiss.ai.mit.edu/6805/student-papers/fall05-papers/facebook.pdf">Facebook: Threats to Privacy</a> &#8211; <span class="caps">H.J</span>ones &amp; <span class="caps">J.S</span>oltren, <span class="caps">MIT </span>in 2005!</li>
</ol>



<p>And the list goes on and on, I&#8217;ve had enough. Google around yourself if you still feel cool with Facebook. All you need is &#8220;privacy&#8221; and &#8220;facebook&#8221; in one query. &#8220;Facebook&#8221; and &#8220;biometrics&#8221; is another good one, see if it produces the results you&#8217;re looking for.</p>

<h3>Deactivation</h3>

<p>If you&#8217;d like to go through the ordeal of asking  Facebook, you can do yourself a favour and check out many <a href="http://stevenmansour.com/writings//2007/jul/23/2342/2504_steps_to_closing_your_facebook_account">blog posts</a> that have already tried. Basically the process boils down to this:</p>


<ol>
<li>Reactivate your facebook account (if necessary)</li>
<li>In Profile -&gt; Edit, go through and delete every piece of information, field by field. <em>prepare to cry</em></li>
<li>Wall post by Wall post delete every one. <em>cry</em></li>
<li>Photos, not so bad go to Edit Album and check all the delete boxes for the photos then delete album.</li>
<li>Remove yourself from all networks (clever little <em>leave network</em> link at the bottom of the Networks page). This will take care of groups and events.</li>
<li>Delete all friends.</li>
</ol>



When you are done the profile page should revert to a example-like style with a preview encouraging you to start adding friends! Fight the temptation and send an e-mail to <a href="mailto:%70%72%69%76%61%63%79%40%66%61%63%65%62%6F%6F%6B%2E%63%6F%6D">privacy@facebook.com</a> with something along the lines of:<br />
<blockquote>Dear Facebook Privacy Staff,<br />
I have removed all of my profile content. Please remove my account from your database and confirm when this is complete.<br /><br />
account: <em>email login</em><br /><br />
Regards,<br /><br />
Chater</blockquote>

<h4>The Response</h4>

<blockquote>Hi Herb,

<p>Your information no longer appears on the site, and we have removed your login email address from our system.  <br />
Thanks,</p>

Paul<br /><br />
User Operations<br /><br />
Facebook</blockquote>

<h3>Other Comments</h3>

<p><typo :lightbox src="/files/facebook.png" thumbsrc="/files/facebook-thumb.png" /></p>

<p>What&#8217;s with this?</p>
<blockquote><strong>Please enter your full birthday. We are required to retrieve this information by law, but you will have control over whether others see it.</strong></blockquote>
<p>You&#8217;re not required by law to do anything. Sure in the <span class="caps">U.S </span>there is the <a href="http://www.coppa.org/coppa.htm"><span class="caps">COPPA</span></a>, but (and I quote below) if you go read the laws you might realize it only has to do with a person&#8217;s age. It is meant to protect children&#8217;s privacy, which is fair enough; I wouldn&#8217;t want any kiddies using Facebook either.
<blockquote>(1) <span class="caps">CHILD.</span>&Atilde;&cent;&acirc;&not;&acirc;The term &#8220;child&#8221; means an individual under the age of 13<sup class="footnote"><a href="#fn1">1</a></sup>.</blockquote>
</p><p>Sounds to me like all that has to be done here is verify my age. Why don&#8217;t they just ask for that?</p>
<p>The wording that is used is interesting as well. Why is Facebook <strong>retrieving</strong> information from you? For whom? As if I am worried about the <em>noobs</em> with accounts on there viewing my info; well, aside from the identity theives and fraudsters, who can make a killing with Facebook (ref <span class="caps">SOPHOS</span>), I don&#8217;t really care, its the corporation that we should be worried about.

<span class="caps">COPPA</span> Section 1302.1</p>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/37/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WHM Cpanel Create Account Error</title>
		<link>http://blog.herbertm.ca/archives/36</link>
		<comments>http://blog.herbertm.ca/archives/36#comments</comments>
		<pubDate>Mon, 21 Jan 2008 14:27:41 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[whm]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Apparently, you can't be running the name-service cachi [...]]]></description>
			<content:encoded><![CDATA[<p></p>Apparently, you can&#8217;t be running the name-service caching daemon with Cpanel/WHM. I was trying to create an account earlier, through both the <span class="caps">WHM </span>web-ui as well as the command-line version <em>wwwacct</em>. Running either script produces no logical error messages related to nscd; at first try it says it is unable to create group. Nothing comes up in classic google search, I had to register on the <a href="http://forums.cpanel.net/showthread.php?t=67164">Cpanel Forums</a> to find some relevant information.<br /><br /><br />
<h4>Attempts to create an account:</h4>


<pre>Checking input data......Done
WWWAcct 12.0 (c) 1997-2007 cPanel, Inc.......Done
Running pre creation script (/scripts/prewwwacct)......Done
Adding User...Unable to add group deuce
</pre>


<p>The script actually manages to create the group, which can be verified in <em>/etc/groups</em>.</p>


<pre># cat /etc/group
---
deuce:x:32070:</pre>


<p>Which you have to manually remove to get the script to work again.</p>


<pre># /usr/sbin/groupdel deuce
</pre>


<p>As mentioned in the above post, (paraphrasing the Cpanel techs) the problem was that nscd is <em>running</em>.</p>


<pre># /sbin/service nscd stop</pre>


<p>Account gets created without a hitch (assuming that group is removed manually). Easily reproducible.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/36/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>
	</channel>
</rss>
