<?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>The Geekery</title>
	<atom:link href="http://jon.netdork.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://jon.netdork.net</link>
	<description>The Usual Stuff...</description>
	<lastBuildDate>Wed, 16 May 2012 03:35:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Still Alive&#8230;</title>
		<link>http://jon.netdork.net/2012/05/15/still-alive/</link>
		<comments>http://jon.netdork.net/2012/05/15/still-alive/#comments</comments>
		<pubDate>Wed, 16 May 2012 03:35:36 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[General Ramblings]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1484</guid>
		<description><![CDATA[It has been a while since I&#8217;ve posted. The last was on my string vs bash match up. It got a fair bit of attention, with some great feedback, so I learnt some new stuff. I&#8217;m going to try getting back to posting more regular posts, even if they aren&#8217;t always techy related1. For now, [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a while since I&#8217;ve posted.  The last was on my string vs bash match up.  It got a fair bit of attention, with some great feedback, so I learnt some new stuff.  I&#8217;m going to try getting back to posting more regular posts, even if they aren&#8217;t always techy related<sup><a href="http://jon.netdork.net/2012/05/15/still-alive/#footnote_0_1484" id="identifier_0_1484" class="footnote-link footnote-identifier-link" title="I do have some in the works on CERT and Emergency management">1</a></sup>.  For now, here&#8217;s what has been going on&#8230;</p>

<ul>
<li>New job</li>
<li>More volunteer work with CERT</li>
<li>More volunteer work at school</li>
</ul>

<p>Generally as busy as before, but at the same time, a different kind of busy.</p>

<h2>Job</h2>

<p>The transition to a new job was probably one of the harder decisions I&#8217;ve had to make in a long time, but now I&#8217;ve settled in, I don&#8217;t regret it at all.  I&#8217;m getting my hands on a lot more stuff I didn&#8217;t have access to before, as well as taking lead on projects that were originally left to HQ folk. </p>

<p>The environment is a lot larger. I&#8217;ve gone from a handful of few racks with gear to 20+ full racks, not counting the volume of VM guests we have running.</p>

<p>Documentation is pretty limited, so I&#8217;m working on updating it all, starting with a full data center audit.  I&#8217;m also working on a Lync pilot, as well as updating monitoring and other projects.</p>

<h2>CERT</h2>

<p>I&#8217;ll have a complete post on this one later.  In the meantime, you can read Christopher Webber&#8217;s post on <a href="http://cwebber.ucr.edu/2012/01/cert-and-operations-a-disaster-made-in-heaven/">CERT and Sys Admins</a>. </p>

<p>With tornadoes striking the DFW metroplex recently, we were asked to help with some cleanup operations. Post and pictures on that later.</p>

<p>So lots of new exciting stuff floating around, learning new stuff, getting my fingers into new toys and such. I&#8217;ll post more stuff as it comes up.</p><ol class="footnotes"><li id="footnote_0_1484" class="footnote">I do have some in the works on CERT and Emergency management</li></ol>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2012/05/15/still-alive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell vs Bash&#8230; String processing face off</title>
		<link>http://jon.netdork.net/2012/03/07/powershell-vs-bash-string-processing-face-off/</link>
		<comments>http://jon.netdork.net/2012/03/07/powershell-vs-bash-string-processing-face-off/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 03:19:48 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1463</guid>
		<description><![CDATA[While working on a file cleanup project today, I had to work with a text file containing close to 2 million lines. I had to extract file names with a specific string within it. I figured I could do it relatively quickly in PowerShell, but also realized it&#8217;d be a good opportunity to flex my [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a file cleanup project today, I had to work with a text file containing close to 2 million lines. I had to extract file names with a specific string within it.  I figured I could do it relatively quickly in PowerShell, but also realized it&#8217;d be a good opportunity to flex my Bash skills.  To say the results were interesting is an understatement (to me at least).  I picked up some tuning tricks while tinkering, which made some massive improvements.</p>

<p><span id="more-1463"></span></p>

<p>So we&#8217;ll set the grounds for the <em>battle</em>.</p>

<ul>
<li>The script has to parse the file with ~2 million records</li>
<li>It has to output to a file containing the file names to remove (all files with <em>02</em> in them)</li>
<li>It has to output <acronym title="Structured Query Language">SQL</acronym> statements to a file for cleaning a temporary table.</li>
<li>The quickest processor wins.</li>
</ul>

<p>An example of the data in the file:</p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Vehicle_ID,URL,DateDeleted,PhotoDeletedID<br />
58331549,\3860\1111111174WC448544WC44854279176192.jpg,2012-03-03 11:37:35.080000000,224516659<br />
58331549,\3860\1111111174WC448544WC44854279176194.jpg,2012-03-03 11:37:38.420000000,224516660<br />
58331995,\2635\1111111199E1648779E164877279175843.jpg,2012-03-03 11:41:35.510000000,224516661<br />
58050027,\5524\56840113_02_222222225WF265239_9.jpg,2012-03-03 12:42:41.537000000,224516931</div></div>

<p>So the basic idea is to loop through the file, and find all lines that have <em>_02_</em> in them.  I then want to extract that file name (<acronym title="Uniform Resource Locator">URL</acronym> column) and the PhotoDeletedID.</p>

<p>Before I started scripting this in PowerShell, I realized that using <em>Get-Content</em> was completely out of the question. This is because <em>Get-Content</em> reads the entire file into memory, creates objects for each line, and then continues with the script.  Similarly, the use of <em>Import-CSV</em> will result in the same issue.  Similarly, I couldn&#8217;t cat the entire file in Bash, as it&#8217;d do the same kind of thing. This meant reading the file line by line.</p>

<p>So here are my initial Bash, and PowerShell scripts&#8230;</p>

<div class="codecolorer-container powershell default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #800080;">$ck</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.Diagnostics.Stopwatch<span style="color: #000000;">&#93;</span>::StartNew<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$base</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;E:\Photos&quot;</span><br />
<span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\deleted_imgs.csv&quot;</span><br />
<span style="color: #800080;">$sql</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;delete from photo_deleted where PhotoDeletedID = {0}&quot;</span><br />
<br />
<span style="color: #800080;">$p_file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\ps_file.txt&quot;</span><br />
<span style="color: #800080;">$p_sql</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\ps_sql.txt&quot;</span><br />
<br />
<span style="color: #800080;">$fh</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::OpenText<span style="color: #000000;">&#40;</span><span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span><br />
try <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">for</span> <span style="color: #000000;">&#40;</span>;;<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$line</span> <span style="color: pink;">=</span> <span style="color: #800080;">$fh</span>.ReadLine<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$line</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0000FF;">break</span>; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$line</span> <span style="color: #FF0000;">-like</span> <span style="color: #800000;">'*_02_*'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$data</span> <span style="color: pink;">=</span> <span style="color: #800080;">$line</span>.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">','</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800080;">$base</span> <span style="color: pink;">+</span> <span style="color: #800080;">$data</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$rem</span> <span style="color: pink;">=</span> <span style="color: #800080;">$sql</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$data</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">3</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$p_file</span> <span style="color: #800080;">$file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$s_file</span> <span style="color: #800080;">$rem</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span>finally <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$fh</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #800080;">$ck</span>.Stop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #800080;">$ck</span>.Elapsed</div></td></tr></tbody></table></div>

<p>On line 10, I am using .Net libraries to open the file, and loop through each line.  I&#8217;m then searching for <em>_02_</em> in the string (line 17), splitting the line, and writing it to the 2 files (line 23 and 24).</p>

<p>I used the following in bash&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line<br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> == <span style="color: #000000; font-weight: bold;">*</span>_02_<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">ID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -d, -f4<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">URL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -d, -f2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;delete from photo_deleted where PhotoDeletedID = <span style="color: #007800;">${ID}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> bash_sql.txt<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;E:\images<span style="color: #007800;">${URL}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> bash_files.txt<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #ff0000;">&quot;deleted_imgs.csv&quot;</span></div></td></tr></tbody></table></div>

<p>This is the same kind of thing, it reads the file line by line (line 3 &amp; 12), looks for <em>_02_</em> line (line 5), uses the cut command to find the field it needs (line 7 &amp; 8), and writes them out to a file.</p>

<p>I then did a head to head execution. I kicked them both off before I headed to lunch.  I was gone for about an hour, and on return, the PowerShell script was still running, the bash script just finished.  The results of the bash script:</p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ time sh ./cleanup.sh<br />
<br />
real &nbsp; &nbsp;60m12.949s<br />
user &nbsp; &nbsp;8m55.905s<br />
sys &nbsp; &nbsp; 6m22.320s</div></div>

<p>I gave the PowerShell script another 45 mins, and it still hadn&#8217;t finished.  In fact, comparison of the file size output showed that the PowerShell script was well behind the Bash script.  This shocked me, I was expecting better performance from PowerShell that this paltry showing.  I stopped the script, and started looking for ways to improve the speed.</p>

<p>One of the things I pointed out at the beginning (from experience) is that I just couldn&#8217;t use Get-Content or Import-CSV because of the memory usage required to load the nearly 2 million rows from the file.  I wondered if the issue was also reversed when writing out the file. The <em>Add-Content</em> command is opening the file, seeking the end of the file, writing the new line, and closing it&#8230; 2 million times.  This is a <em>very</em> expensive operation, so we need to tweak the way this runs.  Falling back to some .Net, I decided to use [System.IO.File] again, and create a file handle to use.</p>

<p>This is the modified PowerShell script&#8230;</p>

<div class="codecolorer-container powershell default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #800080;">$ck</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.Diagnostics.Stopwatch<span style="color: #000000;">&#93;</span>::StartNew<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$base</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;E:\Photos&quot;</span><br />
<span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\deleted_imgs.csv&quot;</span><br />
<span style="color: #800080;">$sql</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;delete from photo_deleted where PhotoDeletedID = {0}&quot;</span><br />
<br />
<span style="color: #800080;">$p_file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\ps_file.txt&quot;</span><br />
<span style="color: #800080;">$p_sql</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Temp\photos\ps_sql.txt&quot;</span><br />
<br />
<span style="color: #800080;">$pf</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::CreateText<span style="color: #000000;">&#40;</span><span style="color: #800080;">$p_file</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #800080;">$ps</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::CreateText<span style="color: #000000;">&#40;</span><span style="color: #800080;">$p_sql</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$fh</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::OpenText<span style="color: #000000;">&#40;</span><span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span><br />
try <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">for</span> <span style="color: #000000;">&#40;</span>;;<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$line</span> <span style="color: pink;">=</span> <span style="color: #800080;">$fh</span>.ReadLine<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$line</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0000FF;">break</span>; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$line</span> <span style="color: #FF0000;">-like</span> <span style="color: #800000;">'*_02_*'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$data</span> <span style="color: pink;">=</span> <span style="color: #800080;">$line</span>.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">','</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800080;">$base</span> <span style="color: pink;">+</span> <span style="color: #800080;">$data</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$rem</span> <span style="color: pink;">=</span> <span style="color: #800080;">$sql</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$data</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">3</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$pf</span>.WriteLine<span style="color: #000000;">&#40;</span><span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$ps</span>.WriteLine<span style="color: #000000;">&#40;</span><span style="color: #800080;">$rem</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span>finally <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$fh</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #800080;">$pf</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #800080;">$ps</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$ck</span>.Stop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #800080;">$ck</span>.Elapsed</div></td></tr></tbody></table></div>

<p>The changes I made were really simple, I added line 10-11, to open the text file in write mode. I then changed the <em>Add-Content</em> line to WriteLine on line 26-27. I finally closed the file handles on line 35-36. I then re-executed the script&#8230;</p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Days &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: 0<br />
Hours &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 0<br />
Minutes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 1<br />
Seconds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 59<br />
Milliseconds &nbsp; &nbsp; &nbsp;: 742<br />
Ticks &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 1197426621<br />
TotalDays &nbsp; &nbsp; &nbsp; &nbsp; : 0.00138591044097222<br />
TotalHours &nbsp; &nbsp; &nbsp; &nbsp;: 0.0332618505833333<br />
TotalMinutes &nbsp; &nbsp; &nbsp;: 1.995711035<br />
TotalSeconds &nbsp; &nbsp; &nbsp;: 119.7426621<br />
TotalMilliseconds : 119742.6621</div></div>

<p>When I saw the results I practically fell off my chair. I couldn&#8217;t believe the actual numbers.  To compare, I verified the file sizes between the Linux batch&#8230;</p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ wc -l ps_*<br />
&nbsp; 1018490 ps_file.txt<br />
&nbsp; 1018490 ps_sql.txt<br />
<br />
$ wc -l bash_*<br />
&nbsp; 1018490 bash_files.txt<br />
&nbsp; 1018490 bash_sql.txt</div></div>

<p><strong>Wow!</strong> The file sizes were the same, the row count was the same, and the execution time was about 1/30th the time.  Could we say PowerShell wins this? I think so!</p>

<p>But, I stepped back and looked at the Bash script, and wondered if it too could be optimized.  Maybe it was having the same issue with open/seek/write/close? How much of an impact is using echo/cut having on the script execution? Is there a better way to split strings?</p>

<p>I did some hunting around, and stumbled across 2 resources that gave me some ideas.  The first was on string splitting.  I&#8217;d completely forgotten about $IFS, and how strings get handled by bash, and <a href="http://stackoverflow.com/questions/918886/split-string-based-on-delimiter-in-bash" title="StackOverflow; linux - splitting string based on delimiter">this</a> little post reminded me.  <em><a href="http://tldp.org/LDP/abs/html/internalvariables.html#IFSREF" title="TLDP; Advanced Bash Scripting - Internal Variables">$IFS</a></em> is an internal variable in Bash, which tells bash on what character to consider a field delimiter. By default it&#8217;s white space, and new line.  This can be changed, and Bash will consider a different field delimiter.  This is a really quick change.</p>

<p>The second was file handles.  This was a little harder to track down, but I stumbled across <a href="http://forums.devshed.com/unix-help-35/bash-scripting-using-file-descriptors-154812.html" title="BASH Scripting; Using File Descriptors">this</a> gem.  I&#8217;ve never used file descriptors before, but this post pointed me in the right direction.  So the tweaked script now looks like this:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">&lt;&gt;</span> <span style="color: #ff0000;">&quot;bash_sql2.txt&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">&lt;&gt;</span> <span style="color: #ff0000;">&quot;bash_files2.txt&quot;</span><br />
<br />
<span style="color: #007800;">OIFS</span>=<span style="color: #800000;">${IFS}</span><br />
<span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot;,&quot;</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line<br />
<span style="color: #000000; font-weight: bold;">do</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; echo &quot;${line}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> == <span style="color: #000000; font-weight: bold;">*</span>_02_<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">DATA</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #800000;">${line}</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">ID</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${DATA[3]}</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">URL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${DATA[1]}</span>&quot;</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ID=`echo &quot;${line}&quot; | cut -d, -f4`</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; URL=`echo &quot;${line}&quot; | cut -d, -f2`</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;delete from photo_deleted where PhotoDeletedID = <span style="color: #007800;">${ID}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">5</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;E:\Images<span style="color: #007800;">${URL}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">6</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #ff0000;">&quot;deleted_imgs.csv&quot;</span><br />
<br />
<span style="color: #007800;">IFS</span>=<span style="color: #800000;">${OIFS}</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span>-<br />
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span>-</div></td></tr></tbody></table></div>

<p>I made a copy of the existing <em>$IFS</em> string, and then changed it to a &#8220;,&#8221; character (line6-7).  I opened 2 new file handles descriptors to the files I wanted to write to (line 3-4).  On lines 13-15, I use the power of the <em>$IFS</em>, and get Bash to split the string into an array.  Lines 19-20 were tweaked to write to the file descriptors, and then they were closed in line 27-28.</p>

<p>So what&#8217;s the results?</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #000000; font-weight: bold;">time</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> .<span style="color: #000000; font-weight: bold;">/</span>cleanup.sh<br />
<br />
real &nbsp; &nbsp;5m8.391s<br />
user &nbsp; &nbsp;4m42.090s<br />
sys &nbsp; &nbsp; 0m18.369s</div></div>

<p>Another <strong>Wow!</strong>. Execution is down to about 8% of the original time, another massive improvement. Just to make sure I had the same results, I double checked the numbers:</p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ wc -l bash_*.txt<br />
&nbsp; 1018490 bash_files2.txt<br />
&nbsp; 1018490 bash_files.txt<br />
&nbsp; 1018490 bash_sql2.txt<br />
&nbsp; 1018490 bash_sql.txt</div></div>

<p>So same results, 8% execution time. I&#8217;d say those changes were a good improvement.</p>

<h2>Conclusion</h2>

<p>So who do we call winner? Well, something I failed to disclose at the start was the platforms.  Initially my plan was to use Cygwin to do the Linux execution side of this. When I attempted to run the initial Linux script, execution was so slow, I could have gone back home, had dinner, come back, and it still wouldn&#8217;t have been done.</p>

<p>The initial PowerShell script had gone through about 10x the file in half the time the Cygwin execution had taken.  This meant I needed to run the Linux script else where, so I fell back to my personal Linux server. For comparison, my laptop (PowerShell) is running Intel Core2 Duo T7520 (2x 2Ghz) with 4GB RAM, while my server is running an older Intel Core2 6300 (2x 1.86Ghz) with 1GB RAM.</p>

<p>So, there is a little bit of difference. I&#8217;ll leave it up to you guys to decide who should be the winner, but I will probably call it a tie.  The differences in the hardware probably allow for one script to execute faster than the other.</p>

<p>I don&#8217;t often spend a lot of time tinkering with some of the scripts I throw together, but this was a fun exercise in performance tweaking, and shows how simple 1-5 line changes can make a substantial improvement over execution. Next time you throw together a script, see what performance tweaks you can do.</p>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2012/03/07/powershell-vs-bash-string-processing-face-off/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>eclipse, TFS Everywhere, and new files</title>
		<link>http://jon.netdork.net/2012/01/22/eclipse-tfs-everywhere-and-new-files/</link>
		<comments>http://jon.netdork.net/2012/01/22/eclipse-tfs-everywhere-and-new-files/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 23:50:25 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[General Ramblings]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1436</guid>
		<description><![CDATA[I work in a mostly windows environment, until relatively recently, where we acquired a new company. The new company was mostly Mac, so I acquired myself a Mac Air. With that, I decided to see how much of my Windows life I could transport over there. I use Microsoft&#8217;s Team Foundation Server for managing source [...]]]></description>
			<content:encoded><![CDATA[<p>I work in a mostly windows environment, until relatively recently, where we acquired a new company.  The new company was mostly Mac, so I acquired myself a Mac Air.  With that, I decided to see how much of my Windows life I could transport over there.  I use Microsoft&#8217;s Team Foundation Server for managing source control, so I had to find a good alternative to trying to get Visual Studio working on a Mac platform.  Fortunately back in 2009, Microsoft acquired a company called Teamprise, which developer a client that worked on a variety of platforms.  Microsoft re-released that as TFS Anywhere.  I use TFS Anywhere to edit a lot of the files in TFS on my Mac, via <a href="http://www.eclipse.org">Eclipse</a>.</p>

<p>A few weeks ago I stumbled on an odd issue where Eclipse wasn&#8217;t keeping in-sync with what TFS Anywhere was doing.  For example, we keep our Nagios configs checked into TFS for version control.  I was using the Mac, and had added several new contact files.  When I was back using my Windows machine, I told Eclipse to trigger the &#8220;Get Latest&#8221; function on TFS Anywhere, which it dutifully did, then threw an error&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">The item $<span style="color: #000000; font-weight: bold;">/</span>infrastructure<span style="color: #000000; font-weight: bold;">/</span>Nagios<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>objects<span style="color: #000000; font-weight: bold;">/</span>contacts<span style="color: #000000; font-weight: bold;">/</span>newcontact.cfg already exists</div></div>

<p>It repeated this error for each of the new contacts I had added.  What appeared to be happening is TFS Anywhere was getting the files, notifying Eclipse the files were there, which triggered the project to add them to the file list, which then in turn triggered Eclipse to try an add them to TFS.  A nice little circle going there. I thought maybe it was just a quirk and closed the project.  When I reopened the project, the same error occurred again, this time I didn&#8217;t even tell Eclipse to do any updates, this occurred just on opening the project.</p>

<p>After some skimming around, I discovered this is likely a bug in TFS Anywhere, and the simple solution is to tell Eclipse to update the server information.  This is done using the &#8220;Team&#8221; context menu (right click the project), then selecting &#8220;Refresh Server Information&#8221;. Here is the <a href="http://social.msdn.microsoft.com/Forums/en-US/tee/thread/3377bf49-0dfc-4c0c-959b-203717bc6787/" title="MSDM Forums; Some files in project not attached to TFS">reference</a> post I found the details on.</p>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2012/01/22/eclipse-tfs-everywhere-and-new-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Journal, digital editions, and Apple</title>
		<link>http://jon.netdork.net/2012/01/20/linux-journal-digital-editions-and-apple/</link>
		<comments>http://jon.netdork.net/2012/01/20/linux-journal-digital-editions-and-apple/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 15:02:50 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Rantings]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1438</guid>
		<description><![CDATA[I&#8217;ve been a long time subscriber to Linux Journal, my closest has a box filled with old editions, and my bookshelf no longer has space, so I was glad to see they were going fully digital. I know they had a digital edition before, but it was one format. I was hoping the switch would [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a long time subscriber to <a href="http://www.linuxjournal.org">Linux Journal</a>, my closest has a box filled with old editions, and my bookshelf no longer has space, so I was glad to see they were going fully digital. I know they had a digital edition before, but it was one format. I was hoping the switch would mean they would expand the formats.</p>

<p><span id="more-1438"></span></p>

<p>I was excited to see them finally publish formats in <acronym title="Portable Document Format">PDF</acronym>, Mobi, and ePub. I was more interested in the latter because I have a Sony reader that handles ePub nicely. I get a nice email once a month with links to each of the formats. Quite handy.</p>

<p>Before I left on a trip to the corporate office in New York, I discovered there was an iPad app for Linux Journal, which allowed you to read the digital editions, so I decided to check it out. Installed easily, pretty easy to use, and looked good too. I opened the app, skimmed a few pages in the latest edition, it seemed a little slow at first, I assumed because it was still downloading some of the content. Once I&#8217;d visited a page, it loaded pretty quick afterwards. It displayed nicely, looked just like the old print magazine did. So I was happy.</p>

<p>I was happy until I was about 10k feet in the air, and was granted permission to use air-safe electronics. I opened up the edition I quickly skimmed at home, swipe past the first few pages, then get a pop-up telling me that I couldn&#8217;t read any more because it wasn&#8217;t online.</p>

<p>This is quite frustrating, fortunately I had planned the trip, and had several forms of entertainment planned out. I could pay the $25 for the flight to use the in-flight wifi, but that seems stupid, and expensive.</p>

<p>I&#8217;m not sure if the issue is with the app itself, or with Apple&#8217;s restrictions on publishers, but this limitation makes the iPad app rather useless, especially as I have the wifi only edition. Maybe I&#8217;m just not using it right. Does anybody else have any experience with it? Have you tried using it with Airplane mode?</p>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2012/01/20/linux-journal-digital-editions-and-apple/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerShell and SQLite</title>
		<link>http://jon.netdork.net/2011/11/27/powershell-and-sqlite/</link>
		<comments>http://jon.netdork.net/2011/11/27/powershell-and-sqlite/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 03:07:54 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1418</guid>
		<description><![CDATA[A while back I mentioned I was using SQLite with PowerShell. I was doing this because I had to access the database for gPodder to tweak some of the subscriptions. A need came up again today after upgrading gPodder to the latest release, and having issues with it. The first task is to get the [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I mentioned I was using SQLite with PowerShell.  I was doing this because I had to access the database for <a href="http://gpodder.org/" title="gPodder, a free podcast aggregator">gPodder</a> to tweak some of the subscriptions. A need came up again today after upgrading <a href="http://gpodder.org/" title="gPodder, a free podcast aggregator">gPodder</a> to the latest release, and having issues with it.</p>

<p><span id="more-1418"></span></p>

<p>The first task is to get the ADO.Net provider, which I found over <a href="http://sqlite.phxsoftware.com/" title="System.Data.SQLite ADO.NET Provider">here</a>.  The provider hasn&#8217;t been updated in a while, but still seems to work just fine. Next is loading the libraries, this is a case of calling the Assembly loader, so the code looks like this:</p>

<div class="codecolorer-container powershell default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000;">&#91;</span>void<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadFrom</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;C:\Temp\System.Data.SQLite.DLL&quot;</span><span style="color: #000000;">&#41;</span></div></div>

<p>Remember to update the path to reflect the actual location.  I have <code>[void]</code> at the beginning to hide the output of the library being loaded. If you are having issues, try removing it to see any errors.</p>

<p>Next is just like using any data object.</p>

<div class="codecolorer-container powershell default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Add<span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">@</span><span style="color: #800000;">'<br />
public class Subscription<br />
{<br />
&nbsp; &nbsp; public string url;<br />
&nbsp; &nbsp; public string title;<br />
}<br />
'</span><span style="color: pink;">@</span><br />
<br />
<span style="color: #000000;">&#91;</span>Void<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadFrom</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;C:\temp\System.Data.SQLite.DLL&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #800080;">$cn</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> <span style="color: #008080; font-style: italic;">-TypeName</span> System.Data.SQLite.SQLiteConnection<br />
<span style="color: #800080;">$cn</span>.ConnectionString <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Data Source=C:\temp\config\database.sqlite&quot;</span><br />
<span style="color: #800080;">$cn</span>.Open<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$cm</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> <span style="color: #008080; font-style: italic;">-TypeName</span> System.Data.Sqlite.SQLiteCommand<br />
<span style="color: #800080;">$sql</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;select title,url from channels&quot;</span><br />
<span style="color: #800080;">$cm</span>.Connection <span style="color: pink;">=</span> <span style="color: #800080;">$cn</span><br />
<span style="color: #800080;">$cm</span>.CommandText <span style="color: pink;">=</span> <span style="color: #800080;">$sql</span><br />
<br />
<span style="color: #800080;">$dr</span> <span style="color: pink;">=</span> <span style="color: #800080;">$cm</span>.ExecuteReader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #800080;">$subs</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #0000FF;">while</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$dr</span>.Read<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$sub</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Subscription<br />
&nbsp; &nbsp; <span style="color: #800080;">$sub</span>.url <span style="color: pink;">=</span> <span style="color: #800080;">$dr</span>.GetString<span style="color: #000000;">&#40;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$sub</span>.title <span style="color: pink;">=</span> <span style="color: #800080;">$dr</span>.GetString<span style="color: #000000;">&#40;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #800080;">$subs</span> <span style="color: pink;">+</span> <span style="color: #800080;">$sub</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
$subs</div></div>

<p>In this code, I&#8217;m creating a custom object to hold the subscription data in it, loading the libraries, and querying the &#8220;channels&#8221; table from the file <code>c:\temp\config\database.sqlite</code>, and then outputting the Title, and <acronym title="Uniform Resource Locator">URL</acronym> for the feed.</p>

<p>The great thing about PowerShell is it&#8217;s ability to pull in, and use any of the .NET libraries, making it incredibly flexible for quick scripts, as well as more in-depth work. The above script took all of about 5 minutes, and got my podcast list back.</p>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/11/27/powershell-and-sqlite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Toys</title>
		<link>http://jon.netdork.net/2011/11/26/android-toys/</link>
		<comments>http://jon.netdork.net/2011/11/26/android-toys/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 02:33:33 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1408</guid>
		<description><![CDATA[Okay, less toys, and more toy. Not only does our other entity work with Apple devices, we have an Android application. Currently development has been done using personal equipment, which has stunted the development to what few android phones we had available. So we decided to pick up a few more Android devices for them [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, less toys, and more toy.  Not only does our other entity work with Apple devices, we have an Android application.  Currently development has been done using personal equipment, which has stunted the development to what few android phones we had available. So we decided to pick up a few more Android devices for them to work with.</p>

<p><span id="more-1408"></span></p>

<p>Due to an unusual glitch in procurement<sup><a href="http://jon.netdork.net/2011/11/26/android-toys/#footnote_0_1408" id="identifier_0_1408" class="footnote-link footnote-identifier-link" title="Not the first one">1</a></sup>, an order of 2 Samsung Galaxy Tab 10.1 devices ended up as 2 <strong>boxes</strong> of them, so we ended up getting a shipment of 25 units.  My boss is working on figuring out what to do with the excess, but has decided to keep a few of the extras, so we&#8217;re sending 2, originally planned, units to the other office, and keeping 2 for us to play with.</p>

<p>First impressions? I&#8217;m going to break it down into hardware, and software.</p>

<p>First up, hardware. It feels like it&#8217;s all made of plastic. This is a good thing if you&#8217;re considering weight to be a factor in your tablet devices. The problem is, they used a faux brushed aluminum backing, which looks sort of cheap to me. The edging looks to be injection molded plastic, you can see the seams near the curved corners. The edging has tiny knicks in it which I can feel with my thumb. I don&#8217;t know if this is because I had it in my laptop bag, or if it came that way.</p>

<p>One thing that has me slightly baffled is placement of the power, and headphone jack. On one hand, I can see why their positioning makes perfect sense, on the other hand, it&#8217;s a completely mystery. The power connector is smack in the middle, at the bottom, if you&#8217;re holding it with the longest edge down. This makes sense because if you have a dock, it can seat nicely into a power connector, but when you&#8217;re holding it, or have it in your lap, you&#8217;ll have a nice power connector jabbing you in places it shouldn&#8217;t be jabbing.</p>

<p>The headphone jack is the one that gets me the most, and it&#8217;s most likely for a silly reason. The headphone jack is located about 1&#8243; right of center at the top of the screen, when held horizontally with longest edge down. Are you wondering why I think this is a stupid place? Plug in the headphones, and if you have the device in front of you, guess where the cable goes? In front of the screen. The solution, you have to either hold the cable to the side, or run it behind the tablet, which means you lose about 6&#8243; of headphone cable just to get it our of your view. This location doesn&#8217;t seem too terribly bad when you&#8217;re using it to play music while reading a vertical ebook for example, but watching a movie (which fits nicely with the dock, and power along the bottom) it seems to hamper viewing.</p>

<p>The final hardware issue that got me was power itself. Not the placement of it, but the requirement.  Battery life seems to be okay, I got away with watching two 90 minute episodes of a show I&#8217;ve been watching on Netflix, as well as reading about 30 pages of a large <acronym title="Portable Document Format">PDF</acronym>, surfing the internet, installing various applications, constantly updating my work email, and relatively heavy internet usage. It seemed to manage all this on a single charge, over 5 days. The problem came late Sunday at about 22:30 as I was laying in bed watching TV. This weird bleep alerted me to something I didn&#8217;t know of, so I looked, and it was sitting at about 15% power. I&#8217;d left the power block in the office, but I had the <acronym title="Universal Serial Bus">USB</acronym> cable in my bag, so I plugged it into my computer thinking it&#8217;d charge&#8230; Nothing. A quick search revealed that the Tab has a rather healthy power requirement. The power adapter, at least the US model, draws 2.5A.  That ampere requirement puts it 5 times higher than the <acronym title="Universal Serial Bus">USB</acronym> 2 specifications will allow for a device to pull. So I grumbled, and searched briefly to see if there was a way around this. There are some documents on how to do it with a rooted Tab, but I&#8217;m not going there with work gear, so I settled in for night, expecting the device to be dead by morning&#8230; I was wrong, it was still sitting at 15% when I woke at 6am. This gives a bit of a testament to the battery life of the device.</p>

<p>I was quite impressed with is the choice to have 2 speakers. This is great because if you&#8217;re holding it, one speaker frequently gets covered up. Also in a portrait orientation, you still have one speaker uncovered if you&#8217;re resting it on your lap.</p>

<p>The cameras both seem okay, and don&#8217;t seem to have any objections to low light pictures, even without flash. They get a little grainy, but nothing terrible.</p>

<p>Now ranting on hardware is done, it&#8217;s software&#8217;s turn. I don&#8217;t have a huge amount to say on this. I&#8217;ve been using Android on my cell phone for a while, so I had a rough idea on what to expect, but I was actually disappointed in the platform as a whole.  Email handling seems to be an after-thought. It seems to have no concept of sub-folders, as it decided to alphabetically sort ALL of my folders into a single level format.  This is fine if you&#8217;re that way inclined, except I have lots of nested folders, for example Notifications\Corporate\Staff. This just got just displayed as &#8220;Staff&#8221; and was sorted right next to &#8220;Sent&#8221;. While this isn&#8217;t a huge problem, it&#8217;s one thing that urks me. This isn&#8217;t just on talking to Exchange, the handling of my personal <acronym title="Internet Message Access Protocol">IMAP</acronym> server was worse. It had no respect for namespaces, so anything that was a &#8216;subfolder&#8217; due to namespaces was listed out as a complete folder name.  For example I have folder called SquirrelMail.Users.Admin, the <acronym title="Internet Message Access Protocol">IMAP</acronym> NAMESPACE command says that . is a folder delimiter, so that should be read as Admin is a sub of Users, which is a sub of SquirrelMail.  Instead, this is displayed exactly as it is named, SquirrelMail.Users.Admin. This makes for a messy list because there is no way to collapse folders I don&#8217;t want to look at on the device. That being said, Gingerbread on my Motorola Atrix handles both cases just fine, so I&#8217;m thinking it&#8217;s a quirk of Honeycomb.  Other than that, the software seems pretty indifferent to my Gingerbread cell phone.</p>

<p>On a better note, the platform is fast. I should hope it would be anyway, it has the NVIDA Tegra 2 in it, which is a dual core processor, along with 1GB RAM to play with. Everything seems to load nice and snappy, and leaving stuff running in the background doesn&#8217;t seem to hamper performance.  The wireless A/B/G/N support is nice too, especially as I have N at home and work. It never seems to have an issue getting a lock whilst swapping between work and home.  Samsung&#8217;s &#8220;Social Hub&#8221; could do with disappearing. It doesn&#8217;t bring anything to the table that the dedicated apps from the various social providers don&#8217;t already give, but it does it in a mediocre way.</p>

<p>It does come bundled with QuickOffice, which seems adequate for general document editing and such. QuickOffice&#8217;s <acronym title="Portable Document Format">PDF</acronym> reader seems to handle PDFs much nicer than the eBook application, or at least the big <acronym title="Portable Document Format">PDF</acronym> I am currently reading anyway.</p>

<p>Flash support seems to be one of its big marketting points, they make a strong emphasis on the packaging material, though I&#8217;ve yet to have a need for it. The one site you&#8217;d think you need it for (YouTube), has an Android app, making the need for it minimal. Not saying there aren&#8217;t people that use Flash heavily else where.</p>

<p>There are, of course, no shortage of games. I&#8217;ve not tested any out yet, but my son is dieing to get his hands on them. Maybe I&#8217;ll let him play, and see what he thinks too.</p>

<p>Overall? I&#8217;d give it a 7.5/10. Unfortunately it&#8217;s coming late into a market already dominated by the iPad. It&#8217;s a pricey device<sup><a href="http://jon.netdork.net/2011/11/26/android-toys/#footnote_1_1408" id="identifier_1_1408" class="footnote-link footnote-identifier-link" title="At $500 for the 16GB WiFi Only model">2</a></sup>, with some hardware quirks I&#8217;m trying to understand, and get around.  I&#8217;m also slightly disappointed in Honeycomb. I was expecting a little more out of it, but I just don&#8217;t see it.</p>

<p>My next post on toys will probably put the iPad against the Tab, and see how they stand up against each other.</p><ol class="footnotes"><li id="footnote_0_1408" class="footnote">Not the first one</li><li id="footnote_1_1408" class="footnote">At $500 for the 16GB WiFi Only model</li></ol>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/11/26/android-toys/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>IPv6 WAN Party</title>
		<link>http://jon.netdork.net/2011/11/07/ipv6-wan-party/</link>
		<comments>http://jon.netdork.net/2011/11/07/ipv6-wan-party/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 00:19:07 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1404</guid>
		<description><![CDATA[Joseph Kern has come up with a novel idea, an IPv6 WAN party. IPv6 is a big project that is going to impact everybody, even if they don&#8217;t know it. So this WAN party gives us a chance to get ahead of the curve, and get some much needed knowledge under out belts, while doing [...]]]></description>
			<content:encoded><![CDATA[<p>Joseph Kern has come up with a novel idea, an <a href="http://www.semafour.net/wanparty" title="Joseph Kern; semafour; wanparty">IPv6 <acronym title="Wide Area Network">WAN</acronym> party</a>.</p>

<p>IPv6 is a big project that is going to impact everybody, even if they don&#8217;t know it. So this <acronym title="Wide Area Network">WAN</acronym> party gives us a chance to get ahead of the curve, and get some much needed knowledge under out belts, while doing practical work.  Joseph&#8217;s idea is that we all setup IPv6, using Hurricane Electric&#8217;s &#8220;Tunnel Broker&#8221; service, on our home networks, then take the certification courses on <a href="http://ipv6.he.net" title="Hurricane Electric; IPv6">http://ipv6.he.net</a>.  There is even the possibility of a Google+ Hangout, while we&#8217;re working, for moral support.</p>

<p>If you&#8217;re interested, follow Joseph on twitter <a href="https://twitter.com/josephkern" title="Twitter; Joseph Kern">@josephkern</a> or the hashtag <a href="https://twitter.com/#!/search/%23ipv6wanparty" title="Twitter Search; #ipv6wanparty">#ipv6wanparty</a>. Initial plans look to host it on Saturday November 12th, at 12pm EST.</p>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/11/07/ipv6-wan-party/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Update and Error 0x800f0818</title>
		<link>http://jon.netdork.net/2011/11/04/windows-update-and-error-0x800f0818/</link>
		<comments>http://jon.netdork.net/2011/11/04/windows-update-and-error-0x800f0818/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 01:01:06 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1393</guid>
		<description><![CDATA[Microsoft Windows Update has a track record of having the worst error reporting, usually throwing error codes, rather than helpful errors. I stumbled on another case of this after I worked on 2 identical machines this week. Windows Update reported the unhelpful error code 0x800f0818 during an update of .Net 3.5 SP1. The scene, a [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft Windows Update has a track record of having the worst error reporting, usually throwing error codes, rather than helpful errors.  I stumbled on another case of this after I worked on 2 identical machines this week.  Windows Update reported the unhelpful error code 0x800f0818 during an update of .Net 3.5 SP1.</p>

<p><span id="more-1393"></span></p>

<p>The scene, a crazy busy week, frantically trying to do the jobs of 5.  I had 2 machines to do updates on, and get ready for some software.  These machines were identical, they were identical because one was built, then the other was cloned from that machine.   We&#8217;ll call the machines <em>DALIIS001</em> and <em>DALIIS002</em>, where <em>DALIIS002</em> was a clone of <em>DALIIS001</em>. During performing updates on these machines, I hit a stumbling point.  <em>DALIIS002</em> rocketed through the 65 initial updates, and was done in about 45 minutes. <em>DALIIS001</em> got stuck on 61 of 65. After about an hour stuck on the 1 update, I decided to go to bed<sup><a href="http://jon.netdork.net/2011/11/04/windows-update-and-error-0x800f0818/#footnote_0_1393" id="identifier_0_1393" class="footnote-link footnote-identifier-link" title="this was 23:30 after all">1</a></sup>. </p>

<p>When I got up, it was still sitting on 61 or 65, so I clicked cancel, nothing. I shut the machine down, and was promptly kicked from the remote desktop, but I noticed it wasn&#8217;t shutting down, so I used vmware console to look at the machine, and saw it had killed my session, but was still trying to install 61/65. So I did the thing the message on the screen said not to, I reset it.</p>

<p>The machine went through 3 reboots, and finally came up. When it tried to re-install that same update, it started throwing the error 0x800f0818.  The next round of updates recommended I installed <strong>System Update Readiness Tool</strong>. A quick look at the notes says it scans the system, and makes sure some stuff is ready for updates, and can fix common issues. I let it run, but it still had the same error.</p>

<p>After poking around a bit, I stumbled upon a blog post by <a href="https://twitter.com/laazyj" title="Twitter; Laazyj">Jason Duffett</a>, titled <a href="http://jasonduffett.net/post/5189439239/windows-2008-r2-service-pack-1-error" title="...on programming and stuff...; Windows 2008 R2 Service Pack 1 won’t install!">Windows 2008 R2 Service Pack 1 won’t install!</a>, who seemed to be having a similar issue with with 2008R2 SP1.  I had apparently missed something with the <em>System Update Readiness Tool</em> (SURT), and that was to look at the log.</p>

<p>As Jason had observed, SURT was finding corrupt files, but not fixing them. Fortunately I had a clone of the machine I was working on, so I followed Jason&#8217;s instructions, copied the necessary files to the broken machine, and re-ran SURT, this time showing no errors. After battling with the corrupt files, I re-ran the Windows Updates, and the .Net service pack installed, as did the Windows service pack.</p>

<p>It would be nice if Microsoft gave out more useful error messages, or at least a little more details to the error instead of forcing us to go digging through the depths of the operating system to find the cause of these mysterious error codes. A big thanks to Jason Duffett for having the solution.</p><ol class="footnotes"><li id="footnote_0_1393" class="footnote">this was 23:30 after all</li></ol>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/11/04/windows-update-and-error-0x800f0818/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Apple toys</title>
		<link>http://jon.netdork.net/2011/10/14/the-apple-toys/</link>
		<comments>http://jon.netdork.net/2011/10/14/the-apple-toys/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 22:22:38 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[General Ramblings]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/2011/10/14/the-apple-toys/</guid>
		<description><![CDATA[We recently acquired a new company, and introduced them into the fold. There is a big difference about the new addition compared to the rest of the organization. They are a Linux and Mac shop. They write their application in Perl, and 95% of the company use Mac computers, and the few machines that are [...]]]></description>
			<content:encoded><![CDATA[<p>We recently acquired a new company, and introduced them into the fold. There is a big difference about the new addition compared to the rest of the organization. They are a Linux and Mac shop. They write their application in <acronym title="Practical Extraction and Report Language">Perl</acronym>, and 95% of the company use Mac computers, and 
the few machines that are Windows based are for accounting purposes.</p>

<p>What does this mean for me? Well, we now have a bunch of Mac users and no staff to help support them. That&#8217;s not saying they don&#8217;t have the ability to support themselves, but sometimes they have questions and ask other sources. So we ordered a bunch of new gear, which means I now have a MacBook Air to play with, and as of yesterday an iPad<sup><a href="http://jon.netdork.net/2011/10/14/the-apple-toys/#footnote_0_1390" id="identifier_0_1390" class="footnote-link footnote-identifier-link" title="I&amp;#8217;m actually using the iPad and the WordPress app to type this">1</a></sup>.</p>

<p>Initial review? The Air is nice, but only for the hardware aspect. I&#8217;m still having issues and bugs sneak in, and working around some of the things I&#8217;m used to doing other ways is quite difficult. One of the reasons I installed Windows7 on it is because I have to make a lot of compromises to just get things working that are just PnP with Windows. That doesn&#8217;t include any of the Active Directory issues we&#8217;ve been having.</p>

<p>As for the iPad, there are some quirks that I&#8217;m struggling with, and some software choices I&#8217;ve yet to understand. They keyboard isn&#8217;t fast enough to keep up, and constantly misses letters. Even in landscape mode, it causes cramps in my knuckles. Software wise, missing stuff like the subscribe options for podcasts in iTunes, seem weird to me.</p>

<p>I&#8217;m a Windows/Linux guy, I cannot fault the stuff Apple has done, they really have changed the market, but I have issues with some of the stuff and how it is setup. This might just be because ive been using the other platforms for so long.</p>

<p>I&#8217;ll probably post a better review after I&#8217;ve spent more time using both. Have any of you switched platform. What kinds of issues did you run into? What quirks can&#8217;t you get over? What things would you like on your original platform?</p><ol class="footnotes"><li id="footnote_0_1390" class="footnote">I&#8217;m actually using the iPad and the WordPress app to type this</li></ol>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/10/14/the-apple-toys/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>VMware VirtualCenter Management Webservices service terminated with service-specific error 0</title>
		<link>http://jon.netdork.net/2011/08/21/vmware-virtualcenter-management-webservices-service-terminated-with-service-specific-error-0/</link>
		<comments>http://jon.netdork.net/2011/08/21/vmware-virtualcenter-management-webservices-service-terminated-with-service-specific-error-0/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 15:07:46 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[General Ramblings]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=1364</guid>
		<description><![CDATA[Earlier this week while trying to establish some potential bottle-necks on our VMware ESXi servers, I noticed an odd issue with the performance tab. When clicking on performance, the &#8220;Overview&#8221; tab would throw a generic browser type error about not being able to connect. Clicking on the detailed view seemed to work just fine. Doing [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week while trying to establish some potential bottle-necks on our VMware ESXi servers, I noticed an odd issue with the performance tab.  When clicking on performance, the &#8220;Overview&#8221; tab would throw a generic browser type error about not being able to connect.  Clicking on the detailed view seemed to work just fine.  Doing some stumbling around, I fell upon <a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1014454" title="VMware KB 1014454; The Performance Overview tab fails to display with the error 'Navigation to the webpage was cancelled'">KB1014454</a>.</p>

<p><span id="more-1364"></span></p>

<p>This pointed out the potential error was that the web service that hosted the performance data wasn&#8217;t running.  A quick check from the server showed the machine wasn&#8217;t listening on the listed port 8443.  This is handled by the &#8220;vCenter Web Management Services&#8221; service, and a quick peek showed the service wasn&#8217;t running.  That&#8217;s easy, a quick right click and start and we should be good to go again&#8230; Right? In this case, wrong. When attempting to start the service, Windows reported the service failed to start, and looking in the Windows event log, we were presented with the error:</p>

<blockquote>
VMware VirtualCenter Management Webservices service terminated with service-specific error 0
</blockquote>

<p>Some more searching around, and I stumbled on a <a href="http://virtualization-spotlight.com/web-access-service-fails-to-start-after-vcenter-install/">gem</a> over at the &#8216;Virtualization Spotlight&#8217; blog.  The post points to the Tomcat logs on the server showing an issue with starting the Tomcat service. Digging into the Tomcat logs, and I was seeing the same error:</p>

<pre>
[994  prunsrv.c] [error] Failed creating java
[1269 prunsrv.c] [error] ServiceStart returned 1
</pre>

<p>Failed to create java?  The second hint in the post is referencing the path to java.dll.  After some thinking I tried to remember when I last saw this working, and I think it was right after upgrading ESXi 4.0 to 4.0U3.  Did the upgrade remove a path reference? Maybe, the solution is simple, just put it back.</p>

<p>Unfortunately it appears JRE had disappeared, maybe it was supposed to be upgraded as part of U3 update, but it wasn&#8217;t there any more.  So I reinstalled JRE again.  I grabbed a copy from the Oracle site <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" title="Java SE Downloads">here</a> using the latest v6 update<sup><a href="http://jon.netdork.net/2011/08/21/vmware-virtualcenter-management-webservices-service-terminated-with-service-specific-error-0/#footnote_0_1364" id="identifier_0_1364" class="footnote-link footnote-identifier-link" title="At the time of writing this was Java SE 6 Update 27">1</a></sup>, and installed it into the path <code>C:\Program Files\VMware\Infrastructure\jre\</code>.  Once installed, I attempted to restart the service, and it came up immediately.  This also got the performance overview tab working again too.</p><ol class="footnotes"><li id="footnote_0_1364" class="footnote">At the time of writing this was Java SE 6 Update 27</li></ol>]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2011/08/21/vmware-virtualcenter-management-webservices-service-terminated-with-service-specific-error-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: jon.netdork.net @ 2012-05-20 08:33:03 -->
