<?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>108.bz</title>
	<atom:link href="http://www.108.bz/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.108.bz</link>
	<description>Wandering futilities...</description>
	<lastBuildDate>Fri, 27 May 2011 09:08:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Google Data API, Google Apps, Provisioning and OAuth</title>
		<link>http://www.108.bz/posts/it/google-data-api-google-apps-provisioning-and-oauth/</link>
		<comments>http://www.108.bz/posts/it/google-data-api-google-apps-provisioning-and-oauth/#comments</comments>
		<pubDate>Thu, 26 May 2011 21:48:06 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Apps]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=728</guid>
		<description><![CDATA[The following info is blatantly stolen from this precious post, but the issue I faced is so odd that I wanted to stress about it myself. All credits go to Philip Hofstetter and his blog. [Edit: the following still applies even when, as described here, the Provisioning API is enabled.] [Edit: the script below doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>The following info is blatantly stolen from <a href="http://www.gnegg.ch/2010/06/google-apps-provisioning-two-legged-oauth/">this</a> precious post, but the issue I faced is so odd that I wanted to stress about it myself. All credits go to Philip Hofstetter and his blog.</p>
<p>[Edit: the following still applies even when, as described <a href="http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_reference.html">here</a>, the Provisioning API is enabled.]<br />
[Edit: the script below doesn&#8217;t handle Results Pagination. That means that it will just return the first 200 or so queried objects. I&#8217;ve yet to complete it&#8230; Depending on your needs, you may just use <a href="http://code.google.com/p/google-apps-manager/">Google Apps Manager</a> instead.</p>
<p>I was trying to fetch some info using Google Data API and Python. At some point, I decided to move from simple authentication with user supplied credentials to two-legged OAuth. The Contact feed remained accessible while trying to read Groups, Users or Nicknames (by means of the <a href="http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_developers_protocol.html">Provisioning API</a>) failed with &#8220;Internal Error&#8221; 500 or &#8220;Authentication Failure&#8221;.</p>
<p>As Philip discovered, some feeds just won&#8217;t work unless explicitly permitted access to.<br />
Inconsistency 1: You API Client name (the one you&#8217;ll use as &#8220;customer_key&#8221; in OAuth and the one whose name will most likely match your Google Apps domain name), is already listed under &#8220;Manage this domain&#8221;, &#8220;Advanced tools&#8221;, &#8220;Manage third party OAuth Client access&#8221;. The wording &#8220;This client has access to all APIs&#8221; is clearly a lie.<br />
Inconsistency 2: I followed Philip advice and manually added the (readonly) feeds/scopes, except that <i>they don&#8217;t show up</i> under &#8220;Manage API client access&#8221;. But they&#8217;re somewhat being honored (i.e.: without the tweak, my script won&#8217;t work). Moreover, the &#8220;Authorize&#8221; operation should be done just once and encompass all of the scopes you need. You can&#8217;t just add one later. Adding a single scope will revoke access to the previous ones. This behaviour is different from Philip&#8217;s (in his screenshots, authorized scopes are indeed visible on Google Apps Domain Control Panel).<br />
This is what I used:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">https://apps-apis.google.com/a/feeds/group/#readonly,https://apps-apis.google.com/a/feeds/user/#readonly,https://apps-apis.google.com/a/feeds/nickname/#readonly</div></div>
<p>And this is the script:</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span><br />
<br />
<span style="color: #808080; font-style: italic;"># $Id: list_groups_emails_oauth.py,v 1.3 2011/05/26 16:12:42 giuliano Exp giuliano $</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">string</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: black;">apps</span>.<span style="color: black;">service</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: black;">apps</span>.<span style="color: black;">groups</span>.<span style="color: black;">service</span><br />
<br />
consumer_key = <span style="color: #483d8b;">'yourdomain.com'</span><br />
consumer_secret = <span style="color: #483d8b;">'yourOAuthkey'</span><br />
sig_method = gdata.<span style="color: black;">auth</span>.<span style="color: black;">OAuthSignatureMethod</span>.<span style="color: black;">HMAC_SHA1</span><br />
<br />
service = gdata.<span style="color: black;">apps</span>.<span style="color: black;">groups</span>.<span style="color: black;">service</span>.<span style="color: black;">GroupsService</span><span style="color: black;">&#40;</span>domain=consumer_key<span style="color: black;">&#41;</span><br />
service.<span style="color: black;">SetOAuthInputParameters</span><span style="color: black;">&#40;</span>sig_method, consumer_key, consumer_secret=consumer_secret, two_legged_oauth=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
res = service.<span style="color: black;">RetrieveAllGroups</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> entry <span style="color: #ff7700;font-weight:bold;">in</span> res:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'group;'</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span>entry<span style="color: black;">&#91;</span><span style="color: #483d8b;">'groupId'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
<br />
service = gdata.<span style="color: black;">apps</span>.<span style="color: black;">service</span>.<span style="color: black;">AppsService</span><span style="color: black;">&#40;</span>domain=consumer_key<span style="color: black;">&#41;</span><br />
service.<span style="color: black;">SetOAuthInputParameters</span><span style="color: black;">&#40;</span>sig_method, consumer_key, consumer_secret=consumer_secret, two_legged_oauth=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
<br />
res = service.<span style="color: black;">RetrieveAllUsers</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> entry <span style="color: #ff7700;font-weight:bold;">in</span> res.<span style="color: black;">entry</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'email;'</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span>entry.<span style="color: black;">login</span>.<span style="color: black;">user_name</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'@'</span> + consumer_key<br />
<br />
res = service.<span style="color: black;">RetrieveAllNicknames</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> entry <span style="color: #ff7700;font-weight:bold;">in</span> res.<span style="color: black;">entry</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>entry, <span style="color: #483d8b;">'nickname'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'alias;'</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span>entry.<span style="color: black;">nickname</span>.<span style="color: black;">name</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'@'</span> + consumer_key</div></div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=728" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fgoogle-data-api-google-apps-provisioning-and-oauth%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fgoogle-data-api-google-apps-provisioning-and-oauth%2F&amp;count=horizontal&amp;text=Google%20Data%20API%2C%20Google%20Apps%2C%20Provisioning%20and%20OAuth: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fgoogle-data-api-google-apps-provisioning-and-oauth%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fgoogle-data-api-google-apps-provisioning-and-oauth%2F&amp;title=Google%20Data%20API%2C%20Google%20Apps%2C%20Provisioning%20and%20OAuth"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/google-data-api-google-apps-provisioning-and-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slow write performance and partition alignment</title>
		<link>http://www.108.bz/posts/it/slow-write-performance-and-partition-alignment/</link>
		<comments>http://www.108.bz/posts/it/slow-write-performance-and-partition-alignment/#comments</comments>
		<pubDate>Tue, 24 May 2011 21:45:00 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=717</guid>
		<description><![CDATA[Or how a single sector can make you ten times more happier. Today I&#8217;ll talk about a client issue: getting (extremely) slow write performance when backing up my laptop over an USB drive (a 200GB Samsung S1 Mini). All I usually do is booting the PC with SystemRescueCd, plug an USB disk in, &#8220;ddrescue /dev/sda [...]]]></description>
			<content:encoded><![CDATA[<p>Or how a single sector can make you ten times more happier.<br />
Today I&#8217;ll talk about a client issue: getting (extremely) slow write performance when backing up my laptop over an USB drive (a 200GB Samsung <a href="http://www.samsung.com/global/business/hdd/external/external_mini.html">S1 Mini</a>). All I usually do is booting the PC with <a href="http://www.sysresccd.org/">SystemRescueCd</a>, plug an USB disk in, &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;"><a href="http://www.gnu.org/software/ddrescue/ddrescue.html">ddrescue</a> /dev/sda /mnt/externaldisk/laptop_disk_image.dd</a></span>&#8220;, letting it run overnight. Except that this morning the backup wasn&#8217;t finished yet. What&#8217;s wrong? Long post (for a simple solution) ahead&#8230;</p>
<p>The USB disk (shown below as <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/sdb*</span>) &#8220;feels&#8221; fast when reading and awfully slow when writing. The most simple way to do an HDD benchmark is, of course <a href="http://en.wikipedia.org/wiki/Dd_(Unix)">dd</a>. Use it along with <a href="http://dag.wieers.com/home-made/dstat/">dstat</a> (an essential tool when pinpointing performance issues, whatever they may be) and you&#8217;ll quickly gather some useful figures. <i>Beware!</i> <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dd</span> can ruin all your data just by mistaking a &#8220;b&#8221; for an &#8220;a&#8221;: triple-check and make sure that you&#8217;re running it on the right devices!</p>
<p>A sequential write test:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # dd if=/dev/zero of=/mnt/temp/x.bin bs=16384 count=$((100*1024))<br />
102400+0 records in<br />
102400+0 records out<br />
1677721600 bytes (1.7 GB) copied, 455.334 s, 3.7 MB/s</div></div>
<p>3.7 MB/s only, definitely slow. <img src='http://www.108.bz/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  Note that you shouldn&#8217;t use <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/{random,urandom}</span> as input file, they&#8217;re a bottleneck by themselves. <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/zero</span>, on the other hand, is super-fast. &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dd if=/dev/zero of=/dev/null bs=16384 count=$((10000*1024))</span>&#8221; (shove zeros to /dev/null) is bound only by the CPU, running at about 9.3 GB/s here.</p>
<p>A sequential read test:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # dd if=/mnt/temp/x.bin of=/dev/null bs=16384 count=$((100*1024))<br />
102400+0 records in<br />
102400+0 records out<br />
1677721600 bytes (1.7 GB) copied, 52.1106 s, 32.2 MB/s</div></div>
<p>30 MB/s, that&#8217;s the order of magnitude I was expecting (confirmed <a href="http://www.storagereview.com/samsung_s1_mini_review">here</a>).</p>
<p>If I repeat the write test and, at the same time, run <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dstat</span>, I notice that there are no burst or drops: speed is constant.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog linux-2.6.36-gentoo-r5 # dstat -p -d -D sdb<br />
---procs--- --dsk/sdb--<br />
run blk new| read &nbsp;writ<br />
&nbsp; 0 &nbsp; 0 1.0| 362k &nbsp;888k &nbsp; &nbsp;# &lt;-- ignore the first sample<br />
&nbsp; 0 &nbsp; 0 &nbsp; 0| &nbsp; 0 &nbsp; &nbsp; 0 <br />
4.0 1.0 1.0| &nbsp; 0 &nbsp; &nbsp; 0 <br />
1.0 2.0 &nbsp; 0| &nbsp; 0 &nbsp; 360k &nbsp; &nbsp;# &lt;-- &quot;dd&quot; starts<br />
&nbsp; 0 2.0 &nbsp; 0| &nbsp; 0 &nbsp;3360k<br />
&nbsp; 0 2.0 &nbsp; 0| &nbsp; 0 &nbsp;3240k<br />
1.0 2.0 &nbsp; 0| &nbsp; 0 &nbsp;3240k<br />
&nbsp; 0 2.0 &nbsp; 0| &nbsp; 0 &nbsp;3240k</div></div>
<p>Since reading works, kernel and USB Host Controller seem to go along well. Issue should lie on the disk&#8217;s side. I had no clue of what was happening until I tried writing straight to the disk instead of the first primary partition (i.e.: /dev/sdb instead of /dev/sdb1), thus <i>trashing the filesystem</i> (I&#8217;ve got no data to lose on that disk: no worries).</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # dd if=/dev/zero of=/dev/sdb bs=16384 count=$((100*1024))<br />
1677721600 bytes (1.7 GB) copied, 63.0382 s, 26.6 MB/s</div></div>
<p>Even though the difference between read and write throughput seems to be too much (almost one order of magnitude), this is starting to look like a FS blocksize/partition aligment issue. Well, some disks use a physical sector size (PSS) of 512 bytes. Others use 4096 bytes (4 KiB). Others use the latter but tell the OS that they&#8217;re using 512 bytes or more simply the OS can&#8217;t figure out the right physical sector size&#8230; And USB mass storage devices tell the OS almost nothing (<a href="http://en.wikipedia.org/wiki/Hdparm">hdparm</a> won&#8217;t help this time)&#8230;</p>
<p>Filesystem (or other &#8220;structured storage&#8221; systems like, for instance, datafiles in databases) organize their data in blocks. The <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">block size</span> can sometimes be adjusted. 4096 bytes is a quite common value:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # tune2fs -l /dev/sdb1 | grep -i block.size<br />
Block size: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4096</div></div>
<p>A sector represents the smallest chunk of data that can be read/written from/to a disk. If its size is 512, and the filesystem block size is 4096, the filesystem driver will read/write batches of 8 sectors. Better said: the FS thinks to deal with 4k blocks, not knowing that lower level functions will further split them in eight (if only logically).<br />
Consider another example: the PSS is 4096, but the drive acts as if it was 512.  Physical sectors can be found at absolute offset sector_number*512*8 (0, 4096, 8192, &#8230;).  What if a 4k write operation happens at offset 1*512*8-512? (3584, it doesn&#8217;t look like a &#8220;bad&#8221; offset: as far as the OS is concerned, any multiple of 512 is fine). The drive, being unable to write less than 4k and at proper locations, will: read sector 0, read sector 1, modify the last 512 bytes chunk of sector 0, modify the first three chunks of sector 1 then write both sectors (or something similar). If things were properly aligned, a single write operation would&#8217;ve sufficed. Read operations speed, on the other hand, may be almost unaffected. Think about it: unless you&#8217;re dealing with tons of 4k files spread across sector couples (i.e.: two sectors read instead of one), large chunks of data are (hopefully) laid out sequentially of the disc. Reading 1GB plus 512 bytes, instead of 1GB alone, won&#8217;t change anything benchmarks.</p>
<p>What&#8217;s up with my partition?</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # sfdisk -uS -l /dev/sdb &nbsp; &nbsp;<br />
<br />
Disk /dev/sdb: 24321 cylinders, 255 heads, 63 sectors/track<br />
Units = sectors of 512 bytes, counting from 0<br />
<br />
&nbsp; &nbsp;Device Boot &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; End &nbsp; #sectors &nbsp;Id &nbsp;System<br />
/dev/sdb1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;63 390716864 &nbsp;390716802 &nbsp;83 &nbsp;Linux</div></div>
<p><span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">sfdisk</span> (one of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">fdisk</span>&#8216;s cousins) shows that the partition starts at byte 63*512=32256. This value isn&#8217;t divisible by 4096, yielding a non integer result. Sector 64, instead, is a good place to start an aligned partition:</p>
<p>63*512/4096 = 7.87<br />
64*512/4096 = 8.00   </p>
<p>Similarly, other partitions should start at sectors that are multiples of 8 (because 512*8=4096).<br />
This is the corrected partition table. Moving the partition forward (by a mere 512 bytes) causes a 10x write speed increase.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">balrog ~ # sfdisk -uS -l /dev/sdb<br />
<br />
Disk /dev/sdb: 24321 cylinders, 255 heads, 63 sectors/track<br />
Units = sectors of 512 bytes, counting from 0<br />
<br />
&nbsp; &nbsp;Device Boot &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; End &nbsp; #sectors &nbsp;Id &nbsp;System<br />
/dev/sdb1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;64 390721967 &nbsp;390721904 &nbsp;83 &nbsp;Linux</div></div>
<p>You may still have a question though. Does aligning a <i>partition</i> mean that the contained <i>filesystem</i> is aligned too? You&#8217;re right, that assumption should not be taken for a fact.</p>
<p>A filesystem is made up of &#8220;your&#8221; data and &#8220;its&#8221; data (the latter being internal structures necessary to organize the former). In any case, a FS will try to pad/align stuff to the block size. That was to say that, if you start a partition and the partition is aligned to a given boundary, the filesystem (all of its composing blocks) will be aligned too.</p>
<p>You can find a description of the ext2 layout <a href="http://www.nongnu.org/ext2-doc/ext2.html#DISK-LAYOUT-SAMPLE-20MB">here</a>. Partition starts with two sectors reserved for the boot loader. Then comes a 1k chunk holding ext2 &#8220;superblock&#8221;. At offset 56 within the superblock, we should find the ext2 magic number (0x53EF), and here it is:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">giuliano@giuliano ~ $ dd if=/dev/sdb1 bs=512 skip=2 count=1 2&gt;/dev/null | xxd -s +56 -l 2<br />
0000038: 53ef &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S.</div></div>
<p>The next byte after the superblock, is byte 4096. From then on, everything happens (from the FS point of view) in chunks as big as the configured block size. My disk is a 4k sector disk, formatted with a single partition aligned (as the FS) to a 4K block. FS block size is 4K too. Can&#8217;t do really do any better than that besides choosing a filesystem that manages to handle the given workload with fewer read/write operations, but I digress&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=717" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fslow-write-performance-and-partition-alignment%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fslow-write-performance-and-partition-alignment%2F&amp;count=horizontal&amp;text=Slow%20write%20performance%20and%20partition%20alignment: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fslow-write-performance-and-partition-alignment%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fslow-write-performance-and-partition-alignment%2F&amp;title=Slow%20write%20performance%20and%20partition%20alignment"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/slow-write-performance-and-partition-alignment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>About path thrashing and why you should always zone</title>
		<link>http://www.108.bz/posts/it/about-path-thrashing-and-why-you-should-always-zone/</link>
		<comments>http://www.108.bz/posts/it/about-path-thrashing-and-why-you-should-always-zone/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 08:58:36 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[SAN]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=703</guid>
		<description><![CDATA[So, Customer starts updating all of his VMware ESX hosts and things turn out for the worst. VMs are crawling slow (ping response time from 0 to 1000ms), console access through vSphere client doesn&#8217;t always work, and hosts&#8217; CPU percentage is unnaturally high. Cause is apparent: path thrashing. Path thrashing happens when, for some reason, [...]]]></description>
			<content:encoded><![CDATA[<p>So, Customer starts updating all of his VMware ESX hosts and things turn out for the worst. VMs are crawling slow (ping response time from 0 to 1000ms), console access through vSphere client doesn&#8217;t always work, and hosts&#8217; CPU percentage is unnaturally high. Cause is apparent: path thrashing.<br />
Path thrashing happens when, for some reason, SCSI LUNs are being continuously reassinged from a controller (Target) to another one. ESX has a hard time &#8220;bouncing&#8221; I/O back and forth on the right Fibre Channel path. On Active/Passive SAN arrays a LUN can be &#8220;owned&#8221; by just one controller at a time. If the LUN owner has to be changed because of a hardware failure (path, Controller, SFP/GBIC, FC switch, &#8230;) or because the Initiator would like to, the LUN itself has to &#8220;trespass&#8221; (in EMC parlance), transition to another controller. The &#8220;command&#8221; to do so can be issued by the Initiator or internally by the storage subsystem.<br />
Back to today&#8217;s case, I was dealing with an IBM DS4800 where LUNs flipped like mad between controller A and B. How to stop it quickly?</p>
<ul>
<li>If anything, the flipping shows that failover works as expected (VMs don&#8217;t crash despite the chaos).</li>
<li>That said, I could just disconnect a controller. Not really because the same storage system hosts an Oracle RAC cluster, humming along happily, unaffected by the issue.</li>
<li>I need a way to selectively &#8220;hide&#8221; a controller from one or more hosts. I can do it easily by tweaking the SAN zoning configuration.</li>
</ul>
<p>A Zone (much like a VLAN) is basically a group of WWNs (or ports). Objects in the Zone can only talk to each other. While creating Zones, it is common practice to &#8220;go minimal&#8221;: they should contain as few stuff as possible. I usually name them like this:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Z_HOSTNAME_P1_DS4800_CA1_CB1</span><br />
HBA Port 1 of HOSTNAME can see Controller A/Port 1 and Controller B/Port 1 of the DS4800.<br />
Thus, going through each ESX server&#8217;s Zone, I just remove the Controller that the host shouldn&#8217;t see. Path thrashing is temporarily stopped.<br />
The above rant serves mainly as a pro-zoning argument. &#8220;If every HBA port has to access every Controller&#8217;s port, why implement zoning?&#8221;. As you just read, zoning saved me from serious trouble, today.<br />
About the &#8220;real&#8221; issue, it was ultimately caused by a thing called &#8220;Auto Volume Transfer&#8221; (AVT)<sup class='footnote'><a href='#fn-703-1' id='fnref-703-1'>1</a></sup>. Let&#8217;s say that a LUN is assigned to controller A, but I/O for the LUN is issued to controller B. With AVT switched on the storage system will automatically transfer the LUN from A to B.<br />
The Customer ESX servers are all (correctly) configured to use the &#8220;Most Recently Used&#8221; (MRU) <a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#038;cmd=displayKC&#038;externalId=1003973">path</a> to a LUN. It seems that ESX, from a certain version on, issues I/O on the standby path, causing havoc if AVT is on. I can&#8217;t tell if that&#8217;s because it is fooled into thinking that the storage is an Active/Active one or if it just sort of periodically &#8220;probes&#8221; standby paths.<br />
How do you switch AVT off? By using the DS &#8220;Storage Manager&#8221; and changing the ESX Hosts&#8217; type from &#8220;Linux&#8221; (or whatever) to &#8220;LNXCLVMWARE&#8221;. This applies to all of the LSI derived Storage Systems (IBM, SUN StorageTek, Engenio, &#8230;). The latter host type is the right one to use when hooking an ESX cluster to an IBM DS Storage System. But &#8220;Linux&#8221; seems to do just fine on not so new ESX hosts version 4.1.x &#8230; When AVT is off, the Storage will decide to trespass LUNs only in the event of an internal hardware failure while, normally, LUN ownership will be handled by the multipathing software on the Host.</p>
<p>More reading on the subject:</p>
<p>[<a href="https://www.ibm.com/developerworks/forums/message.jspa?messageID=14532649">1</a>] Differences between the &#8220;Linux&#8221; and &#8220;LNXCLVMWARE&#8221; host types.<br />
[<a href="http://webcache.googleusercontent.com/search?q=cache:SP6Ytyb4-0YJ:https://selfservice.lsi.com/service/main.jsp%3Bjsessionid%3D0637AE74501C3CB54E44A071BEFF108D%3Ft%3DsolutionTab%26ft%3DsearchTab%26ps%3DsolutionPanels%26locale%3Den_US%26_dyncharset%3DUTF-8%26curResURL%3D%252Fservice%252Fmain.jsp%253Bjsessionid%253D0637AE74501C3CB54E44A071BEFF108D%253F_dyncharset%253DUTF-8%2526_dynSessConf%253D3633170421896306112%2526t%253DsearchTab%2526locale%253Den_US%2526_dyncharset%253DUTF-8%2526topicName%253D%2526sfield%253D%2526dosearch%253Dtrue%2526searchstring%253DQuery%25252520does%25252520not%25252520work%25252520in%25252520WINS%2526useFocusTopic%253Dtrue%2526focusTopic%253D9000029%26solutionId%3DLSI7423%26isSrch%3DYes+site:selfservice.lsi.com+AVT&#038;cd=1&#038;hl=en&#038;ct=clnk&#038;client=opera&#038;source=www.google.com">2</a>] <i>How does Auto Volume Transfer (AVT) work?</i> Courtesy of Google&#8217;s cache. Lists which SCSI commands trigger AVT.<br />
[<a href="https://www.ibm.com/developerworks/mydeveloperworks/blogs/VirtuallySpeaking/entry/vmware_scsi_errors_and_conditions_ibm_ds_storage_systems1?lang=en">3</a>] A really nice blog post about the same issue described here. (Found, of course, when I was writing mine)</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-703-1'>or even &#8220;Auto Disk Transfer&#8221; (ADT) <span class='footnotereverse'><a href='#fnref-703-1'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=703" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fabout-path-thrashing-and-why-you-should-always-zone%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fabout-path-thrashing-and-why-you-should-always-zone%2F&amp;count=horizontal&amp;text=About%20path%20thrashing%20and%20why%20you%20should%20always%20zone: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fabout-path-thrashing-and-why-you-should-always-zone%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fabout-path-thrashing-and-why-you-should-always-zone%2F&amp;title=About%20path%20thrashing%20and%20why%20you%20should%20always%20zone"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/about-path-thrashing-and-why-you-should-always-zone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cloning DHCP reservations between Windows servers</title>
		<link>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/</link>
		<comments>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 16:01:30 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=688</guid>
		<description><![CDATA[Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers [...]]]></description>
			<content:encoded><![CDATA[<p>Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers are active on that particular ethernet segment. Depending on their number, the PC will receive one or more answer, each offering an IP address. If a client is to be assigned a fixed IP, all of those offers should bear the same IP address. Hence, DHCP reservations need to be configured the same for every DHCP server in the given scope. As far as I know, this needs to be done by hand. To speed up the process, I use <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> (see <a href="http://technet.microsoft.com/en-us/library/cc787375(WS.10).aspx">Netsh commands for DHCP</a>).</p>
<p>The command below will dump all of the reservations to a file named &#8220;reservations.txt&#8221;. <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">findstr</span> filters <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> output keeping just the info we need.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh dhcp server \\dhcpsrv1 scope 10.4.0.0 dump | findstr Add.reservedip &gt; reservations.txt</div></div>
<p>Each line in &#8220;reservations.txt&#8221; should look like this:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Dhcp Server 10.4.1.1 Scope 10.4.0.0 Add reservedip 10.4.5.3 58b04576339a &quot;pcname.domain.lan&quot; &quot;Reservation Comment&quot; &quot;BOTH&quot;</div></div>
<p><span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">10.4.1.1</span> is the IP address for <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dhcpsrv1</span>, the &#8220;source&#8221; DHCP server.</p>
<p>Open &#8220;reservations.txt&#8221; in a text editor, check that everything is fine and substitute the source DHCP server IP with the target&#8217;s one (i.e.: 10.4.1.1 becomes 10.4.1.2), save the file and run:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh &lt; reservations.txt<br />
netsh&gt;<br />
Changed the current scope context to 10.4.0.0 scope.<br />
<br />
Command completed successfully.<br />
netsh&gt;<br />
Command completed successfully.<br />
netsh&gt;<br />
[..]</div></div>
<p>That&#8217;s it; not a fancy trick, but it may be useful nonetheless. Just beware that, when there are thousands of clients, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> could take a while to complete its job (especially the &#8220;dump&#8221; step)&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=688" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-dhcp-reservations-between-windows-servers%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-dhcp-reservations-between-windows-servers%2F&amp;count=horizontal&amp;text=Cloning%20DHCP%20reservations%20between%20Windows%20servers: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-dhcp-reservations-between-windows-servers%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-dhcp-reservations-between-windows-servers%2F&amp;title=Cloning%20DHCP%20reservations%20between%20Windows%20servers"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript for Sysadmins, again</title>
		<link>http://www.108.bz/posts/it/javascript-for-sysadmins-again/</link>
		<comments>http://www.108.bz/posts/it/javascript-for-sysadmins-again/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:09:50 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SonicWALL]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=678</guid>
		<description><![CDATA[Following up on the previous post, let me show you other ways to trick web application into doing what they&#8217;ve not been designed to do: saving the Sysadmin some typing and avoding errors. I&#8217;ll use JavaScript, jQuery, Greasemonkey and Perl to automate Firefox and implement a sort of dynamic form filling. Let&#8217;s start with a [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on the <a href="http://www.108.bz/posts/it/firequery-fun/">previous post</a>, let me show you other ways to trick web application into doing what they&#8217;ve not been designed to do: saving the Sysadmin some typing and avoding errors. I&#8217;ll use JavaScript, jQuery, Greasemonkey and Perl to automate Firefox and implement a sort of dynamic form filling. Let&#8217;s start with a screencast:</p>
<p><iframe title="YouTube video player" width="600" height="474" src="http://www.youtube.com/embed/vO55CBFZwq8?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>The config I had to do (on a <a href="http://www.sonicwall.com">SonicWALL</a> firewall), involves about 70 subnets, each similar to the other. Only the subnet&#8217;s addressing scheme changes, making creation of VLANs/objects/rules a repetitive and error-prone task.</p>
<p>What&#8217;s happening in the screencast? VLAN sub-interfaces are being automatically created without me having to type anything at all. How could that be? A simple Greasemonkey script calls a &#8220;web service&#8221; (AJAX style) fetching the needed data and filling the form for me (I just click the &#8220;OK&#8221; or &#8220;Cancel&#8221; buttons). Why this whole Greasemonkey/web service mess? Because here, as in the previous post, JavaScript code is basically being injected into a &#8220;page&#8221;. Pages (or tabs, or windows) are ran by the browser into a <a href="http://en.wikipedia.org/wiki/Sandbox_(software_development)">sandbox</a>: they can&#8217;t exchange data between each other. Thus page A (the webapp) can&#8217;t access code/data in page B (our code). Moreover, injected JavaScript gets lost when the page is closed (think ugly GUIs where dialog windows pop up just to be destroyed shortly after). We need a way (Greasemonkey) to re-inject the code each time our page is shown and some external, long lived, entity to update/keep status (the web service).</p>
<p>Thanks to the <a href="http://search.cpan.org/~jesse/HTTP-Server-Simple-0.43/lib/HTTP/Server/Simple.pm">HTTP::Server::Simple</a> Perl module, building the web service is trivial. The only logic behind it is keeping track of the current VLAN&#8217;s index, iterating through each value on subsequent web service calls:</p>
<div class="codecolorer-container perl blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> LameServer<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> base <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span>HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Server</span><span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">::</span><span style="color: #006600;">CGI</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@VLANS</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span> <span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">12</span> <span style="color: #cc66cc;">13</span> <span style="color: #cc66cc;">14</span> <span style="color: #cc66cc;">15</span> <span style="color: #cc66cc;">16</span> <span style="color: #cc66cc;">17</span> <span style="color: #cc66cc;">18</span> <span style="color: #cc66cc;">19</span> <span style="color: #cc66cc;">20</span> <span style="color: #cc66cc;">21</span> <span style="color: #cc66cc;">22</span> <span style="color: #cc66cc;">23</span> <span style="color: #cc66cc;">24</span> <span style="color: #cc66cc;">25</span> <span style="color: #cc66cc;">26</span> <span style="color: #cc66cc;">27</span> <span style="color: #cc66cc;">28</span> <span style="color: #cc66cc;">29</span> <span style="color: #cc66cc;">30</span> <span style="color: #cc66cc;">31</span> <span style="color: #cc66cc;">32</span> <span style="color: #cc66cc;">33</span> <span style="color: #cc66cc;">34</span> <span style="color: #cc66cc;">35</span> <span style="color: #cc66cc;">36</span> <span style="color: #cc66cc;">37</span> <span style="color: #cc66cc;">38</span> <span style="color: #cc66cc;">39</span> <span style="color: #cc66cc;">40</span> <span style="color: #cc66cc;">41</span> <span style="color: #cc66cc;">42</span> <span style="color: #cc66cc;">43</span> <span style="color: #cc66cc;">44</span> <span style="color: #cc66cc;">45</span> <span style="color: #cc66cc;">46</span> <span style="color: #cc66cc;">61</span> <span style="color: #cc66cc;">62</span> <span style="color: #cc66cc;">63</span> <span style="color: #cc66cc;">64</span> <span style="color: #cc66cc;">65</span> <span style="color: #cc66cc;">66</span> <span style="color: #cc66cc;">67</span> <span style="color: #cc66cc;">68</span> <span style="color: #cc66cc;">69</span> <span style="color: #cc66cc;">70</span> <span style="color: #cc66cc;">71</span> <span style="color: #cc66cc;">72</span> <span style="color: #cc66cc;">73</span> <span style="color: #cc66cc;">74</span> <span style="color: #cc66cc;">75</span> <span style="color: #cc66cc;">76</span> <span style="color: #cc66cc;">77</span> <span style="color: #cc66cc;">78</span> <span style="color: #cc66cc;">79</span> <span style="color: #cc66cc;">84</span> <span style="color: #cc66cc;">85</span> <span style="color: #cc66cc;">86</span> <span style="color: #cc66cc;">87</span> <span style="color: #cc66cc;">88</span> <span style="color: #cc66cc;">89</span> <span style="color: #cc66cc;">90</span> <span style="color: #cc66cc;">91</span> <span style="color: #cc66cc;">92</span> <span style="color: #cc66cc;">93</span> <span style="color: #cc66cc;">94</span> <span style="color: #cc66cc;">95</span> <span style="color: #cc66cc;">96</span> <span style="color: #cc66cc;">97</span> <span style="color: #cc66cc;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">sub</span> handle_request <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$self</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$cgi</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;HTTP/1.0 200 OK<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Content-type:text/plain<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">&quot;$VLANS[$COUNTER] index $COUNTER<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$VLANS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$COUNTER</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$COUNTER</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">@VLANS</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> main<span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$server</span> <span style="color: #339933;">=</span> LameServer<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3333</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>And here&#8217;s the Greasemonkey script. It runs automatically when the &#8220;add VLAN&#8221; page pops up, does the sort-of-AJAX call, uses jQuery to properly fill the form.</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// ==UserScript==</span><br />
<span style="color: #006600; font-style: italic;">// @name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentVLAN</span><br />
<span style="color: #006600; font-style: italic;">// @namespace &nbsp; &nbsp; &nbsp;dontcare</span><br />
<span style="color: #006600; font-style: italic;">// @require &nbsp; &nbsp; &nbsp; &nbsp;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js</span><br />
<span style="color: #006600; font-style: italic;">// @include &nbsp; &nbsp; &nbsp; &nbsp;https://192.168.168.168/*</span><br />
<span style="color: #006600; font-style: italic;">// ==/UserScript==</span><br />
<br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/192.168.168.168.*editInterface/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; GM_xmlhttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; method<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://localhost:3333/&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">onload</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.<span style="color: #660066;">GM_CurrentVLAN</span> <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GM_log<span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> GM_wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> unsafeWindow.<span style="color: #660066;">jQuery</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>GM_wait<span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ <span style="color: #339933;">=</span> unsafeWindow.<span style="color: #660066;">jQuery</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; GM_wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select[name=interface_Zone]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'CZ'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsafeWindow.<span style="color: #660066;">setIfaceContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;Zone&quot; onchange function.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=iface_vlan_tag]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #339933;">+</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select[name=iface_vlan_parent]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'X0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=lan_iface_lan_ip]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;10.0.&quot;</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=lan_iface_ping_mgmt]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<span style="color: #009900;">&#125;</span></div></div>
<p>I built similar scripts to create static ARP entries and routes. Another one took care of firewall symbolic objects (names) but, as that part of the config is itself carried out by AJAX (in a non reloading window), I didn&#8217;t need Greasemonkey, just Firebug.<br />
No kidding, the above tricks saved me half a day of tedium&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=678" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fjavascript-for-sysadmins-again%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fjavascript-for-sysadmins-again%2F&amp;count=horizontal&amp;text=JavaScript%20for%20Sysadmins%2C%20again: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fjavascript-for-sysadmins-again%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fjavascript-for-sysadmins-again%2F&amp;title=JavaScript%20for%20Sysadmins%2C%20again"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/javascript-for-sysadmins-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FireQuery fun</title>
		<link>http://www.108.bz/posts/it/firequery-fun/</link>
		<comments>http://www.108.bz/posts/it/firequery-fun/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 22:09:44 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Aventail]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SonicWALL]]></category>
		<category><![CDATA[SSLVPN]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=666</guid>
		<description><![CDATA[Or how to toggle a thousand checkboxes clicking none. Have you ever wondered that jQuery may be relevant to your everyday sysadmin job? It is: web-based GUIs proliferate and the Command Line is sooo nineties (this one&#8217;s not mine)&#8230; Working on a SonicWALL/Aventail SSL VPN box, I was asked to simplify how permissions were mapped [...]]]></description>
			<content:encoded><![CDATA[<p>Or how to toggle a thousand checkboxes clicking none.<br />
Have you ever wondered that jQuery may be relevant to your everyday sysadmin job? It is: web-based GUIs proliferate and the Command Line is sooo nineties (this one&#8217;s not mine)&#8230;<br />
Working on a SonicWALL/Aventail SSL VPN box, I was asked to simplify how permissions were mapped to Users. What a User could or couldn&#8217;t do, was defined at the User level. Ok, let&#8217;s just:</p>
<ul>
<li>Create an A/D group for each role/profile.</li>
<li>Configure permissions (rules, resources access, &#8230;) on various <i>Communities</i> (Aventail parlance for roles/profiles).</li>
<li>Put the right Users into the right A/D group.</li>
<li>Cleanup: generally, each Community should just have A/D groups assigned to it. Get rid of unnecessary Community memberships.</li>
</ul>
<p>First three tasks were easy (thanks also to the <a href="http://www.108.bz/posts/it/cloning-an-active-directory-group/">DS*</a> commands). The fourth, uhm:<br />
<a href="http://www.108.bz/wp-content/uploads/2011/03/20110118-sonicwallaventail1.png"><img src="http://www.108.bz/wp-content/uploads/2011/03/20110118-sonicwallaventail1.png" alt="" title="sonicwallaventail" width="550" height="631" class="aligncenter size-full wp-image-669" /></a><br />
Removing members from a Community means unchecking each User. In my case, more than one thousand clicks and a beginning of carpal tunnel syndrome. At page three I started to think about a less saddening way.</p>
<p><a href="http://firequery.binaryage.com/">FireQuery</a> is a Firefox extensions that let&#8217;s you &#8220;inject&#8221; jQuery into any webpage. Here&#8217;s what I did:</p>
<ul>
<li>Went to the page depicted above (the one that let&#8217;s you assign members to a Community).</li>
<li>Launched Firebug.</li>
<li>Inspected the DOM and noticed that each of the checkboxes value begins with &#8220;AV&#8221;.</li>
<li>Used the debugger to see what&#8217;s going on when checking/unchecking members. Nothing really strange: just a bit of JavaScript to highlight a row depending on its checkbox&#8217;s status.</li>
<li>Hit the <i>jQuerify</i> button. FireQuery is needed because Aventail&#8217;s web-based GUI doesn&#8217;t use jQuery.</li>
<li>Went to <i>Console</i>, typed the JavaScript one-liner below and hit <i>Run</i></li>
</ul>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[value^=&quot;AV&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span></div></div>
<p>which translates to: use jQuery to select all of the checkboxes whose value starts with &#8220;AV&#8221;. Uncheck the selected checkboxes.</p>
<p>See? No useless clicking: a GUI has been CLI-fied.</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=666" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Ffirequery-fun%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Ffirequery-fun%2F&amp;count=horizontal&amp;text=FireQuery%20fun: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Ffirequery-fun%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Ffirequery-fun%2F&amp;title=FireQuery%20fun"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/firequery-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle Grid Control &#8211; crashing runInstaller</title>
		<link>http://www.108.bz/posts/it/oracle-grid-control-crashing-runinstaller/</link>
		<comments>http://www.108.bz/posts/it/oracle-grid-control-crashing-runinstaller/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 23:20:27 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[JRE]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=659</guid>
		<description><![CDATA[Today I ran into a weird issue while installing Oracle Grid Control Agent 10.2.0.3 on Linux. Right after typing &#8220;runInstaller&#8221;, OUI crashed because of segmentation fault&#8230; Let me talk about some of the troubleshooting maneuvers you may need to perform should you find yourself in similar troubles. Here are the relevant details: OS: Red Hat [...]]]></description>
			<content:encoded><![CDATA[<p>Today I ran into a weird issue while installing Oracle Grid Control Agent 10.2.0.3 on Linux. Right after typing &#8220;runInstaller&#8221;, OUI crashed because of segmentation fault&#8230; Let me talk about some of the troubleshooting maneuvers you may need to perform should you find yourself in similar troubles.</p>
<p>Here are the relevant details:</p>
<ul>
<li>OS: Red Hat Enterprise Linux Server 5.3 x86-64</li>
<li>GC Agent: Oracle Enterprise Manager 10g Grid Control Release 3 (10.2.0.3) for Linux x86-64</li>
<li>GC Console: Oracle Enterprise Manager 10g Release 5 (10.2.0.5) Grid Control for Microsoft Windows 32-bit</li>
</ul>
<p>And here&#8217;s the error message (the most interesting portions):</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">An unexpected exception has been detected in native code outside the VM.<br />
Unexpected Signal : 11 occurred at PC=0xE44F46A7<br />
Function=[Unknown.]<br />
Library=(N/A)<br />
<br />
[..]<br />
<br />
Current Java thread:<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.awt.motif.MToolkit.init(Native Method)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.awt.motif.MToolkit.&lt;init&gt;(Unknown Source)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)<br />
<br />
[..]<br />
<br />
Heap at VM Abort:<br />
Heap<br />
&nbsp;def new generation &nbsp; total 576K, used 84K [0xe6510000, 0xe65b0000, 0xe7090000)<br />
&nbsp; eden space 512K, &nbsp; 4% used [0xe6510000, 0xe65152f8, 0xe6590000)<br />
&nbsp; from space 64K, 100% used [0xe65a0000, 0xe65b0000, 0xe65b0000)<br />
&nbsp; to &nbsp; space 64K, &nbsp; 0% used [0xe6590000, 0xe6590000, 0xe65a0000)<br />
&nbsp;tenured generation &nbsp; total 6212K, used 4461K [0xe7090000, 0xe76a1000, 0xefb10000)<br />
&nbsp; &nbsp;the space 6212K, &nbsp;71% used [0xe7090000, 0xe74eb5f8, 0xe74eb600, 0xe76a1000)<br />
&nbsp;compacting perm gen &nbsp;total 5632K, used 5398K [0xefb10000, 0xf0090000, 0xf3b10000)<br />
&nbsp; &nbsp;the space 5632K, &nbsp;95% used [0xefb10000, 0xf00558b0, 0xf0055a00, 0xf0090000)<br />
<br />
Local Time = Tue Feb &nbsp;8 09:45:48 2011<br />
Elapsed Time = 1<br />
#<br />
# The exception above was detected in native code outside the VM<br />
#<br />
# Java VM: Java HotSpot(TM) Client VM (1.4.2_08-b03 mixed mode)<br />
#</div></div>
<p>To go past this show-stopper I tried a few things&#8230;</p>
<p>The Heap report produced by java at crash time, seemed to indicate a memory shortage. By editing the &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">install/oraparam.ini</span>&#8221; file, you can tweak how much RAM is available for OUI&#8217;s JVM. Just alter &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">JRE_MEMORY_OPTIONS</span>&#8221; value.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#JRE_MEMORY_OPTIONS=&quot; -mx150m&quot;<br />
JRE_MEMORY_OPTIONS=&quot; -Xms512m -Xmx2048m&quot;</div></div>
<p>This is also a safe place to put additional command line parameters: they&#8217;ll mostly be passed to java&#8217;s command line. I said &#8220;mostly&#8221; because OUI wrapper/launcher seems to check some sort of allowed parameters list and may refuse to go on if somethings doesn&#8217;t look right.</p>
<p>The &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-XX:MaxPermSize=32m</span>&#8221; is one of the knobs that doesn&#8217;t pass the sanity check. In order to run OUI&#8217;s JVM by hand, with the right parameters, just keep the first lines of runInstaller (the ones starting with &#8216;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Arg:</span>&#8216;):</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Arg:0:/tmp/OraInstall2011-02-08_04-55-33PM/jre/1.4.2/bin/java:<br />
Arg:1:-Doracle.installer.library_loc=/tmp/OraInstall2011-02-08_04-55-33PM/oui/lib/linux:<br />
Arg:2:-Doracle.installer.oui_loc=/tmp/OraInstall2011-02-08_04-55-33PM/oui:<br />
Arg:3:-Doracle.installer.bootstrap=TRUE:<br />
[..]<br />
Arg:20:-timestamp:<br />
Arg:21:2011-02-08_04-55-33PM:<br />
Arg:22:-nowelcome:</div></div>
<p>Strip &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">^Arg:</span>&#8220;, &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">^\d*:</span>&#8220;, &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">:$</span>&#8220;, add a trailing &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;"> \</span>&#8221; and you&#8217;ll have an OUI launching shell script you can alter at will.</p>
<p>Increasing JVM&#8217;s memory led to no effect. Heap report looked fine (usage percentages went down) but crash was still there.</p>
<p>Another useful switch is &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-XX:+ShowMessageBoxOnError</span>&#8220;. It makes java halt on error, allowing us to attach a debugger and perform a stack backtrace, e.g.:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Unexpected Signal: 11, PC: 0x6d4626a7, PID: 4866<br />
An error has just occurred.<br />
To debug, use 'gdb /tmp/OraInstall2011-02-08_11-01-42AM/jre/1.4.2/bin/java 4866'; then switch to thread -136623920</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#0 &nbsp;0xffffe410 in __kernel_vsyscall ()<br />
#1 &nbsp;0xf7e462b6 in nanosleep () from /lib/libc.so.6<br />
#2 &nbsp;0xf7e460df in sleep () from /lib/libc.so.6<br />
#3 &nbsp;0xf7bdc6d7 in os::message_box ()<br />
&nbsp; &nbsp;from /tmp/OraInstall2011-02-08_11-01-42AM/jre/1.4.2/lib/i386/client/libjvm.so<br />
#4 &nbsp;0xf7bd9c52 in os::handle_unexpected_exception ()<br />
&nbsp; &nbsp;from /tmp/OraInstall2011-02-08_11-01-42AM/jre/1.4.2/lib/i386/client/libjvm.so<br />
#5 &nbsp;0xf7bddbf6 in JVM_handle_linux_signal ()<br />
&nbsp; &nbsp;from /tmp/OraInstall2011-02-08_11-01-42AM/jre/1.4.2/lib/i386/client/libjvm.so<br />
#6 &nbsp;0xf7bdc9d8 in signalHandler ()<br />
&nbsp; &nbsp;from /tmp/OraInstall2011-02-08_11-01-42AM/jre/1.4.2/lib/i386/client/libjvm.so<br />
#7 &nbsp;&lt;signal handler called&gt;<br />
#8 &nbsp;0x6d4626a7 in ?? ()<br />
#9 &nbsp;0x6d6d75b9 in XtToolkitInitialize () from /usr/lib/libXt.so.6</div></div>
<p>I also tried to &#8220;inject&#8221; a couple of newer JVM&#8217;s into the stage directory. The quickest way is to borrow it from another installer.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[oracle@racnode01 orastage]$ find . -type d -name oracle.swd.jre -exec echo {} \; -exec ls {} \;<br />
./Linux_x86_64_Grid_Control_full_102030/Disk1/stage/Components/oracle.swd.jre<br />
1.4.2.8.0<br />
./p6810189_10204_Linux-x86-64/Disk1/stage/Components/oracle.swd.jre<br />
1.4.2.14.0</div></div>
<p>The server&#8217;s has a &#8220;working&#8221; directory were Oracle patches/products are stored before use. In my case, changing OUI&#8217;s JVM from 1.4.2.8 to 1.4.2.14 is a matter of copying:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">./p6810189_10204_Linux-x86-64/Disk1/stage/Components/oracle.swd.jre/1.4.2.14.0</div></div>
<p>to:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">./Linux_x86_64_Grid_Control_full_102030/Disk1/stage/Components/oracle.swd.jre</div></div>
<p>Then modifing the same &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">oraparam.ini</span>&#8221; file mentioned before.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#JRE_LOCATION=../stage/Components/oracle.swd.jre/1.4.2.8.0/1/DataFiles<br />
JRE_LOCATION=../stage/Components/oracle.swd.jre/1.4.2.14.0/1/DataFiles</div></div>
<p>You could as well download a specific JRE from http://java.sun.com (sorry: from Oracle) and:</p>
<ul>
<li>install the new JRE somewhere</li>
<li>unzip (-t) the &#8220;filegroup1.jar&#8221; file that corresponds to OUI&#8217;s &#8220;factory&#8221; JRE. Note how the directories are laid out (something like: &#8220;jre/1.4.2&#8243;). Modify the new JRE accordingly.</li>
<li>zip the new JRE, rename the resulting file to &#8220;filegroup1.jar&#8221;, copy it in the right place.</li>
<li>modify oraparam.ini and choose the JVM version you&#8217;ll boot OUI into.</li>
</ul>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[oracle@racnode01 oracle.swd.jre]$ pwd<br />
/opt/orastage/Linux_x86_64_Grid_Control_full_102030/Disk1/stage/Components/oracle.swd.jre<br />
[oracle@racnode01 oracle.swd.jre]$ find . -type f<br />
./1.4.2.8.0/1/DataFiles/filegroup1.jar &nbsp; # &lt;-- factory<br />
./1.4.2.8.0/1/DataFiles/filegroup2.jar<br />
./1.4.2.8.0/1/DataFiles/filegroup3.jar<br />
./1.4.2.8.0/1/DataFiles/filegroup4.jar<br />
./1.4.2.8.0/1/DataFiles/filegroup5.jar<br />
./1.4.2.14.0/1/DataFiles/filegroup1.jar &nbsp;# &lt;-- stolen from patchset p6810189<br />
./1.4.2.14.0/1/DataFiles/filegroup2.jar<br />
./1.4.2.14.0/1/DataFiles/filegroup3.jar<br />
./1.4.2.14.0/1/DataFiles/filegroup4.jar<br />
./1.4.2.14.0/1/DataFiles/filegroup5.jar<br />
./1.4.2.19.0/1/DataFiles/filegroup1.jar &nbsp;# &lt;-- downloaded by hand</div></div>
<p>Three different JREs, each of them segfaulting in the same spot, as we saw in the backtrace:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#9 &nbsp;0x6d6d75b9 in XtToolkitInitialize () from /usr/lib/libXt.so.6</div></div>
<p>Who&#8217;s the owner of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">libXt</span>?</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@racnode01 ~]# rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' -f /usr/lib/libXt.so.6<br />
libXt-1.0.2-3.1.fc6 i386</div></div>
<p>After making sure that none of the running processes was using that package contents, I decided to remove it (<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">rpm -e &#8211;nodeps libXt-1.0.2-3.1.i386</span>) and reinstall it. Surprisingly, OUI worked flawlessy after this last action. Too bad I can&#8217;t really explain why. <img src='http://www.108.bz/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  libXt version didn&#8217;t change before/after reinstall. I should diff it anyway with what&#8217;s left untouched on other RAC cluster members. I&#8217;ll update the post when I have a stricter explanation&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=659" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Foracle-grid-control-crashing-runinstaller%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Foracle-grid-control-crashing-runinstaller%2F&amp;count=horizontal&amp;text=Oracle%20Grid%20Control%20%26%238211%3B%20crashing%20runInstaller: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Foracle-grid-control-crashing-runinstaller%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Foracle-grid-control-crashing-runinstaller%2F&amp;title=Oracle%20Grid%20Control%20%26%238211%3B%20crashing%20runInstaller"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/oracle-grid-control-crashing-runinstaller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting data from a CCTV DVR hard disk</title>
		<link>http://www.108.bz/posts/it/extracting-data-from-a-cctv-dvr-hard-disk/</link>
		<comments>http://www.108.bz/posts/it/extracting-data-from-a-cctv-dvr-hard-disk/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 22:23:44 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Data Recovery]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=643</guid>
		<description><![CDATA[Today I was handed a hard disk, removed from from a CCTV DVR about which we knew nothing (no model/make). The request was to extract as much footage as possible from it. I hooked the disk to my laptop via a SATA/USB adaptor but, unsurprisingly, wasn&#8217;t able to find/mount a filesystem. I dumped the first [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was handed a hard disk, removed from from a CCTV DVR about which we knew nothing (no model/make). The request was to extract as much footage as possible from it. I hooked the disk to my laptop via a SATA/USB adaptor but, unsurprisingly, wasn&#8217;t able to find/mount a filesystem. I dumped the first 30 megabytes off the device (<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dd if=/dev/sdb of=x.bin bs=1M count=30</span>) and opend the resulting file with a hex editor:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># od -t x1 -a x.bin | sed 's/nul/ &nbsp; /g' | head<br />
0000000 &nbsp;44 &nbsp;48 &nbsp;46 &nbsp;53 &nbsp;34 &nbsp;2e &nbsp;31 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; D &nbsp; H &nbsp; F &nbsp; S &nbsp; 4 &nbsp; . &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
0000020 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
*<br />
0036040 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;03 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;01 &nbsp;00 &nbsp;00 &nbsp;00<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; etx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
0036060 &nbsp;03 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00<br />
&nbsp; &nbsp; &nbsp; &nbsp; etx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
0036100 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;22 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00 &nbsp;00</div></div>
<p>The first bytes read &#8220;DHFS4.1&#8243;. Various Google searches return just one english hit: a machine translated page from chinese mentioning a company named &#8220;<a href="http://www.dahuasecurity.com">Dahua</a>&#8221; that manufactures some video surveillance equipment. On their support page an <a href="http://www.dahuasecurity.com/upload/HDD%20Download%20Tool.rar">HDD Download Tool</a> can be found (filename: <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">HDD Download Tool.rar</span>). It can look up video clips stored on a disk by date, time and channel (input number), and extract them as &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.dav</span>&#8221; files (e.g: <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">01.23.03-01.33.21[M][@2a2ed][0].dav</span>). You can convert <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.dav</span> files to <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.avi</span> using &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dhavi.exe</span>&#8221; (from <a href="http://www.bahamassecurity.com/software/cctv/dahuaaviconvert.asp">bahamassecurity.com</a>). I was able to run the latter with <a href="http://www.winehq.org">Wine</a>, which probably means that <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.dav</span> content can be packed into an <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.avi</span> container without transcoding (even though the website says something about H.264 codecs). The former tool, instead, requires Windows because of the raw disk I/O going on.</p>
<p>Hopefully, this post gathered some difficult to find info, coming either from Chinese pages or sites not indexed by Google&#8230;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Size &nbsp; &nbsp;| md5sum &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Filename<br />
--------+----------------------------------+------------------------<br />
240168 &nbsp;| cbe0912a78074226060d4101f4f67902 | *HDD Download Tool.rar<br />
87552 &nbsp; | 18b79f0827dfa27cf4e068f02d78f02b | *HDD Download Tool User's Manua 2009-6.doc<br />
216081 &nbsp;| 993c1bd56e03427351bb8cdfea142803 | *General_DiskCopy_Eng_TS_V1.00.0.R.090611.rar<br />
299008 &nbsp;| 624721057cd0857ef5ecbde9643debfd | *General_DiskCopy_Eng_TS_V1.00.0.R.090611.exe<br />
208896 &nbsp;| e5e3fa834ccf7e6b1ad222b1aa38b91c | *DiskIOCtl.dll<br />
1037312 | 4a5b234d673e5d10fbddddae3bb777a1 | *dhavi.exe</div></div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=643" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fextracting-data-from-a-cctv-dvr-hard-disk%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fextracting-data-from-a-cctv-dvr-hard-disk%2F&amp;count=horizontal&amp;text=Extracting%20data%20from%20a%20CCTV%20DVR%20hard%20disk: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fextracting-data-from-a-cctv-dvr-hard-disk%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fextracting-data-from-a-cctv-dvr-hard-disk%2F&amp;title=Extracting%20data%20from%20a%20CCTV%20DVR%20hard%20disk"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/extracting-data-from-a-cctv-dvr-hard-disk/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cloning an Active Directory group</title>
		<link>http://www.108.bz/posts/it/cloning-an-active-directory-group/</link>
		<comments>http://www.108.bz/posts/it/cloning-an-active-directory-group/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 12:06:10 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=617</guid>
		<description><![CDATA[Or how to use the dsquery/dsget/dsmod commands to copy all the members from an Active Directory group (source), to another one (destination). If, like me, you are on a neverending quest to click less and script more, you can solve the problem this way: Create the destination group, should it not exist. Find the source [...]]]></description>
			<content:encoded><![CDATA[<p>Or how to use the <a href="http://technet.microsoft.com/en-us/library/cc732952(WS.10).aspx">dsquery</a>/<a href="http://technet.microsoft.com/en-us/library/cc755162(WS.10).aspx">dsget</a>/<a href="http://technet.microsoft.com/en-us/library/cc732406(WS.10).aspx">dsmod</a> commands to copy all the members from an<br />
Active Directory group (<i>source</i>), to another one (<i>destination</i>).</p>
<p>If, like me, you are on a neverending quest to click less and script more, you can solve the problem this way:</p>
<ul>
<li>Create the destination group, should it not exist.</li>
<li>Find the source group&#8217;s <a href="http://en.wikipedia.org/wiki/Distinguished_Name">DN</a>:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery group -samid sourcegroup<br />
&quot;CN=sourcegroup,OU=Groups,DC=contoso,DC=com&quot;</div></div>
<p>&#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-samid</span>&#8221; argument is the group name whose DN you&#8217;re looking for. You can use &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">*</span>&#8221; as a wildcard.</li>
<li>Ditto for the destination group:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery group -samid destinationgroup<br />
&quot;CN=destinationgroup,OU=Groups,DC=contoso,DC=com&quot;&lt;/li&gt;</div></div>
<li>On with the copy itself:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsget group &quot;CN=sourcegroup,OU=Groups,DC=contoso,DC=com&quot; -members -expand | dsmod group &quot;CN=destinationgroup,OU=Groups,DC=contoso,DC=com&quot; -addmbr -c<br />
dsmod succeeded:CN=destinationgroup,OU=Groups,DC=contoso,DC=com</div></div>
<p>These are two commands: &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsget group</span>&#8221; and &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsmod group</span>&#8220;. Output from the first is piped to the second. &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-members</span>&#8221; causes the group members&#8217; DNs to be listed on standard output (one by line, quoted). &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-expand</span>&#8221; makes <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsget</span> to recursively expand the sub-groups that <i>sourcegroup</i> may hold.<br />
Conversely, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsmod</span> modifies <i>destinationgroup</i> adding members to it.<br />
Very cool, so far. The only caveat is that the &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-c</span>&#8221; switch doesn&#8217;t work as advertised. It should copy members over <i>destinationgroup</i> even if already exist, but it doesn&#8217;t. If you need to re-sync source and dest, delete source&#8217;s contents from dest.</li>
</ul>
<p>Bonus note; here&#8217;s a quick way to discover a user&#8217;s DN given his username:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery user -samid jdoe<br />
&quot;CN=John Doe,CN=Users,DC=contoso,DC=com&quot;</div></div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=617" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-an-active-directory-group%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-an-active-directory-group%2F&amp;count=horizontal&amp;text=Cloning%20an%20Active%20Directory%20group: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-an-active-directory-group%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fcloning-an-active-directory-group%2F&amp;title=Cloning%20an%20Active%20Directory%20group"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/cloning-an-active-directory-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symantec Endpoint Protection &#8211; crypt32 errors</title>
		<link>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/</link>
		<comments>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 16:28:58 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[Symantec]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=591</guid>
		<description><![CDATA[One of the most procrastinated issues I had at a Customer&#8217;s, was the proliferation of errors like these (as shown in servers/clients Event Viewer): Event Type: Error Event Source: &#160; crypt32 Event Category: None Event ID: &#160; 8 Description: Failed auto update retrieval of third-party root list sequence number from: &#60;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&#62; with error: This network [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most procrastinated issues I had at a Customer&#8217;s, was the proliferation of errors like these (as shown in servers/clients Event Viewer):</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Error<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 8<br />
Description:<br />
Failed auto update retrieval of third-party root list sequence number from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&gt; with error: This network connection does not exist.</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Error<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 11<br />
Description:<br />
Failed extract of third-party root list from auto update cab at: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab&gt; with error: A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file.</div></div>
<p>There are several posts mentioning the issue, <a href="http://www.symantec.com/connect/forums/crypt32-errors-event-viewer-after-sep-110-installation">this one</a> pointed me in the right direction. Basically, because of how SEP components communicate, Windows is triggered into updating the list of trusted root Certification Authorities. It tries to do so through the Internet using the Computer account. The latter may not have any proxy configured. Being unable to reach outside, the host gets flooded by <i>crypt32</i> errors.</p>
<p>In order to solve the issue, I decided to deploy a valid proxy configuration, for the Computer account (<i>SYSTEM</i> user), on a subset of the Domain&#8217;s hosts.<br />
One of the ways to script that is the &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">proxycfg -u</span>&#8221; command<sup class='footnote'><a href='#fn-591-1' id='fnref-591-1'>1</a></sup> that works by copying the current user proxy settings to the SYSTEM&#8217;s registry. Sounds cool but if the current user is not a member of the local Administrators group, he won&#8217;t have the necessary rights. The following script instead, can be launched via Group Policy<sup class='footnote'><a href='#fn-591-2' id='fnref-591-2'>2</a></sup> during operating system startup, and since it&#8217;s a <i>startup</i> script rather than a <i>login</i> one, it will run with administrative privileges.</p>
<p>Nothing fancy in the below source. It creates the registry key if it doesn&#8217;t exist, then sets the right value for <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">WinHttpSettings</span> which I obtained this way:</p>
<ul>
<li>use &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">proxycfg -u</span>&#8221; on a test host</li>
<li>use the Registry editor to export the contents of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections</span></li>
</ul>
<p>The value is of type <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">REG_BINARY</span>. Since the <a href="http://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.85).aspx">RegWrite</a> API (method of class <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">WScript.Shell</span>) cannot deal with binary values, WMI (<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">StdRegProv</span> registry provider) needs to be used. Also, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">SetBinaryValue</span> expects an array of decimal values, while Regedit exports them as hexadecimal digits (you&#8217;ll have to take care of the conversion yourself).</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span><br />
<span style="color: #000080;">Const</span> HKEY_LOCAL_MACHINE = &amp;H80000002<br />
<br />
strPath = <span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections&quot;</span><br />
strKey = <span style="color: #800000;">&quot;WinHttpSettings&quot;</span><br />
strValue = <span style="color: #800000;">&quot;24,0,0,0,0,0,0,0,3,0,0,0,19,0,0,0,112,114,111,120,121,46,99,117,115,116,46,108,97,110,58,56,48,56,48,47,0,0,0,49,48,46,42,46,42,46,42,59,115,101,114,118,101,114,50,48,59,115,101,114,118,101,114,50,48,46,42,59,42,46,99,117,115,116,46,108,97,110,59,60,108,111,99,97,108,62&quot;</span><br />
strMachineName = <span style="color: #800000;">&quot;.&quot;</span><br />
<br />
arrValues = Split(strValue,<span style="color: #800000;">&quot;,&quot;</span>)<br />
strMoniker = <span style="color: #800000;">&quot;winMgmts:\\&quot;</span> &amp; strMachineName &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span><br />
<span style="color: #000080;">Set</span> oReg = GetObject(strMoniker)<br />
rv = oReg.CreateKey(HKEY_LOCAL_MACHINE, strPath)<br />
rv = oReg.SetBinaryValue(HKEY_LOCAL_MACHINE, strPath, strKey, arrValues)</div></div>
<p>If the scripts works as it should, you&#8217;ll be greeted by these events:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Information<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 7<br />
Description:<br />
Successful auto update retrieval of third-party root list sequence number from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&gt;</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Information<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 2<br />
Description:<br />
Successful auto update retrieval of third-party root list cab from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab&gt;</div></div>
<p>And, hopefully, crypt32 errors will be gone for good.</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-591-1'>See <a href="http://msdn.microsoft.com/en-us/library/ms761351(v=vs.85).aspx">Using the WinHTTP Proxy Configuration Utility</a> <span class='footnotereverse'><a href='#fnref-591-1'>&#8617;</a></span></li>
<li id='fn-591-2'>Computer Configuration, Windows Settings, Scripts, Startup <span class='footnotereverse'><a href='#fnref-591-2'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=591" width="1" height="1" style="display: none;" /><p><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fsymantec-endpoint-protection-crypt32-errors%2F&amp;counturl=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fsymantec-endpoint-protection-crypt32-errors%2F&amp;count=horizontal&amp;text=Symantec%20Endpoint%20Protection%20%26%238211%3B%20crypt32%20errors: " frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fsymantec-endpoint-protection-crypt32-errors%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20" frameborder="0" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.108.bz%2Fposts%2Fit%2Fsymantec-endpoint-protection-crypt32-errors%2F&amp;title=Symantec%20Endpoint%20Protection%20%26%238211%3B%20crypt32%20errors"><img src="http://www.108.bz/share_save_171_16_orange.png" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

