<?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>systemBash &#187; Linux</title>
	<atom:link href="http://systembash.com/tags/system-administration/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://systembash.com</link>
	<description>Technology and System Administration</description>
	<lastBuildDate>Fri, 13 Jan 2012 03:18:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What a Resilver Looks Like in ZFS (and a Bug and/or Feature)</title>
		<link>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/</link>
		<comments>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/#comments</comments>
		<pubDate>Sun, 15 May 2011 12:16:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=974</guid>
		<description><![CDATA[At home I have an (admittedly small) ZFS array set up to experiment with this neat newish raid technology. I think it has been around long enough that it can be used in production, but I'm still getting used to the little bugs/features, and here is one that I just found.

After figuring out that I had 2 out of 3 of my 1TB Seagate Barracuda hard drives fail, I had to give the array up for a loss and test out my backup strategy. Fortunately it worked and there was no data loss. After receiving the replacement drives in from RMA, I rebuilt the ZFS array (using raidz again) and went along my merry way. After 6 months or so, I started getting some funky results from my other drive. Thinking it might have some issue as with the others, I removed the drive and ran Seatools on it (by the way, Seatools doesn't offer a 64-bit Windows version - what year is this?).

The drive didn't show any signs of failure, so I decided to wipe it and add it back into the array to see what happens. That, of course, is easier said than done.]]></description>
			<content:encoded><![CDATA[<p>At home I have an (admittedly small) <a href="http://en.wikipedia.org/wiki/ZFS">ZFS</a> array set up to experiment with this awesome newish <a href="http://en.wikipedia.org/wiki/RAID">RAID</a> technology. I think it has been around long enough that it can now be used in production, but I&#8217;m still getting used to the little bugs/features, and here is one that I just found.</p>
<p>After figuring out that I had 2 out of 3 of my 1TB Seagate Barracuda hard drives in the array fail, I had to give the entire array up for a loss and test out my backup strategy. Fortunately it worked and there was no data loss. After receiving the replacement drives in from Seagate, I rebuilt the ZFS array (using <a href="http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#Should_I_Configure_a_RAIDZ.2C_RAIDZ-2.2C_RAIDZ-3.2C_or_a_Mirrored_Storage_Pool.3F">raidz</a> again) and went along my merry way. After another 6 months or so, I started getting some funky results from my other drive. Thinking it might have some issue as with the others, I removed the drive and ran <a href="http://www.seagate.com/www/en-us/support/downloads/seatools">Seatools</a> on it (by the way, Seatools doesn&#8217;t offer a 64-bit Windows version &#8211; what year is this?).</p>
<p>The drive didn&#8217;t show any signs of failure, so I decided to wipe it and add it back into the array to see what happens. That, of course, is easier said than done.</p>
<p>One of the problems I ran into is that I am using <a href="http://www.ubuntu.com/">Ubuntu</a> and <a href="http://fuse.sourceforge.net/">fuse</a> to run zfs. Ubuntu has this nasty habit of changing around drive identifiers when USB devices are plugged in. So now when this drive is plugged in, it is on /dev/sde instead of /dev/sdd, which is now a USB attached drive. </p>
<p>No problem, I figure, I&#8217;ll offline the bad drive in the zpool and replace it with the new drive location. No such luck.</p>
<p>First I offlined the drive using <code class="codecolorer text mac-classic"><span class="text">zpool offline media /dev/sdd</span></code>:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: DEGRADED<br />
status: One or more devices has been taken offline by the administrator.<br />
&nbsp; &nbsp; &nbsp; &nbsp; Sufficient replicas exist for the pool to continue functioning in a<br />
&nbsp; &nbsp; &nbsp; &nbsp; degraded state.<br />
action: Online the device using 'zpool online' or replace the device with<br />
&nbsp; &nbsp; &nbsp; &nbsp; 'zpool replace'.<br />
&nbsp;scrub: none requested<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; DEGRADED &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;DEGRADED &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; OFFLINE &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0</div></td></tr></tbody></table></div>
<p>Now that it&#8217;s offline, I thought you should be able to detach it. No such luck &#8211; since it is a &#8216;primary&#8217; device of the zpool it does not allow you to remove it.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool detach media /dev/sdd<br />
cannot detach /dev/sdd: only applicable to mirror and replacing vdevs</div></td></tr></tbody></table></div>
<p>What they <em>want</em> you to do is replace the drive with another drive. This drive (the same drive, with all info wiped from it) is now on /dev/sde. I try to replace it:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool replace media /dev/sdd /dev/sde<br />
invalid vdev specification<br />
use '-f' to override the following errors:<br />
/dev/sde is part of active pool 'media'<br />
dave@cerberus:~$ sudo zpool replace -f media /dev/sdd /dev/sde<br />
invalid vdev specification<br />
the following errors must be manually repaired:<br />
/dev/sde is part of active pool 'media'</div></td></tr></tbody></table></div>
<p>Even with -f it doesn&#8217;t allow the replacement, because the system thinks that the drive is part of another pool.</p>
<p>So basically you are stuck if trying to test a replacement with a drive that already been used in the pool. I&#8217;m sure I could replace it with another 1TB disk but what is the point of that? </p>
<p>I ended up resolving the problem by removing the external USB drive, therefore putting the drive back into the original /dev/sdd slot. Without issuing any commands, the system now sees the drive as the old one, and starts resilvering the drive.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
status: One or more devices has experienced an unrecoverable error. &nbsp;An<br />
&nbsp; &nbsp; &nbsp; &nbsp; attempt was made to correct the error. &nbsp;Applications are unaffected.<br />
action: Determine if the device needs to be replaced, and clear the errors<br />
&nbsp; &nbsp; &nbsp; &nbsp; using 'zpool clear' or replace the device with 'zpool replace'.<br />
&nbsp; &nbsp;see: http://www.sun.com/msg/ZFS-8000-9P<br />
&nbsp;scrub: resilver in progress for 0h9m, 4.62% done, 3h18m to go<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp;13 &nbsp;30.2G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0</div></td></tr></tbody></table></div>
<p>It is interesting to see what it looks like from an i/o perspective. The system reads from the two good drives and writes to the new (bad) one. Using <code class="codecolorer text mac-classic"><span class="text">iostat -x</span></code>:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">avg-cpu: &nbsp;%user &nbsp; %nice %system %iowait &nbsp;%steal &nbsp; %idle<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 29.77 &nbsp; &nbsp;0.00 &nbsp; 13.81 &nbsp; 32.81 &nbsp; &nbsp;0.00 &nbsp; 23.60<br />
<br />
Device: &nbsp; &nbsp; &nbsp; &nbsp; rrqm/s &nbsp; wrqm/s &nbsp; &nbsp; r/s &nbsp; &nbsp; w/s &nbsp; rsec/s &nbsp; wsec/s avgrq-sz avgqu-sz &nbsp; await &nbsp;svctm &nbsp;%util<br />
sda &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp; &nbsp;0.80 &nbsp; &nbsp;0.00 &nbsp; &nbsp;33.60 &nbsp; &nbsp; 0.00 &nbsp; &nbsp;42.00 &nbsp; &nbsp; 0.01 &nbsp; 15.00 &nbsp;15.00 &nbsp; 1.20<br />
sdb &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp;625.00 &nbsp; &nbsp;0.00 108033.20 &nbsp; &nbsp; 0.00 &nbsp; 172.85 &nbsp; &nbsp; 0.56 &nbsp; &nbsp;0.90 &nbsp; 0.49 &nbsp;30.80<br />
sdc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp;624.20 &nbsp; &nbsp;0.00 107828.40 &nbsp; &nbsp; 0.00 &nbsp; 172.75 &nbsp; &nbsp; 0.50 &nbsp; &nbsp;0.81 &nbsp; 0.47 &nbsp;29.60<br />
sdd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 1.20 &nbsp; &nbsp;0.00 &nbsp;504.40 &nbsp; &nbsp; 0.00 107729.60 &nbsp; 213.58 &nbsp; &nbsp; 9.52 &nbsp; 18.85 &nbsp; 1.98 100.00</div></td></tr></tbody></table></div>
<p>It seems that ZFS is able to identify a hard drive by GID somehow but doesn&#8217;t automatically use it in the pool. This makes it so that you can&#8217;t test a drive by removing it, formatting it, and putting it into a new location. <strong>Basically, zfs assumes that your drives are always going to be in the same /dev location, which isn&#8217;t always true</strong>. As soon as you attach a USB drive in Ubuntu things are going to shift around.</p>
<p>After the resilver is complete, the zpool status is:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
status: One or more devices has experienced an unrecoverable error. &nbsp;An<br />
&nbsp; &nbsp; &nbsp; &nbsp; attempt was made to correct the error. &nbsp;Applications are unaffected.<br />
action: Determine if the device needs to be replaced, and clear the errors<br />
&nbsp; &nbsp; &nbsp; &nbsp; using 'zpool clear' or replace the device with 'zpool replace'.<br />
&nbsp; &nbsp;see: http://www.sun.com/msg/ZFS-8000-9P<br />
&nbsp;scrub: resilver completed after 0h16m with 0 errors on Sun May 15 07:35:46 2011<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp;13 &nbsp;50.0G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
<br />
errors: No known data errors</div></td></tr></tbody></table></div>
<p>You can now clear the error with:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool clear media<br />
root@cerberus:/home/dave#</div></td></tr></tbody></table></div>
<p>Zpool status now shows no errors:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
&nbsp;scrub: resilver completed after 0h16m with 0 errors on Sun May 15 07:35:46 2011<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp;50.0G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
<br />
errors: No known data errors</div></td></tr></tbody></table></div>
<p>So now the question I have is this: <em>Are you able to manually update or remove the drive status somewhere in your system?</em> How did zfs know that this drive already had a pool installed on it? I zeroed the drive and verified with fdisk there were no partition on it. Is there a file somewhere on the system that stores this information, or is it written somewhere on the drive?</p>
<p>ZFS is great, but it still has some little issues like this that give me pause before using it in a production system. Then again, I suppose all massive disk array systems have their little quirks!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Disabling The hald-addon-storage Service On CentOS/RedHat</title>
		<link>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/</link>
		<comments>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 16:13:53 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[hald]]></category>
		<category><![CDATA[hardware access layer]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=961</guid>
		<description><![CDATA[The hald &#8211; Hardware Access Layer Daemon &#8211; runs several processes in order to keep track of what hardware is installed on your system. This includes polling USB Drives and &#8216;hot-swap&#8217; devices to check for changes along with a host of other tasks. You might see it running on your system as follows: 12342474 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160;\_ hald-runner 2481 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160; &#160; &#160;\_ hald-addon-acpi: listening on acpid socket /var/run/acpid.socket 2487 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160; &#160; &#160;\_ hald-addon-keyboard: listening on /dev/input/event0 2495 ? &#160; &#160; &#160; &#160;S &#160; &#160; 41:47 &#160; &#160; &#160;\_ hald-addon-storage: polling /dev/hdc If your system is static and the devices do not change, you can actually disable this service using a policy entry. Create a file in your policy directory, for example /etc/hal/fdi/policy/99-custom.fdi. Add the text: 123456789&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;....]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://linux.die.net/man/8/hald">hald</a> &#8211; <em>Hardware Access Layer Daemon</em> &#8211; runs several processes in order to keep track of what hardware is installed on your system. This includes polling USB Drives and &#8216;hot-swap&#8217; devices to check for changes along with a host of other tasks. </p>
<p>You might see it running on your system as follows:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">2474 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp;\_ hald-runner<br />
2481 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp; &nbsp; &nbsp;\_ hald-addon-acpi: listening on acpid socket /var/run/acpid.socket<br />
2487 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp; &nbsp; &nbsp;\_ hald-addon-keyboard: listening on /dev/input/event0<br />
2495 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; 41:47 &nbsp; &nbsp; &nbsp;\_ hald-addon-storage: polling /dev/hdc</div></td></tr></tbody></table></div>
<p>If your system is static and the devices do not change, you can actually disable this service using a policy entry. </p>
<p>Create a file in your policy directory, for example /etc/hal/fdi/policy/99-custom.fdi. Add the text:</p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deviceinfo</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;storage.removable&quot;</span> <span style="color: #000066;">bool</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;info.addons&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;strlist&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hald-addon-storage<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/remove<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/match<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deviceinfo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Save and reload the hald using <code class="codecolorer text mac-classic"><span class="text">/etc/init.d/haldaemon restart</span></code>.</p>
<p>And you will find that service no longer is polling your hardware.</p>
<p>Of course to turn it back on, remove that policy entry and restart the haldaemon again, it will be back in service.</p>
<p><em>Solution Credit: <a href="http://www.linuxforums.org/forum/newbie/160675-solved-completely-disabling-hald-addon-storage-not-just-stop-polling.html">Linuxforums User cn77</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Random Quotes to the Bash Login Screen</title>
		<link>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/</link>
		<comments>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 13:49:13 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=873</guid>
		<description><![CDATA[According to &#8220;official&#8221; system administrator rules and guidelines you shouldn&#8217;t be adding so-called vain scripts to the login prompt &#8211; only utilities that will add something useful to the system (for example, current system load, memory and disk usage, etc). However I have some systems that I frequently connect to and thought it would be neat to add a random quote script to my bash login. That being said, this should only be done on &#8216;non-production&#8217; systems and adds a security vector so please be careful where you use this. The goal of this is to add a little quote, at random, every time you log into your system. My thoughts were to do it not only as a little source of inspiration but also to add perspective to what I&#8217;m doing sitting in front of the computer all of the time. Originally I was going to try to write....]]></description>
			<content:encoded><![CDATA[<p>According to &#8220;official&#8221; system administrator rules and guidelines you shouldn&#8217;t be adding so-called vain scripts to the login prompt &#8211; only utilities that will add something useful to the system (for example, current system load, memory and disk usage, etc). However I have some systems that I frequently connect to and thought it would be neat to add a random quote script to my bash login. That being said, this should only be done on &#8216;non-production&#8217; systems and adds a security vector so please be careful where you use this. </p>
<p>The goal of this is to add a little quote, at random, every time you log into your system. My thoughts were to do it not only as a little source of inspiration but also to add perspective to what I&#8217;m doing sitting in front of the computer all of the time. </p>
<p>Originally I was going to try to write the script solely in bash since it is so flexible (and just as a proof of concept) but dealing with RSS in bash isn&#8217;t exactly pretty and I just wanted to get this together as quick as possible. PHP makes parsing XML easy, there are a number of ways to accomplish it. I chose to use the ready-made script at <a href="http://rssphp.net/">rssphp.net</a> to do this, if you are curious about how you can handle this yourself using SimpleXML check out <a href="http://www.pixel2life.com/publish/tutorials/102/xml_parsing_using_built_in_libraries_in_php5/">this tutorial</a> over at Pixel2Life. The end result of my solution is a bash script calling a php script to grab the quote.</p>
<h2>The Code</h2>
<p>First create a file named <code class="codecolorer text mac-classic"><span class="text">/etc/update-motd.d/10-quote</span></code>. The name does not matter much &#8211; the number will decide what order the script is called in of all the scripts in /etc/update-motd.d. Do an <code class="codecolorer text mac-classic"><span class="text">ls</span></code> on that directory to see what all is being called when you log in. Add the following lines to this file, assuming you are placing your scripts in /etc/scripts/:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>getquote.php<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span></div></td></tr></tbody></table></div>
<p><a href="http://rssphp.net/download/">Download v1 of rssphp</a> and extract it to the <code class="codecolorer text mac-classic"><span class="text">/etc/scripts/</span></code> directory. We will require that file in our php code.</p>
<p>Create the file <code class="codecolorer text mac-classic"><span class="text">/etc/scripts/getquote.php</span></code> and add the following:</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'rss_php.php'</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> rss_php<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.quotedb.com/quote/quote.php?action=random_quote_rss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rssitems</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// print_r($rssitems);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' :: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>I am using the RSS source from <a href="http://www.quotedb.com">QuoteDB</a> as the source of my quotes. Of all the places I checked (and I checked a lot) they seemed to have the most appropriate ones for this use. Feel free to use any source you wish &#8211; as long as the XML fields title/description hold the quote you will be able to use it. The RSS url was not obvious from the site and I had to do some digging to find it, in the end I am using <code class="codecolorer text mac-classic"><span class="text">http://www.quotedb.com/quote/quote.php?action=random_quote_rss</span></code>.</p>
<p>We also add the <em>if</em> statement to allow it to degrade nicely in case you have no network connectivity to the server. After a short period &#8211; a second or two &#8211; it will time out and let you log in. </p>
<p>The end result is a pretty quote in our motd:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Linux vps01.[redacted].com 2.6.18-2-pve #1 SMP Mon Feb 1 10:45:26 CET 2010 x86_64 GNU/Linux<br />
Ubuntu 10.04.1 LTS<br />
<br />
&quot;The absence of alternatives clears the mind marvelously.&quot; :: Henry Kissinger<br />
<br />
root@vps01:~#</div></td></tr></tbody></table></div>
<p>It should be pretty strait forward; let me know if you run into any problems!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fixing ip_conntrack Bottlenecks: The Tale Of The DNS Server With Many Tiny Connections</title>
		<link>http://systembash.com/content/fixing-ip_conntrack-bottlenecks-the-tale-of-the-dns-server-with-many-tiny-connections/</link>
		<comments>http://systembash.com/content/fixing-ip_conntrack-bottlenecks-the-tale-of-the-dns-server-with-many-tiny-connections/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 21:06:23 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[tcp/ip]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=822</guid>
		<description><![CDATA[I manage a server which has a sole purpose: serving DNS requests. We use <a href="http://www.powerdns.com">PowerDNS</a>, which has been great. It is a DNS server whose backend is SQL, making administration of large numbers of records very easy. It is also fast, easy to use, open source and did I mention it is free?

The server has been humming along for years now. The traffic graphs don't show a lot of data moving through it because it only serves DNS requests (plus MySQL replication) in the form of tiny UDP packets. 

Read on to follow my story of how I fixed this tricky problem. No kittens were harmed in the writing of this post. ]]></description>
			<content:encoded><![CDATA[<p>Server management is a funny thing. No matter how long you have been doing it, new interesting and unique challenges continue to pop up keeping you on your toes. This is a story about one of those challenges. </p>
<p>I manage a server which has a sole purpose: serving DNS requests. We use <a href="http://www.powerdns.com">PowerDNS</a>, which has been great. It is a DNS server whose backend is SQL, making administration of large numbers of records very easy. It is also fast, easy to use, open source and did I mention it is free?</p>
<p>The server has been humming along for years now. The traffic graphs don&#8217;t show a lot of data moving through it because it only serves DNS requests (plus MySQL replication) in the form of tiny UDP packets. </p>
<p><img src="http://systembash.com/wp-content/uploads/2010/10/servergraph.png" alt="" title="servergraph" width="507" height="355" class="aligncenter size-full wp-image-823" /></p>
<p>We started seeing these spikes in traffic but everything on the server seemed to be working properly. Test connections with <a href="http://linux.die.net/man/1/dig">dig</a> proved that the server was accurately responding to requests, but external tests showed the server going up and down. </p>
<h2>The First Clue</h2>
<p>I started going through logs to see if we were being DoSed or if it was some sort of configuration problem. Everything seemed to be running properly and the requests, while voluminous, seemed to be legit. Within the flood of messages I spied error messages such as this:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">printk: 2758 messages suppressed.<br />
ip_conntrack: table full, dropping packet.</div></td></tr></tbody></table></div>
<p>Ah ha! A clue! Let&#8217;s check the current numbers of ip_conntrack, which is a kernel function for the firewall which keeps tabs on packets heading into the system.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@ns1 log]# head /proc/slabinfo<br />
slabinfo - version: 2.0<br />
# name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;active_objs&gt; &lt;num_objs&gt; &lt;objsize&gt; &lt;objperslab&gt; &lt;pagesperslab&gt; : tunables &lt;batchcount&gt; &lt;limit&gt; &lt;sharedfactor&gt; : slabdata &lt;active_slabs&gt; &lt;num_slabs&gt; &lt;sharedavail&gt;<br />
ip_conntrack_expect &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;192 &nbsp; 20 &nbsp; &nbsp;1 : tunables &nbsp;120 &nbsp; 60 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0<br />
ip_conntrack &nbsp; &nbsp; &nbsp; &nbsp;34543 &nbsp;34576 &nbsp; &nbsp;384 &nbsp; 10 &nbsp; &nbsp;1 : tunables &nbsp; 54 &nbsp; 27 &nbsp; &nbsp;8 : slabdata &nbsp; 1612 &nbsp; 1612 &nbsp; &nbsp;108<br />
fib6_nodes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5 &nbsp; &nbsp;119 &nbsp; &nbsp; 32 &nbsp;119 &nbsp; &nbsp;1 : tunables &nbsp;120 &nbsp; 60 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;0<br />
ip6_dst_cache &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; 15 &nbsp; &nbsp;256 &nbsp; 15 &nbsp; &nbsp;1 : tunables &nbsp;120 &nbsp; 60 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;0<br />
ndisc_cache &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; 20 &nbsp; &nbsp;192 &nbsp; 20 &nbsp; &nbsp;1 : tunables &nbsp;120 &nbsp; 60 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;0<br />
rawv6_sock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4 &nbsp; &nbsp; 11 &nbsp; &nbsp;704 &nbsp; 11 &nbsp; &nbsp;2 : tunables &nbsp; 54 &nbsp; 27 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;0<br />
udpv6_sock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;704 &nbsp; 11 &nbsp; &nbsp;2 : tunables &nbsp; 54 &nbsp; 27 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0<br />
tcpv6_sock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8 &nbsp; &nbsp; 12 &nbsp; 1216 &nbsp; &nbsp;3 &nbsp; &nbsp;1 : tunables &nbsp; 24 &nbsp; 12 &nbsp; &nbsp;8 : slabdata &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; &nbsp;0</div></td></tr></tbody></table></div>
<p>Continuing this line of logic, lets check our current value for this setting:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@ns1 log]# sysctl net.ipv4.netfilter.ip_conntrack_max<br />
net.ipv4.netfilter.ip_conntrack_max = 34576</div></td></tr></tbody></table></div>
<p>So it looks like we are hitting up against this limit. After the number of connections reaches this number, the kernel will simply drop the packet. It does this so that it will not overload and freeze up due to too many packets coming into it at once.</p>
<p>This system is running on CentOS 4.8, and since then newer versions of RHEL5 have the default set at 65536. For maximum efficiency we keep this number at multiples of 2. The top size depends on your memory, so just be careful as overloading it may cause you to run out of it.</p>
<h2>Fixing The ip_conntrack Bottleneck</h2>
<p>In my case I decided to go up 2 steps to 131072. To temporarily set it, use sysctl:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@ns1 log]# sysctl -w &nbsp;net.ipv4.netfilter.ip_conntrack_max=131072<br />
net.ipv4.netfilter.ip_conntrack_max = 131072</div></td></tr></tbody></table></div>
<p>Test everything out, if you have some problems with your network or system crashing, a reboot will set the value back to normal. To make the setting permanent on reboot, add the following line to your <code class="codecolorer text mac-classic"><span class="text">/etc/sysctl.conf</span></code> file:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># need to increase this due to volume of connections to the server<br />
net.ipv4.netfilter.ip_conntrack_max=131072</div></td></tr></tbody></table></div>
<p>My theory is that since the server was dropping packets, remote hosts were re-sending their DNS requests causing a &#8216;flood&#8217; of traffic to the server and the spikes you see in the traffic graph above whenever traffic was mildly elevated. The bandwidth spikes were caused by amplification of traffic due to resending of the requests. After increasing ip_conntrack_max I immediately saw the bandwidth resume to normal levels. </p>
<p>Your server should now be set against an onslaught of tiny packets, legitimate or not. If you have even more connections than what you can safely track with ip_conntrack you may need to move to the next level which involves hardware firewalls and other methods for packet inspection off-server on dedicated hardware.</p>
<p>Some resources used in my investigation of this problem:<br />
[1] <a href="http://wiki.khnet.info/index.php/Conntrack_tuning">http://wiki.khnet.info/index.php/Conntrack_tuning</a><br />
[2] <a href="http://serverfault.com/questions/111034/increasing-ip-conntrack-max-safely">http://serverfault.com/questions/111034/increasing-ip-conntrack-max-safely</a><br />
[3] <a href="http://www.linuxquestions.org/questions/red-hat-31/ip_conntrack-table-full-dropping-packet-615436/">http://www.linuxquestions.org/questions/red-hat-31/ip_conntrack-table-full-dropping-packet-615436/</a></p>
<p><small>The image of the kittens used for the featured image has nothing to do with this post. There are no known good photos of a &#8220;UDP Packet&#8221;, and I thought that everyone likes kittens, so there it is. Credit <a href="http://www.flickr.com/photos/mathias-erhart/2562106102/">flickr user mathias-erhart</a>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/fixing-ip_conntrack-bottlenecks-the-tale-of-the-dns-server-with-many-tiny-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another Bash One Liner To Delete Old Directories</title>
		<link>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/</link>
		<comments>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 22:05:58 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=685</guid>
		<description><![CDATA[We received a tip from blog readers Christian and Michael for alternatives to the command to delete all directories older than a certain period of time. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line. From Christian: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \; From Michael: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory =&#62; {}” \; -exec rm -rf “{}” \; The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!]]></description>
			<content:encoded><![CDATA[<p>We received a tip from blog readers Christian and Michael for alternatives to the <a href="http://systembash.com/content/delete-directories-older-than-week/">command to delete all directories older than a certain period of time</a>. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line.</p>
<p>From Christian:</p>
<pre>find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \;</pre>
<p>From Michael:</p>
<pre>find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory =&gt; {}” \; -exec rm -rf “{}” \;</pre>
<p>The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Line Batch Rename Files Using CSV Input File and awk</title>
		<link>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/</link>
		<comments>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 17:12:32 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[csv]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=614</guid>
		<description><![CDATA[The Bash command environment, which is the namesake of this blog, is very flexible in that it allows you to manipulate the filesystem in many ways. Awk and sed are very powerful tools that allow you to do this rename with a simple one line command. This post will walk you through doing this with a Comma Separated Value (CSV) file and also using a simple regular expression to rename many files. The goal is  to rename a whole folder, hundreds of files, to a proper format for viewing in Boxee. The old listing, for example using ls -1, was: Seinfeld-(The Wig Master)-2003-09-26-0(1).avi Seinfeld-(The Wink)-2004-01-03-0.avi Seinfeld-(The Wizard)-2004-02-26-0.avi Seinfeld-(The Yada Yada)-2003-06-04-0.avi Seinfeld-(The Pen)-2004-06-22-0.avi I created a CSV file, and from the powers of the Amazon Mechanical Turk services, generated an entire list of the correct filenames, in the format: Seinfeld.7x19.The.Wig.Master.avi Seinfeld.7x04.The.Wink.avi Seinfeld.9x15.The.Wizard.avi Seinfeld.8x19.The.Yada.Yada.avi Seinfeld.3x03.The.Pen.avi Now I just needed a way to....]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.gnu.org/software/bash/manual/bashref.html#What-is-Bash_003f">Bash</a> command environment, which is the namesake of this blog, is very flexible in that it allows you to manipulate the filesystem in many ways. <a href="http://linux.die.net/man/1/awk">Awk</a> and <a href="http://linux.die.net/man/1/sed">sed</a> are very powerful tools that allow you to do this rename with a simple one line command. This post will walk you through doing this with a Comma Separated Value (CSV) file and also using a simple regular expression to rename many files.<br />
<span id="more-614"></span><br />
The goal is  to rename a whole folder, hundreds of files, to a <a href="http://forum.boxee.tv/showthread.php?t=5214">proper format</a> for viewing in Boxee. The old listing, for example using ls -1, was:</p>
<pre>Seinfeld-(The Wig Master)-2003-09-26-0(1).avi
Seinfeld-(The Wink)-2004-01-03-0.avi
Seinfeld-(The Wizard)-2004-02-26-0.avi
Seinfeld-(The Yada Yada)-2003-06-04-0.avi
Seinfeld-(The Pen)-2004-06-22-0.avi</pre>
<p>I created a CSV file, and from the powers of the <a href="https://www.mturk.com/mturk/welcome">Amazon Mechanical Turk</a> services, generated an entire list of the correct filenames, in the format:</p>
<pre>Seinfeld.7x19.The.Wig.Master.avi
Seinfeld.7x04.The.Wink.avi
Seinfeld.9x15.The.Wizard.avi
Seinfeld.8x19.The.Yada.Yada.avi
Seinfeld.3x03.The.Pen.avi</pre>
<p>Now I just needed a way to actually do the rename.</p>
<p>The final CSV file I generated is in the format:</p>
<pre>Seinfeld-(The Wig Master)-2003-09-26-0(1).avi,Seinfeld.7x19.The.Wig.Master.avi
Seinfeld-(The Wink)-2004-01-03-0.avi,Seinfeld.7x04.The.Wink.avi
Seinfeld-(The Wizard)-2004-02-26-0.avi,Seinfeld.9x15.The.Wizard.avi
Seinfeld-(The Yada Yada)-2003-06-04-0.avi,Seinfeld.8x19.The.Yada.Yada.avi
Seinfeld-(The Pen)-2004-06-22-0.avi,Seinfeld.3x03.The.Pen.avi</pre>
<p>Note that in my format, there could be no commas in the file names; but you can use any other delimiter such as = or ;, it would work equally as well with a character change in the script.</p>
<p>Using awk, you can get a correct command line output from this file:</p>
<pre>awk -F',' '{print("mv &#92;"" $1 "&#92;" &#92;"" $2 "&#92;"")}' input.txt</pre>
<p>Results in a preview of your commands, like so:</p>
<pre>mv "Seinfeld-(The Wig Master)-2003-09-26-0(1).avi" "Seinfeld.7x19.The.Wig.Master.avi"
mv "Seinfeld-(The Wink)-2004-01-03-0.avi" "Seinfeld.7x04.The.Wink.avi"
mv "Seinfeld-(The Wizard)-2004-02-26-0.avi" "Seinfeld.9x15.The.Wizard.avi"
mv "Seinfeld-(The Yada Yada)-2003-06-04-0.avi" "Seinfeld.8x19.The.Yada.Yada.avi"
mv "Seinfeld-(The Pen)-2004-06-22-0.avi" "Seinfeld.3x03.The.Pen.avi"</pre>
<p>Note that we put the file names in quotes because they contain spaces, and linux won&#8217;t recognize the filenames if you don&#8217;t include that. The -F command in awk is where you specify your delimiter, so feel free to use another character. Once you have &#8216;proofed&#8217; the script to make sure it is doing what you expect it to, you execute it by adding |/bin/sh to the end, to pipe it directly to bash.</p>
<pre>awk -F',' '{print("mv &#92;"" $1 "&#92;" &#92;"" $2 "&#92;"")}' input.txt | /bin/sh</pre>
<p>This won&#8217;t result in any output, but you will see that it changed the names of your files, just as if you would have typed in the commands (proofed above) yourself.</p>
<p>If you don&#8217;t want to go through the bother of generating a CSV file, but you still want to use bash to rename files using awk, you can use a similar command which I found over at <a href="http://snipplr.com/view/3648/batch-file-rename-with-awk-and-sed/">Snipplr</a>.</p>
<pre>ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2'</pre>
<p>As with the other one, this will output the command to move the file but instead uses sed to do a search/replace of the string in the filename. Append |/bin/sh to execute the commands on your system.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux Command Line, Generating a Random File</title>
		<link>http://systembash.com/content/linux-command-line-generating-a-random-file/</link>
		<comments>http://systembash.com/content/linux-command-line-generating-a-random-file/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 01:53:41 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=581</guid>
		<description><![CDATA[It is very easy to create a random file using the linux command line. Much like the command to fill a file with all zeros, for example a 1 Meg file: dd if=/dev/zero of=zero.filename bs=1024 count=1000 You do the same using /dev/urandom: dd if=/dev/urandom of=random.filename bs=1024 count=1000 Resulting in a 1MB file: 1000+0 records in 1000+0 records out 1024000 bytes (1.0 MB) copied, 0.0294247 s, 34.8 MB/s This is transferring random data from the virtual device urandom to the output file. We use /dev/urandom instead of /dev/random because the /dev/random source generates random data very slowly. urandom is much faster at this but remains very random, if not quite a random as /dev/random. This should work with any system with dd and /dev/urandom.]]></description>
			<content:encoded><![CDATA[<p>It is very easy to create a random file using the linux command line. Much like the command to fill a file with all zeros, for example a 1 Meg file:</p>
<pre>dd if=/dev/zero of=zero.filename bs=1024 count=1000</pre>
<p>You do the same using /dev/urandom:</p>
<pre>dd if=/dev/urandom of=random.filename bs=1024 count=1000</pre>
<p>Resulting in a 1MB file:</p>
<pre>1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB) copied, 0.0294247 s, 34.8 MB/s</pre>
<p>This is transferring random data from the virtual device urandom to the output file. We use /dev/urandom instead of /dev/random because the /dev/random source generates random data very slowly. urandom is much faster at this but remains very random, <a href="http://vinitsworld.blogspot.com/2008/10/difference-between-devrandom-and.htmlh">if not quite a random</a> as /dev/random. This should work with any system with <a href="http://linux.die.net/man/1/dd">dd</a> and /dev/urandom.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/linux-command-line-generating-a-random-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tweaking TCP for Fast (100mbps+) Connections and Transfers on Linux</title>
		<link>http://systembash.com/content/tweaking-tcp-for-fast-100mbps-connections-and-transfers-on-linux/</link>
		<comments>http://systembash.com/content/tweaking-tcp-for-fast-100mbps-connections-and-transfers-on-linux/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 01:26:24 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[tcp/ip]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=516</guid>
		<description><![CDATA[We recently did some speed testing on a few of the servers on our network, and we were not receiving the speeds expected considering they were sitting on a physical 100mbps ethernet port. The servers were indeed on physical 100mbps connection, however wget (TCP/IP, HTTP Port 80) download tests showed only a max of about 1.5MB/sec (note the 8bit/byte conversion, so this translates to about 12mbits).]]></description>
			<content:encoded><![CDATA[<p>We recently did some speed testing on a few of the servers on our network, and we were not receiving the speeds expected considering they were sitting on a physical 100mbps ethernet port. The servers were indeed on physical 100mbps connection, however wget (TCP/IP, HTTP Port 80) download tests showed only a max of about 1.5MB/sec (note the 8bit/byte conversion, so this translates to about 12mbits).</p>
<p><a href="http://systembash.com/wp-content/uploads/2009/12/fastnetwork.png"><img class="aligncenter size-full wp-image-519" title="fastnetwork" src="http://systembash.com/wp-content/uploads/2009/12/fastnetwork.png" alt="" width="531" height="203" /></a></p>
<p>This is due to how TCP frames data packets and optimizes them for connections. I believe by default TCP on most systems assumes about a 10mbit max capable transfer rate, so it does not show performance gains on a larger pipe without modification to the kernel options which govern TCP/IP frame size and features. Some distributions may make this change for you automatically however many will not.</p>
<p>To keep things short and sweet, we took the following advice from <a href="http://www.speedguide.net/">Speedguide.net</a> on tweaking TCP parameters on linux kernel systems. This will cover Linux 2.1 and above &#8211; which means CentOS, RedHat, Ubuntu, Debian and many more distributions.</p>
<p>The TCP Parameters we will change are:</p>
<ul>
<li>/proc/sys/net/core/rmem_max - Maximum TCP Receive Window</li>
<li>/proc/sys/net/core/wmem_max &#8211; Maximum TCP Send Window</li>
<li>/proc/sys/net/ipv4/tcp_timestamps - (<a href="http://www.ietf.org/rfc/rfc1323.txt">RFC 1323</a>) timestamps add 12 bytes to the TCP header&#8230;</li>
<li>/proc/sys/net/ipv4/tcp_sack &#8211; tcp selective acknowledgements.</li>
<li>/proc/sys/net/ipv4/tcp_window_scaling &#8211; support for large TCP Windows (<a href="http://www.ietf.org/rfc/rfc1323.txt">RFC 1323</a>). Needs to be set to 1 if the Max TCP Window is over 65535.</li>
</ul>
<p>If you recall /proc/ is the volatile portion of kernel configuration, you can change it on the fly but it will be reset on reboot unless settings are changed via an init file or setting the options in /etc/sysctl.conf. To change the settings once (to test):</p>
<pre class="prettyprint">echo 256960 > /proc/sys/net/core/rmem_default
echo 256960 > /proc/sys/net/core/rmem_max
echo 256960 > /proc/sys/net/core/wmem_default
echo 256960 > /proc/sys/net/core/wmem_max
echo 0 > /proc/sys/net/ipv4/tcp_timestamps
echo 1 > /proc/sys/net/ipv4/tcp_sack
echo 1 > /proc/sys/net/ipv4/tcp_window_scaling</pre>
<p>And to apply them for good, add the following lines to /etc/sysctl.conf:</p>
<pre class="prettyprint">net.core.rmem_default = 256960
net.core.rmem_max = 256960
net.core.wmem_default = 256960
net.core.wmem_max = 256960
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1</pre>
<p>Use &#8216;sysctl -p&#8217; to apply the changes in this file to your running Linux instance. Feel free to experiment with these numbers to see how they impact your transfers, it depends a lot on how many and how large the files are that you transferring. These changes must be made on the SERVER side, any change on the client side would not impact the download speed from the server.</p>
<p>There are several other variables to consider, and these all depend on your application so change them if you know what you are attempting to do. After changing these settings, you will see speeds of about 10MB/sec (80mbps) on a 100mbps connection. The other 20mbps are lost in TCP and other network layer overhead, which is unavoidable.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/tweaking-tcp-for-fast-100mbps-connections-and-transfers-on-linux/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A Poor Man&#8217;s VPN: Proxy Web Connection to Remote Server (via SSH and Tunnel)</title>
		<link>http://systembash.com/content/a-poor-mans-vpn-proxy-web-connection-to-remote-server-via-ssh-and-tunnel/</link>
		<comments>http://systembash.com/content/a-poor-mans-vpn-proxy-web-connection-to-remote-server-via-ssh-and-tunnel/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 13:12:20 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://systembash.com/content/a-poor-mans-vpn-proxy-web-connection-to-remote-server-via-ssh-and-tunnel/</guid>
		<description><![CDATA[Did you ever have a situation where you needed to access a website that had an IP restriction in place? I recently had a situation where I needed to access the web via my university connection (due to IP restrictions placed on accessing databases of research papers). They do not have a VPN setup so it is hard to do this off-campus. I do however have access to a linux machine on campus. I am familiar with port forwarding using SSH but I had never used it to actually tunnel web traffic using a web browser on Windows. Turns out it is surprisingly easy! The ssh command to use is: 1ssh -C2qTnN -D 8080 username@remote_host This command sshes to the remote_host, and creates a tunnel on your localhost, port 8080. Note that you need to have private key authentication already set up for this host &#8211; it will not work....]]></description>
			<content:encoded><![CDATA[<p>Did you ever have a situation where you needed to access a website that had an IP restriction in place? I recently had a situation where I needed to access the web via my university connection (due to IP restrictions placed on accessing databases of research papers). They do not have a VPN setup so it is hard to do this off-campus.</p>
<p>I do however have access to a linux machine on campus. I am familiar with port forwarding using SSH but I had never used it to actually tunnel web traffic using a web browser on Windows. Turns out it is surprisingly easy!</p>
<p>The ssh command to use is:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ssh -C2qTnN -D 8080 username@remote_host</div></td></tr></tbody></table></div>
<p>This command sshes to the remote_host, and creates a tunnel on your localhost, port 8080. Note that you need to have private key authentication already set up for this host &#8211; it will not work with password authentication.</p>
<p>The description of the switches are (from the <a href="http://linux.die.net/man/1/ssh">ssh man page</a>):</p>
<ul>
<li>-C : Compression</li>
<li>-2 : Use SSHv2</li>
<li>-q : quiet!</li>
<li>-T : Disable pseuto-tty allocation</li>
<li>-n : Prevents reading from stdin (you need to have private key authentication set up, to prevent password authentication)</li>
<li>-N : Do not execute a remote command (or launch a shell). Just use the ssh process for port forwarding</li>
<li>-D : Allocate a socket to listen on the local side. When a connection is made to this port it is located to the remote machine. Makes SSH work as a SOCKS server. Only root can forward&nbsp;privileged&nbsp;ports like this.</li>
</ul>
<p>From here, you set up Firefox or your browser of choice to use a Socks proxy on localhost:8080. The man page says that SOCKS4 and SOCK5 should both work but I had to use SOCKS v4, SOCKS v5 did not seem to work for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/a-poor-mans-vpn-proxy-web-connection-to-remote-server-via-ssh-and-tunnel/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Install SNMP on Tomato Router Firmware and Graph Traffic with Cacti</title>
		<link>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/</link>
		<comments>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 01:16:39 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Other Code]]></category>
		<category><![CDATA[Other Technology]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=406</guid>
		<description><![CDATA[You&#8217;ve flashed your old WRT54G or other vanilla router with the Tomato firmware. This itself turns your router into a lean, mean routing machine with QOS, SSH and more, but let&#8217;s say we want to take it a bit further. What it we want to get some more stats out of it? In order to do this, we first need to set up a way to pull this information from the router. The best way to do this is to install an SNMP (Simple Network Management Protocol) daemon on the system. The main roadblock we face here is that the system mainly runs in volatile system memory, meaning that every time the system is rebooted the filesystem is reset. Fortunately Tomato provides a way to get around this using CIFS shares. Follow the steps below (as modified from here) to install an SNMP server on a Tomato router. Create a....]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve flashed your old WRT54G or other vanilla router with the <a href="http://www.polarcloud.com/tomato">Tomato firmware</a>. This itself turns your router into a lean, mean routing machine with QOS, SSH and more, but let&#8217;s say we want to take it a bit further. What it we want to get some more stats out of it?</p>
<p>In order to do this, we first need to set up a way to pull this information from the router. The best way to do this is to install an SNMP (<strong><span style="text-decoration: underline;">S</span></strong>imple <span style="text-decoration: underline;"><strong>N</strong></span>etwork <strong><span style="text-decoration: underline;">M</span></strong>anagement <strong><span style="text-decoration: underline;">P</span></strong>rotocol) daemon on the system.</p>
<p>The main roadblock we face here is that the system mainly runs in volatile system memory, meaning that every time the system is rebooted the filesystem is reset. Fortunately Tomato provides a way to get around this using CIFS shares. Follow the steps below (as modified from <a href="http://www.linksysinfo.org/forums/showthread.php?t=51064">here</a>) to install an SNMP server on a Tomato router.</p>
<ol>
<li>Create a network (samba, CIFS) share somewhere on the network. This computer must be on all of the time in order for Tomato to run the SNMP server.</li>
<li>Download the snmpd.zip file from one of these locations:<br />
[<a href="http://bok.xs4all.nl/downloads/snmpd.zip">xs4all.nl</a>]<br />
[<a href="http://systembash.com/source/snmpd.zip">systembash</a>]</p>
<p>expand the binary and .conf file into the share or a subdirectory (for example, &lt;share name&gt;/snmp)</p>
<p>MD5 for snmpd binary is ae0d622648efdb8dceb7b3b5a63e23ac</li>
<li style="text-align: center; ">Set up the shared directory on the router. Visit Administration-&gt;CIFS Client. Add the share as follows, with your correct share information:<img class="aligncenter size-full wp-image-428" title="cifs1" src="http://systembash.com/wp-content/uploads/2009/08/cifs11.png" alt="cifs1" width="360" height="258" /></li>
<li>Log into the Tomato router via ssh, and start SNMPd on the router by issuing the command:
<pre>/cifs1/snmp/snmpd -c /cifs1/snmp/snmpd.conf &amp;</pre>
</li>
<li> Test that SNMP is running and can be accessed on another computer on the network. To test it, you can use snmpwalk like so:
<pre>snmpwalk -c public -v 2c &lt;IP Address of Router&gt;</pre>
<p>If it works properly, it will list the available OIDs from the router. You do not need to take note of these, but they will be used in the graphing software later.</li>
<li>Finally, we need to launch the SNMP server when the router is restarted. You do this by adding the command to start it in the area Administration -&gt; Scripts -&gt; Firewall:
<pre>sleep 30
/cifs1/snmp/snmpd -c /cifs1/snmp/snmpd.conf -s &amp;</pre>
<p>This launches the snmp server 30 seconds after the router is started or rebooted.</li>
</ol>
<p>Thats it! SNMP is now running on the router.</p>
<p>Now to add this SNMP host to your graphing software. For this example, I will use <a href="http://www.cacti.net/">Cacti</a>, which I will assume you have already set up. If you need to set it up, please <a href="http://www.cacti.net/documentation.php">follow the directions</a> on the Cacti site for installation.</p>
<p>First, add the router as a new device, using the information below (change IP to suite your needs):</p>
<p><center><img class="aligncenter size-full wp-image-430" title="adddevice" src="http://systembash.com/wp-content/uploads/2009/08/adddevice.png" alt="adddevice" width="338" height="768" /></center></p>
<p>After adding the device, you have several options depending on what sort of data you are looking for. For system information on the router &#8211; for example CPU usage, memory usage, etc; you can go directly to Create -&gt; New Graphs. Select your device and then add the graph you are looking for.</p>
<p>The graph will show as a broken image at first, or a blank graph with &#8220;NaN&#8221; as the data source. Give it a few minutes to update, and the information should start to flow through. The ucd/net options work best, but feel free to experiment.</p>
<p>To get traffic stats on the interface, you first need to &#8220;Walk&#8221; the device.  Go back to your device list, and edit the device you added. Under &#8220;Associated Data Queries&#8221;, Add Data Query, add &#8220;SNMP &#8211; Interface Statistics&#8221; with Re-Index period as &#8220;Uptime goes backwards&#8221;. After adding it you should see under status something like: Success [39 Items, 6 Rows].</p>
<p>Since these data sources are now added, you can go back to Add a new Graph. After selecting the device, you should see a list of these new interfaces. Select the interfaces you wish to graph, and select the graph type (I suggest In/Out bits with Total).</p>
<p>After a few minutes, the data should start filling in. After a while, you will get a graph like this:</p>
<p><center><a href="http://systembash.com/wp-content/uploads/2009/08/graph_image.php1.png"><img src="http://systembash.com/wp-content/uploads/2009/08/graph_image.php1-300x120.png" alt="graph_image.php" title="graph_image.php" width="300" height="120" class="aligncenter size-medium wp-image-435" /></a></center></p>
<p><em>In conclusion</em>, with a little work, you can get enterprise class graphing from your consumer router. The total project took me about 45 minutes, and I was trying to figure out all of the data sources and the correct way to enter everything.</p>
<p>Let me know your experiences, suggestions and corrections!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 1/18 queries in 0.006 seconds using disk: basic

Served from: systembash.com @ 2012-02-07 03:53:31 -->
