<?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>h1tman.com - Tim Galyean&#039;s blog</title>
	<atom:link href="http://www.h1tman.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.h1tman.com</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 22:28:39 +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>Theia &#8211; Open Source NetApp Monitoring</title>
		<link>http://www.h1tman.com/2011/10/theia-open-source-netapp-monitoring/</link>
		<comments>http://www.h1tman.com/2011/10/theia-open-source-netapp-monitoring/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 21:13:17 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Operations]]></category>
		<category><![CDATA[autodiscovery]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[subprocess]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=704</guid>
		<description><![CDATA[During my time here at Ning I have had the opportunity to work on many different projects open and closed source. The one thing that has been a continuous trend is our ability to provide stable and useful open source code. Complimented by the likes of Thomas Dudziak, Brian McCallister, and Gerir Ning has proven [...]]]></description>
			<content:encoded><![CDATA[<p>During my time here at Ning I have had the opportunity to work on many different projects open and closed source. The one thing that has been a continuous trend is our ability to provide stable and useful open source code. Complimented by the likes of <a href="http://tomdzk.wordpress.com/" target="_blank">Thomas Dudziak</a>, <a href="http://skife.org/" target="_blank">Brian McCallister</a>, and <a href="http://blog.aiama.com/" target="_blank">Gerir</a> Ning has proven to be able to remain on the cutting edge of technology without losing customer focus.<br />
<br />
Once again Ning is continuing this trend by releasing Theia as our most recent Open Source project. Theia provides a free alternative for monitoring NetApp utilization including CPU load, Disk usage, iops, interface utilization and more. Additionally Theia can also send passive health checks to nagios via <a href="http://community.nagios.org/2009/06/11/nagios-setting-up-the-nsca-addon-for-passive-checks/" target="_blank">nsca addon</a>.</p>
<p>So where do I come in? Well thats an easy question to answer with a long explanation. <a href="http://blog.aiama.com/" target="_blank">Gerir</a> wrote Theia as an internal tool for gathering statistical data from our production NetApps. Being an architecty kinda guy we keep him very busy, so unfortunately he doesn&#8217;t have as much time to work on Theia as we would like. This is where I come in.. After having some conversations with Gerir about Theia, we decided that she needed some attention and after a few revisions it would be time for Theia to be introduced to the Open Source community through <a href="http://github.com/ning" target="_blank">http://github.com/ning</a></p>
<p><b>Getting ready for open source!</b><br />
The main feature that was holding us back from open sourcing Theia was the lack of interface autodiscovery. This was a crucial part to open sourcing Theia because without this you would have to create a copy of Theia for every netapp you were planning to monitor. As part of the metrics collection we parse network interface statistics. Previously this required you to hard code the name of the NetApp interface into theia. From an Operations perspective this would be a nightmare to manage if you have more than one NetApp, or if the interfaces ever changed. In addition to the management nightmares python dictionary&#8217;s only support unique Key&#8217;s which Theia uses for text formatting which would prevent Theia from ever being able to display statistical data for multiple network interfaces.</p>
<p>I overcame these obstacles by utilizing modules that were already being imported as to limit overhead, and to keep things tidy. So first things first.. we need to &#8220;discover&#8221; the active interfaces on the NetApp. There are a few built in tools which are exposed to provide this functionality but they dont appear to be written with automation in mind. </p>
<p>By using the python subprocess library we can login to the netapp and collect some data as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">&quot;/usr/bin/ssh -o BatchMode=yes -2 -ax -i /root/.ssh/perfstat_dsa %s 'stats show ifnet'|sed 's/:/ /g'|sort|awk '{print $2}'|uniq|tr -d '<span style="color: #000099; font-weight: bold;">\r</span>'&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>hostname<span style="color: black;">&#41;</span></pre></div></div>

<p>If we break down this command we can see that we are establishing an SSH connection to the NetApp and running &#8216;stats show ifnet&#8217; which is a utility exposed by ONTAP 7.3. After we have the interface details we can then perform some text formatting so that we can parse the network interfaces and load them into a python list.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">NetApp<span style="color: #000000; font-weight: bold;">&gt;</span> stats show ifnet
ifnet:svif0:recv_packets:<span style="color: #000000;">22510</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:recv_errors:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:send_packets:<span style="color: #000000;">41798</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:send_errors:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:collisions:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:recv_data:1969198b<span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:send_data:61504464b<span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:recv_mcasts:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:send_mcasts:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
ifnet:svif0:recv_drop_packets:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>s
NetApp<span style="color: #000000; font-weight: bold;">*&gt;</span></pre></div></div>

<p>Code:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">&quot;/usr/bin/ssh -o BatchMode=yes -2 -ax -i /root/.ssh/perfstat_dsa %s 'stats show ifnet'|sed 's/:/ /g'|sort|awk '{print $2}'|uniq|tr -d '<span style="color: #000099; font-weight: bold;">\r</span>'&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>hostname<span style="color: black;">&#41;</span>
    p = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>,shell=<span style="color: #008000;">True</span>,stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span>,stderr=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>
    so = p.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span></pre></div></div>

<p>Note that the subprocess library returns both stdout and stderr so we must tell python to only return stdout by specifying <code>[0]</code> at the end our <code>p.communicate()</code> command. </p>
<p>Now that we have the names of the interfaces we can collect data for each individual interface by iterating over our python list. This is done by using a basic <code>for loop</code> as shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    if_list = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    if_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>so.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">for</span> interface <span style="color: #ff7700;font-weight:bold;">in</span> if_list:
            vifs = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
            vifs = interface.<span style="color: black;">splitlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>As you can see in the <code>for loop</code> listed above we are calling the buit in python library <code>splitlines()</code> as well as <code>rstrip()</code>. In order to properly format our list we must first remove the newline characters that are inserted by the <code>stats show ifnet</code> command, and then sort them into the &#8220;vifs&#8221; list. Here is the before and after using <code>print</code> statements to compare.</p>
<p><code>if_list.append(so.rstrip('\n'))</code></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: black;">&#91;</span><span style="color: #483d8b;">'e0b<span style="color: #000099; font-weight: bold;">\n</span>e0d<span style="color: #000099; font-weight: bold;">\n</span>e0e<span style="color: #000099; font-weight: bold;">\n</span>e0f<span style="color: #000099; font-weight: bold;">\n</span>vif0'</span><span style="color: black;">&#93;</span></pre></div></div>

<p><code><br />
    for interface in if_list:<br />
            vifs = []<br />
            vifs = interface.splitlines()<br />
</code></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: black;">&#91;</span><span style="color: #483d8b;">'e0b'</span>, <span style="color: #483d8b;">'e0d'</span>, <span style="color: #483d8b;">'e0e'</span>, <span style="color: #483d8b;">'e0f'</span>, <span style="color: #483d8b;">'vif0'</span><span style="color: black;">&#93;</span></pre></div></div>

<p>Up to this point we have been doing prep work leading in to the working portion of this code. In order for Theia to iterate over our active interfaces and collect the statistical data that we are looking for we need to present these values to theia in the form of a python dictionary. Dictionary&#8217;s are pretty simple and consist of a Key and a Value. The Key specifies the name of our Value. For example if you had a Key called &#8220;Food&#8221;, Pizza could be your value and would be represented as:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">mealtime = <span style="color: black;">&#123;</span> 
      <span style="color: #483d8b;">'Food'</span>    : <span style="color: #483d8b;">&quot;pizza&quot;</span>
<span style="color: black;">&#125;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> mealtime</pre></div></div>

<p>Theia uses a dictionary called xnmetrics that will be used to collect the specific data from the NetApp. Since the python dictionary requires you to have unique Keys, we must also specify the interface name as part of the Key. We do this by writing another simple <code>for loop</code>, but we will append the data in our list into the xnmetrics dictionary.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">for</span> vif <span style="color: #ff7700;font-weight:bold;">in</span> vifs:
            xnmetrics<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;NetRE %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;ifnet:%s:recv_errors&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span>
            xnmetrics<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;NetSE %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;ifnet:%s:send_errors&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span></pre></div></div>

<p>Here we are doing a few things. First and most obvious is our <code>for loop</code> but whats important is the action we are performing. While iterating through our list of interfaces we are appending the Key and Value for each interface as the vif into our xnmetrics dictionary. By appending the interface name into the key we can ensure that we always have our required unique Key name and as an afterthought we can also easily identify the name of the interface.</p>
<p>I hope you find this article useful, and as with all open source projects we are looking for contributors who would like to use and expand upon Theia. So if you are interested head over to the Ning github @ <a href="https://github.com/ning/Theia" target="_blank">https://github.com/ning/Theia</a> to get started!</p>
<p><b>autodiscover.py &#8211; code integrated into Theia for interface autodiscovery</b></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># xnmetrics dictionary (Original Theia code)</span>
xnmetrics = <span style="color: black;">&#123;</span> 
      <span style="color: #483d8b;">'APB'</span>    : <span style="color: #483d8b;">&quot;system:system:avg_processor_busy&quot;</span>,
      <span style="color: #483d8b;">'CIFSO'</span>  : <span style="color: #008000;">None</span>,
      <span style="color: #483d8b;">'CPU'</span> : <span style="color: #483d8b;">&quot;system:system:cpu_busy&quot;</span>,
      <span style="color: #483d8b;">'CPtime'</span> : <span style="color: #483d8b;">&quot;system:system:cp_time&quot;</span>,
      <span style="color: #483d8b;">'CacheAge'</span> : <span style="color: #483d8b;">&quot;system:system:cache_age&quot;</span>,
      <span style="color: #483d8b;">'CacheHit'</span> : <span style="color: #483d8b;">&quot;system:system:cache_hit&quot;</span>,
      <span style="color: #483d8b;">'DiskRead'</span> : <span style="color: #483d8b;">&quot;system:system:disk_data_read&quot;</span>,
      <span style="color: #483d8b;">'DiskUtil'</span> : <span style="color: #483d8b;">&quot;system:system:disk_busy&quot;</span>,
      <span style="color: #483d8b;">'DiskWrite'</span> : <span style="color: #483d8b;">&quot;system:system:disk_data_written&quot;</span>,
      <span style="color: #483d8b;">'HTTPO'</span> : <span style="color: #008000;">None</span>,
      <span style="color: #483d8b;">'NFSO'</span> : <span style="color: #483d8b;">&quot;nfsv3:nfs:nfsv3_ops&quot;</span>,
      <span style="color: #483d8b;">'NFSRL'</span> : <span style="color: #483d8b;">&quot;nfsv3:nfs:nfsv3_read_latency&quot;</span>,
      <span style="color: #483d8b;">'NFSRO'</span> : <span style="color: #483d8b;">&quot;nfsv3:nfs:nfsv3_read_ops&quot;</span>,
      <span style="color: #483d8b;">'NFSWL'</span> : <span style="color: #483d8b;">&quot;nfsv3:nfs:nfsv3_write_latency&quot;</span>,
      <span style="color: #483d8b;">'NFSWO'</span> : <span style="color: #483d8b;">&quot;nfsv3:nfs:nfsv3_write_ops&quot;</span>,
      <span style="color: #483d8b;">'NetIn'</span> : <span style="color: #483d8b;">&quot;system:system:net_data_recv&quot;</span>,
      <span style="color: #483d8b;">'NetOut'</span> : <span style="color: #483d8b;">&quot;system:system:net_data_sent&quot;</span>,
      <span style="color: #483d8b;">'TPB'</span> : <span style="color: #483d8b;">&quot;system:system:total_processor_busy&quot;</span>,
      <span style="color: #483d8b;">'TapeRead'</span> : <span style="color: #008000;">None</span>,
      <span style="color: #483d8b;">'TapeWrite'</span> : <span style="color: #008000;">None</span>,
      <span style="color: #483d8b;">'TotalO'</span> : <span style="color: #483d8b;">&quot;system:system:total_ops&quot;</span>,
      <span style="color: #483d8b;">'cpu0'</span> : <span style="color: #483d8b;">&quot;processor:processor0:processor_busy&quot;</span>,
      <span style="color: #483d8b;">'cpu1'</span> : <span style="color: #483d8b;">&quot;processor:processor1:processor_busy&quot;</span>,
      <span style="color: #483d8b;">'cpu2'</span> : <span style="color: #483d8b;">&quot;processor:processor2:processor_busy&quot;</span>,
      <span style="color: #483d8b;">'cpu3'</span> : <span style="color: #483d8b;">&quot;processor:processor3:processor_busy&quot;</span>
<span style="color: black;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># interface autodiscovery code (Open Source Initiative)</span>
<span style="color: #ff7700;font-weight:bold;">def</span> vifautodiscover<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    hostname = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
    <span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">&quot;/usr/bin/ssh -o BatchMode=yes -2 -ax -i /root/.ssh/perfstat_dsa %s 'stats show ifnet'|sed 's/:/ /g'|sort|awk '{print $2}'|uniq|tr -d '<span style="color: #000099; font-weight: bold;">\r</span>'&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>hostname<span style="color: black;">&#41;</span>
    p = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>,shell=<span style="color: #008000;">True</span>,stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span>,stderr=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>
    so = p.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
    if_list = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    if_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>so.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">for</span> interface <span style="color: #ff7700;font-weight:bold;">in</span> if_list:
            vifs = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
            vifs = interface.<span style="color: black;">splitlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">for</span> vif <span style="color: #ff7700;font-weight:bold;">in</span> vifs:
            xnmetrics<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;NetRE %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;ifnet:%s:recv_errors&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span>
            xnmetrics<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;NetSE %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;ifnet:%s:send_errors&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>vif<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> xnmetrics
&nbsp;
vifautodiscover<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2011/10/theia-open-source-netapp-monitoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual hosts using IPv6</title>
		<link>http://www.h1tman.com/2011/09/virtual-hosts-using-ipv6/</link>
		<comments>http://www.h1tman.com/2011/09/virtual-hosts-using-ipv6/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 18:22:05 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[virtual hosts]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/2011/09/virtual-hosts-using-ipv6/</guid>
		<description><![CDATA[Alright, so as we all know IPv4 is reaching the point of exhaustion and its time to start getting ready for IPv6. This can be very important for those of us who host web servers as many hosting providers will also be switching to assigning IPv6 addresses or NAT based Private IP&#8217;s in the Class [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, so as we all know IPv4 is reaching the point of exhaustion and its time to start getting ready for IPv6. This can be very important for those of us who host web servers as many hosting providers will also be switching to assigning IPv6 addresses or NAT based Private IP&#8217;s in the Class A space 10.0.0.0/8 for IPv4 or fc00::/7 for IPv6 (<a href="http://en.wikipedia.org/wiki/Private_network" target="_blank">Unique Local Address &#8220;ULA&#8221;</a>).</p>
<p>With that in mind how are you going to host your website on IPv6 address space? There are many web servers available as free Open Source software such as <a href="http://nginx.org/" target="_blank">nginx</a>, <a href="http://www.apache.org/" target="_blank">apache (httpd)</a>, and <a href="http://www.lighttpd.net/" target="_blank">lighthttpd</a>. For the context of this article we will focus on apache, and assume that you already have IPv6 connectivity and an understanding of virtual hosts.</p>
<h3>Getting Started</h3>
<p>Here are a few things that you are going to need to get started:</p>
<ul>
<li>Linux based server</li>
<li>Familiarity with Apache and the Linux command line (bash)</li>
<li>IPv6 address</li>
<li>Text editor</li>
</ul>
<p>As the transition to IPv6 progresses you should see your hosting provider assigning IPv6 addresses. At this time many hosting companies have not yet caught up to this as implementing IPv6 networking and connectivity can be extremely time consuming and expensive. Currently <a href="http://www.verio.com/web-hosting/ipv6-hosting/" target="_blank">Verio</a>, <a href="http://www.linode.com/" target="_blank">Linode</a>, and <a href="http://www.liquidweb.com/services/ipv6.html" target="_blank">Liquid Web</a> all provide web hosting with IPv6 connectivity.</p>
<h3>Networking</h3>
<p>Once you have confirmed that the network appliance your server is connected to has IPv6 capabilities, and your provider has assigned you an IPv6 address you can get started configuring your network interfaces. There are many ways this can be done but we will only cover binding an IPv6 address to an interface already serving traffic over IPv4.</p>
<p>First things first.. enable IPv6 networking by adding the following line to /etc/sysconfig/network on a redhat based Linux distribution.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">NETWORKING_IPV6</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>This is one of the files your init scripts consults with to identify what networking services to start. Now we can move on to configuring the interface. Mentioned previously we will be configuring a single interface to serve both IPv4 and IPv6 traffic. In this example we will be binding these addresses to eth0.</p>
<p>Here are the parameters we must edit:</p>
<ul>
<li>IPV6INIT &#8211; Accepts YES/NO and is used to determine if we should bring up IPv6</li>
<li>IPV6ADDR &#8211; The IPv6 Address provided to you by your hosting company</li>
<li>IPV6_DEFAULTGW &#8211; The default gateway which should also be provided by your hosting company</li>
</ul>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">IPV6INIT</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">IPV6ADDR</span>=<span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17
<span style="color: #007800;">IPV6_DEFAULTGW</span>=fe80::<span style="color: #000000;">1</span></pre></div></div>

<p>At this point you should be ready to restart networking and test connectivity. This will differ slightly from some of the tools we use for testing IPv4. For example if you wanted to run a simple ping command you would use ping6 or a third party site such as <a href="http://www.subnetonline.com/pages/ipv6-network-tools/online-ipv6-ping.php" target="_blank">SubnetOnline</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>networking restart</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PING <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">32</span> data bytes
<span style="color: #000000;">40</span> bytes from <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">245</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">176</span> ms
<span style="color: #000000;">40</span> bytes from <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">245</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">144</span> ms
<span style="color: #000000;">40</span> bytes from <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">2</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">245</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">144</span> ms
<span style="color: #000000;">40</span> bytes from <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">3</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">245</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">144</span> ms
&nbsp;
<span style="color: #660033;">---</span> <span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17 <span style="color: #c20cb9; font-weight: bold;">ping</span> statistics <span style="color: #660033;">---</span>
<span style="color: #000000;">4</span> packets transmitted, <span style="color: #000000;">4</span> received, <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> packet loss, <span style="color: #000000; font-weight: bold;">time</span> 3010ms
rtt min<span style="color: #000000; font-weight: bold;">/</span>avg<span style="color: #000000; font-weight: bold;">/</span>max<span style="color: #000000; font-weight: bold;">/</span>mdev = <span style="color: #000000;">144.641</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">152.757</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">176.961</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">13.982</span> ms, pipe <span style="color: #000000;">2</span></pre></div></div>

<p>If a ping from your workstation does not work do not be alarmed.. your local network may not have IPv6 connectivity. If you should encounter any issues up to this point you should consult with your hosting provider to ensure your interfaces are configured properly and you have the correct configuration.</p>
<h3>Virtual Hosts</h3>
<p>Now that we have networking configured we can move on to configuring our <a href="http://en.wikipedia.org/wiki/Virtual_hosting" target="_blank">virtual hosts</a>. Virtual hosts are pretty easy to configure, however there are multiple steps. First and foremost you must configure apache to listen on your IPv6 interface. This is pretty easy to do however there is an important syntax change that you need to be aware of..</p>
<p>When configuring apache to listen on an IPv4 interface using port 80 you would typically use the following statement in httpd.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Listen 127.0.0.1:<span style="color: #000000;">80</span></pre></div></div>

<p>This changes very slightly but the IPv6 address requires brackets around it like in this example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Listen <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000;">80</span></pre></div></div>

<p>Below is an example virtual host configuration. This is pretty standard and does not provide any cache control or any additional features. Here is a break down on the configuration:</p>
<ul>
<li>ServerName &#8211; this will be the name of your virtual host or domain name</li>
<li>ServerAlias &#8211; aliases work similar to ServerName, however they are used to redirect a URL to the content specified in DocumentRoot</li>
<li>DocumentRoot &#8211; this is where you store your website content</li>
<li>ErrorLog &#8211; pretty self explanatory however any errors that may be generated will be logged here. (404, 500 etc..)</li>
<li>CustomLog &#8211; CustomLog provides you with an &#8216;all in one&#8217; solution for logging HTTP requests. It specifies the path to the log file as well as the log format. For more details on how to customize this please refer to the apache docs <a href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html" target="_blank">here</a>.</li>
<li>Options -Indexes &#8211; this disables directory listings on folder&#8217;s that do not have an index page.</li>
<li>AllowOverride &#8211; this directive is what tells apache to ignore or utilize the contents of a .htaccess file</li>
<li>Order &#8211; Order provides a very basic means of access control.</li>
<li>Allow &#8211; apache docs describe this best.. &#8220;Controls which hosts can access an area of the server&#8221;</li>
<li>Typically most people append their virtual host configuration to the httpd.conf file, however it can be stored elsewhere as httpd.conf provides an include directory. For example you could do something like..

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>vhost.d
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Include vhost.d/*.conf&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>httpd.conf</pre></div></div>

<p>This would provide you with the ability to create a file such as &#8220;/etc/httpd/vhost.d/mydomain.conf&#8221; where you would store your virtual host configuration. Doing this keeps httpd.conf clean, and also makes things a bit easier to manage.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    ServerName  www.yoursite.com
    ServerAlias www.yoursite.com yoursite.com
    UseCanonicalName Off
    DocumentRoot    <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>yoursite<span style="color: #000000; font-weight: bold;">/</span>public_html
    ErrorLog    <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>yoursite-error_log
    CustomLog   <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>yoursite-access_log combined
&nbsp;
        Options <span style="color: #660033;">-Indexes</span> FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all</pre></div></div>

<p>Now that your virtual hosts are configured its time to restart apache and start hosting your website. I hope whoever reads this finds it helpful. If you have any questions please feel free to comment below.<br />
<!-- IPv6-test.com button BEGIN --><br />
<a href="http://ipv6-test.com/validate.php?url=referer"><img title="ipv6 ready" src="http://ipv6-test.com/button-ipv6-small.png" alt="ipv6 ready" border="0" /></a><br />
<!-- IPv6-test.com button END --></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2011/09/virtual-hosts-using-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datacenter Migration, Relocation, and New Ventures</title>
		<link>http://www.h1tman.com/2011/09/datacenter-migration-relocation-and-new-ventures/</link>
		<comments>http://www.h1tman.com/2011/09/datacenter-migration-relocation-and-new-ventures/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 21:01:03 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[datacenter]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[ning]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=583</guid>
		<description><![CDATA[As many of you know I have decided to shift gears and accept a position with Silicon Valley startup Ning. With this transition I am migrating all  of my websites back over to linode. As a previous customer of linode I know that their service is reliable and they provide all of the features that [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you know I have decided to shift gears and accept a position with Silicon Valley startup Ning. With this transition I am migrating all  of my websites back over to linode. As a previous customer of linode I know that their service is reliable and they provide all of the features that an experienced I.T. professional is looking for including IPv6.</p>
<p>Over the next few day&#8217;s I will be updating my servers to have IPv6 compatibility and networking which will give me the ability to host this blog in IPv4 as well as IPv6 address space. Following these updates I will document some of the changes required to start using IPv6 as well as how to configure apache virtual hosts to serve traffic over an IPv6 interface.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>www ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dig AAAA h1tman.com</span>
&nbsp;
; <span style="color: #000000; font-weight: bold;">&lt;&lt;&gt;&gt;</span> DiG 9.7.0-P2-RedHat-9.7.0-<span style="color: #000000;">5</span>.P2.el6_0.1 <span style="color: #000000; font-weight: bold;">&lt;&lt;&gt;&gt;</span> AAAA h1tman.com
<span style="color: #000000; font-weight: bold;">;;</span> global options: +cmd
<span style="color: #000000; font-weight: bold;">;;</span> Got answer:
<span style="color: #000000; font-weight: bold;">;;</span> -<span style="color: #000000; font-weight: bold;">&gt;&gt;</span>HEADER<span style="color: #000000; font-weight: bold;">&lt;&lt;</span>- opcode: QUERY, status: NOERROR, <span style="color: #c20cb9; font-weight: bold;">id</span>: <span style="color: #000000;">3229</span>
<span style="color: #000000; font-weight: bold;">;;</span> flags: qr rd ra; QUERY: <span style="color: #000000;">1</span>, ANSWER: <span style="color: #000000;">1</span>, AUTHORITY: <span style="color: #000000;">2</span>, ADDITIONAL: <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span> QUESTION SECTION:
;h1tman.com.			IN	AAAA
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span> ANSWER SECTION:
h1tman.com.		<span style="color: #000000;">3600</span>	IN	AAAA	<span style="color: #000000;">2600</span>:3c01::f03c:91ff:fe93:eb17
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span> AUTHORITY SECTION:
h1tman.com.		<span style="color: #000000;">3600</span>	IN	NS	ns23.domaincontrol.com.
h1tman.com.		<span style="color: #000000;">3600</span>	IN	NS	ns24.domaincontrol.com.
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span> Query <span style="color: #000000; font-weight: bold;">time</span>: <span style="color: #000000;">235</span> msec
<span style="color: #000000; font-weight: bold;">;;</span> SERVER: 74.207.241.5<span style="color: #666666; font-style: italic;">#53(74.207.241.5)</span>
<span style="color: #000000; font-weight: bold;">;;</span> WHEN: Fri Sep  <span style="color: #000000;">2</span> 09:<span style="color: #000000;">53</span>:03 <span style="color: #000000;">2011</span>
<span style="color: #000000; font-weight: bold;">;;</span> MSG SIZE  rcvd: <span style="color: #000000;">108</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>www ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p>So why the change of pace? Well, thats a complicated question to ask but here are some highlights.. Ning employ&#8217;s some of the most technical, and well known people in the industry. With that in mind (and a new environment) this provides an excellent opportunity to learn new technologies, expand upon experience, learn new way&#8217;s of implementing, deploying, and maintaining software and infrastructure as well as meeting new people. </p>
<p>By now you may have asked yourself &#8220;what does &#8216;ning&#8217; do?&#8221;. Well, basically we provide a social networking platform that empowers the non-technical bloggers, businesses, and people who enjoy social networking an easy platform to design and maintain their own social network without the overhead of an IT department and developers. Bored and got time to surf the net? Visit our site: <a href="http://www.ning.com/">http://www.ning.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2011/09/datacenter-migration-relocation-and-new-ventures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Load Balancing with HAProxy and Apache</title>
		<link>http://www.h1tman.com/2011/03/load-balancing-with-haproxy-and-apache/</link>
		<comments>http://www.h1tman.com/2011/03/load-balancing-with-haproxy-and-apache/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 14:13:44 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[failover]]></category>
		<category><![CDATA[haproxy]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mysqld]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=531</guid>
		<description><![CDATA[What you need to know: 1. Familiar with linux text editors 2. Have a basic understanding of load balancing 3. Familiarity with Apache, MySQL, and rsync 4. The ability to create at least 4 virtual machines What does this set-up provide? This set-up will provide you with some very basic failover at the web servers [...]]]></description>
			<content:encoded><![CDATA[<p><b><br />
<h3>What you need to know:</h3>
<p></b><br />
1. Familiar with linux text editors<br />
2. Have a basic understanding of load balancing<br />
3. Familiarity with Apache, MySQL, and rsync<br />
4. The ability to create at least 4 virtual machines</p>
<p><b><br />
<h3>What does this set-up provide?</h3>
<p></b><br />
This set-up will provide you with some very basic failover at the web servers by using a load balancer. Keep in mind I will not be discussing HA at the load balancer level so you will still have a single point of failure with this guide, as it is only intended to provide some fundamental knowledge on how to set-up a replicated and load balanced pair of web servers.</p>
<p><b><br />
<h3>Why is this useful?</h3>
<p></b><br />
If your website needs some redundancy as well as the need to be able to handle large volumes of traffic then this will give you a good starting point. This solution will not fit every website&#8217;s needs so you must design to fit your application, performance requirements, disaster recovery plan, redundancy and scalability. This guide will however provide you with the basics to configure a small web server farm that will handle most &#8216;run of the mill&#8217; websites.</p>
<p><b><br />
<h3>Getting Started..</h3>
<p></b><br />
First and foremost we need four virtual machines running CentOS 5.5. Just about any hypervisor will work. If you do not have one readily available you can download VMWare Server, or Virtual box for free. Once your hypervisor is installed you need to proceed with creating your virtual machines. These will not require much disk space for this &#8220;how to&#8221;. Creating these virtual machines with 256MB RAM and 10GB of disk space should be sufficient for a testing environment (not for a production website). When creating these virtual machines keep in mind to set their host names respective to their roles for easy identification. For example:</p>
<p>Web Server 1 &#8211; WWW1<br />
Web Server 2 &#8211; WWW2<br />
Load Balancer &#8211; LB1<br />
Database Server &#8211; DB1</p>
<p>Feel free to set these to whatever you would like as long as you can remember their roles. For this example we will use the host names listed above. Once you have all virtual machines installed go ahead and ensure they have network connectivity and that they are up to date. To verify this run the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum clean all
yum <span style="color: #660033;">-y</span> update
yum <span style="color: #660033;">-y</span> upgrade</pre></div></div>

<p>Now that we have our environment ready to go we can get started with configuring the virtual machines.</p>
<p><b><br />
<h3>LB1 &#8211; HAProxy Load Balancer</h3>
<p></b><br />
Before we get started with the installation of the load balancer we need to ensure that we have the correct YUM repositories installed. With that said the only additional repository that we will need is EPEL. Here is a link for the EPEL repository that will outline all the details for the repository: http://fedoraproject.org/wiki/EPEL</p>
<p>To install the EPEL repository simply run the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-Uvh</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedoraproject.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">5</span>-<span style="color: #000000;">4</span>.noarch.rpm</pre></div></div>

<p>Now that our repository is ready go ahead and install HAProxy:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> haproxy</pre></div></div>

<p>Now comes the configuration. Fortunately HAProxy is fairly simple to configure however we need some basic information before we can proceed.</p>
<p>1. eth0 IP of the load balancer<br />
2. eth0 IP of both web servers</p>
<p>Once you have this information you can go ahead and edit the configuration file located at /etc/haproxy/haproxy.cfg</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">global
&nbsp;
    <span style="color: #666666; font-style: italic;">#logging is designed to work with syslog facility's due to chrooted environment</span>
    <span style="color: #666666; font-style: italic;">#log loghost    local0 info - By default this is commented out</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#chroot directory</span>
    <span style="color: #c20cb9; font-weight: bold;">chroot</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>haproxy
&nbsp;
    <span style="color: #666666; font-style: italic;">#user/group id</span>
    uid <span style="color: #000000;">99</span>
    gid <span style="color: #000000;">99</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#running mode</span>
    daemon
defaults
&nbsp;
    <span style="color: #666666; font-style: italic;">#HTTP Log format</span>
    mode http
&nbsp;
    <span style="color: #666666; font-style: italic;">#number of connection retries for the session</span>
    retries <span style="color: #000000;">3</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#try another webhead if retry fails</span>
    option redispatch
&nbsp;
    <span style="color: #666666; font-style: italic;">#session settings - max connections, and session timeout values</span>
    maxconn <span style="color: #000000;">10000</span>
    contimeout <span style="color: #000000;">10000</span>
    clitimeout <span style="color: #000000;">50000</span>
    srvtimeout <span style="color: #000000;">50000</span>
&nbsp;
listen webfarm 127.0.0.5:<span style="color: #000000;">80</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#HTTP Log format</span>
    mode http
    <span style="color: #666666; font-style: italic;">#stats uri /haproxy</span>
    stats uri <span style="color: #000000; font-weight: bold;">/</span>haproxy
&nbsp;
    <span style="color: #666666; font-style: italic;">#balance roundrobin - Typical Round Robin</span>
    <span style="color: #666666; font-style: italic;">#balance leastconn - Least Connections</span>
    <span style="color: #666666; font-style: italic;">#balance static-rr - Static Round Robin - Same as round robin, but weights have no effect</span>
    balance roundrobin
&nbsp;
    <span style="color: #666666; font-style: italic;">#cookie &lt;COOKIENAME&gt; prefix - Used for cookie-based persistence</span>
    cookie webpool insert
&nbsp;
    <span style="color: #666666; font-style: italic;">#option httpclose - http connection closing</span>
    option  httpclose
&nbsp;
    <span style="color: #666666; font-style: italic;">#option forwardfor - best stated as &quot;Enable insertion of the X-Forwarded-For header to requests sent to the web heads&quot; aka send EU IP</span>
    option forwardfor
&nbsp;
    <span style="color: #666666; font-style: italic;">#Web Servers (Examples)</span>
    server WWW1 127.0.0.1:<span style="color: #000000;">80</span> check port <span style="color: #000000;">80</span> <span style="color: #666666; font-style: italic;"># Active in rotation   </span>
    server WWW2 127.0.0.2:<span style="color: #000000;">80</span> check port <span style="color: #000000;">80</span> <span style="color: #666666; font-style: italic;"># Active in rotation</span></pre></div></div>

<p>HAProxy is now configured. As you can see this was a pretty simple process, however there are a few things left to do.. </p>
<p>1. Ensure that HAProxy starts on reboot</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">chkconfig haproxy on</pre></div></div>

<p>2. Configure iptables to allow HTTP access to port 80</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>3. Start the service</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>haproxy start</pre></div></div>

<p>At this point you should be able to open a browser and view the HAProxy status page. If your eth0 IP address for your load balancer was 127.0.0.5 you could browse to http://127.0.0.5/haproxy to view the current status.</p>
<p><b><br />
<h3>WWW1/2 &#8211; Apache Web Servers</h3>
<p></b><br />
This part isnt much more difficult than setting up your load balancer however the apache configuration file syntax is a little more cryptic. So first things first.. Install apache and configure iptables.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> httpd</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">chkconfig httpd on</pre></div></div>

<p>This will provide you with a basic installation of apache that will work for the purpose of this example. At the bottom of this portion I will provide an example of a more advanced configuration file for use with virtual hosts. As with our load balancer we will need to configure iptables to allow HTTP traffic access to port 80.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>By default without any configuration changes apache sets your document root to /var/www/html. This is where you will store your website content. This can be changed to fit your needs when creating virtual hosts, or for security concerns. To create an example web page simply run the following command. This will allow us to ensure the load balancer is working later on.</p>
<p>On WWW1:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;WWW1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>index.html</pre></div></div>

<p>On WWW2:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;WWW2&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>index.html</pre></div></div>

<p>Now that you have installed a fake temporary website we should be able to start apache and test our load balancer. Starting apache is very similar to starting HAProxy. Simply run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>httpd start</pre></div></div>

<p>If you type http://127.0.0.5/ into your browser you should be greeted by one of your web servers with a response of &#8220;WWW1&#8243; or &#8220;WWW2&#8243; on the screen. If you press F5 on your keyboard (command + R for mac) to refresh the page multiple times you should see the text change back and forth. This is because we configured the load balancer with &#8217;round robin&#8217; which sends one request to WWW1 the second to WWW2 the third to WWW1 and so on. At this point once you verify your load balancer worked as expected you can configure a basic cron job using rsync to replicate your data.</p>
<p>In this example we are only using basic one way replication provided by rsync. In order to do this we need to setup a key pair for our web servers. Simple way to do this is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>WWW1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa <span style="color: #660033;">-b</span> <span style="color: #000000;">2048</span></pre></div></div>

<p>Once you have saved the key you need to copy the public key over to WWW2 in /root/.ssh/authorized_keys. This file may not exist so you will need to create it. After setting our public key on WWW2 verify you can login as the root user from WWW1 to WWW2. If this is successful add the following to /etc/crontab:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">05 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> rsync <span style="color: #660033;">-aPSv</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'ssh'</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html 127.0.0.2:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html</pre></div></div>

<p>Make sure you edit the IP addresses listed in this article to be the same as those of your virtual machines. The ones used here will not work and are only for examples. At this point we have set up and configured our load balancer as well as our web servers and replication. To test replication simply login to WWW1 and run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>text.txt</pre></div></div>

<p> Give it a few minutes and you should see this file show up on WWW2. If all is well then move on to the next section to configure your database server.</p>
<p>Example Virtual Host:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost 127.0.0.2:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	ServerName	example.com
	ServerAlias	example.com
	UseCanonicalName Off
	DocumentRoot	<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>public_html<span style="color: #000000; font-weight: bold;">/</span>example.com
	ErrorLog	<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>example.com-error_log
	CustomLog	<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>example.com-access_log combined
	<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>public_html<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">&gt;</span>
		Options Indexes FollowSymLinks
		IndexOptions FancyIndexing
		AllowOverride All
		Order allow,deny
		Allow from all
	<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
		php_admin_value open_basedir <span style="color: #ff0000;">&quot;/home/user/public_html/example.com:/tmp&quot;</span>
		php_admin_flag safe_mode On
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><b><br />
<h3>DB1 &#8211; MySQL Database Server</h3>
<p></b><br />
This section is going to be pretty brief as the exact configuration for MySQL is dependant on your application. With that in mind here we go.. </p>
<p>First and foremost install the service:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql mysql-server</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">chkconfig mysqld on</pre></div></div>

<p>Once installed you can proceed with any configuration changes in /etc/my.cnf or simply start the service as is by running:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysqld start</pre></div></div>

<p>As with apache and HAProxy we must configure the firewall to be able to communicate with our web servers, however this time not on port 80.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">3306</span> <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>And thats it! If you are planning on using a database driven application such as wordpress you will want to set your wp-config.php to point to the eth0 IP of your DB1 server during the configuration portion of the wordpress setup. </p>
<p>I hope this helps anyone looking for a similar configuration, as well as provide some ideas on how to set up something like this. If you have questions please feel free to ask by posting here!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2011/03/load-balancing-with-haproxy-and-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downtime &#8211; memcached revised</title>
		<link>http://www.h1tman.com/2010/11/downtime-memcached-revised/</link>
		<comments>http://www.h1tman.com/2010/11/downtime-memcached-revised/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 02:42:58 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=487</guid>
		<description><![CDATA[Today&#8217;s downtime was unfortunately caused by memcached being overloaded. After tracking down the issue I figured that my configuration could use a slight overhaul in order to prevent future issues like today&#8217;s. The basic resolution was to simply restart the service which brought the site back online. Simple enough, however I feel that if memcached [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s downtime was unfortunately caused by memcached being overloaded. After tracking down the issue I figured that my configuration could use a slight overhaul in order to prevent future issues like today&#8217;s. The basic resolution was to simply restart the service which brought the site back online. </p>
<p>Simple enough, however I feel that if memcached cant handle the current load then there is probably a reason and it should be revised. </p>
<p><strong>Initial Configuration:</strong><br />
Database Server<br />
- MySQL 5.0.77<br />
- Memcached 1.4.5</p>
<p>Memcached(defaults):<br />
64MB Cache<br />
1024 Max Connections<br />
Listening on private IP</p>
<p>As you can see here this is not optimal for a fairly high traffic website. Defaults are in most cases not the best for use in production unless your application can perform the way its expected. Additionally there is no fault tolerance in the event that memcached should fail, and since the service was running on a production database server it was robbing a minimal amount of memory from MySQL.</p>
<p>While troubleshooting the issue I found that my resource usage was relatively low on my web servers which provided me with some room to disable memcached on my database server, and deploy local instances on the web servers themselves. This not only frees up network / memory usage on my database server, but it also allows me to re-configure the services to allow for a larger cache per server. Another performance impacting improvement by moving the instances locally to the web servers is reduction in latency. Theoretically since the cache is now stored on the web servers, they should be able to access the data much faster as well as not have to worry about the network.</p>
<p><strong>New Configuration:</strong><br />
Web Servers:<br />
- Apache 2.2.3<br />
- Memcached 1.4.5</p>
<p>Memcached(defaults):<br />
128MB Cache<br />
1024 Max Connections<br />
Listening on 127.0.0.1</p>
<p>Now each of the web servers has a local instance of memcached running and the overall response time seems much quicker. However even with this configuration there is no fault tolerance for memcached but the likeliness of it becoming overloaded within this configuration is much lower. Watchdog or some other type of monitoring software such as Nagios could also be a viable option for checking and automatically responding should memcached fail. Unfortunately I do not know of any open source projects at this time which allow for this automation, though I do not think it would be difficult to write a script for this. </p>
<p>Memcached Configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PORT</span>=<span style="color: #000000;">11211</span>
<span style="color: #007800;">USER</span>=memcached
<span style="color: #007800;">MAXCONN</span>=<span style="color: #000000;">1024</span>
<span style="color: #007800;">CACHESIZE</span>=<span style="color: #000000;">128</span></pre></div></div>

<p>If you are considering using memcached just keep in mind that it currently has no form of authentication. This can be particularly troublesome if you do not take the proper security measures to prevent unauthorized access. This can be easily done by blocking or restricting access to the port.</p>
<p>iptables example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># define your chain</span>
:MEMCACHE - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>:<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># specify protocol and port for the chain</span>
<span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp              <span style="color: #660033;">--dport</span> <span style="color: #000000;">11211</span>        <span style="color: #660033;">-j</span> MEMCACHE
&nbsp;
<span style="color: #666666; font-style: italic;"># apply rules to the chain</span>
<span style="color: #660033;">-A</span> MEMCACHE <span style="color: #660033;">-s</span> 10.176.12.18<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #660033;">-A</span> MEMCACHE <span style="color: #660033;">-s</span> 10.176.12.17<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #660033;">-A</span> MEMCACHE <span style="color: #660033;">-j</span> DROP</pre></div></div>

<p>As shown in the iptables example above, the final rule for the MEMCACHE chain is to drop all traffic. This allows you to block all access to the specified port except for those that you explicitly allow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/11/downtime-memcached-revised/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RHCT expires with RHEL 6</title>
		<link>http://www.h1tman.com/2010/11/rhct-expires-with-rhel-6/</link>
		<comments>http://www.h1tman.com/2010/11/rhct-expires-with-rhel-6/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 14:00:37 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[rhcsa]]></category>
		<category><![CDATA[rhct]]></category>
		<category><![CDATA[RHEL 6]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=475</guid>
		<description><![CDATA[So I received an email this morning from RedHat explaining that RHEL 6 has been announced and with it comes the discontinuation of the RHCT exam which they are replacing with the RHCSA (RedHat Certified Systems Administrator). Fortunately this does not invalidate the RHCT because RedHat feels that the similarities between the two exams are [...]]]></description>
			<content:encoded><![CDATA[<p>So I received an email this morning from RedHat explaining that RHEL 6 has been announced and with it comes the discontinuation of the RHCT exam which they are replacing with the RHCSA (RedHat Certified Systems Administrator). Fortunately this does not invalidate the RHCT because RedHat feels that the similarities between the two exams are so close that they are converting all existing RHCT&#8217;s over to RHCSA&#8217;s effective January 1st 2011. Here is the email from RedHat:</p>
<blockquote><p>Red Hat has announced general availability of Red Hat Enterprise<br />
Linux 6.  Effective with the release of version 6, we will<br />
no longer offer the Red Hat Certified Technician (RHCT) exam.<br />
We are launching a new certification, Red Hat Certified System<br />
Administrator (RHCSA) in its place.  You can read about this<br />
new program at</p>
<p>https://www.redhat.com/certification/rhcsa/</p>
<p>You will continue to retain your RHCT and it will still be<br />
possible to verify your certification at</p>
<p>https://www.redhat.com/training/certification/verify</p>
<p>In addition, because you earned RHCT on Red Hat Enterprise<br />
Linux 5, we will issue a Red Hat Enterprise Linux 5 RHCSA to<br />
you retroactively by January 1, 2011.  While there are some<br />
differences between RHCT and RHCSA, we believe that the common<br />
areas between them justify issuing this certification to you<br />
and hope that it proves useful to you and your career.</p>
<p>Please direct questions or comments to the certification team at</p>
<p>https://www.redhat.com/training/certification/comments.html</p>
<p>Best wishes!<br />
Red Hat Certification</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/11/rhct-expires-with-rhel-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>2010 OpenStack Summit &#8211; San Antonio TX</title>
		<link>http://www.h1tman.com/2010/11/2010-openstack-summit-san-antonio-tx/</link>
		<comments>http://www.h1tman.com/2010/11/2010-openstack-summit-san-antonio-tx/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 14:32:07 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[open source cloud]]></category>
		<category><![CDATA[openstack]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=464</guid>
		<description><![CDATA[The second OpenStack summit is under way. So far the discussions appear to be very detailed, and have lots of contributors. There was quite a bit of debate around IPv6; As of this writing the Austin release of nova does not currently provide IPv6 support, however the Bexar release should contain &#8220;dual stack&#8221; which will [...]]]></description>
			<content:encoded><![CDATA[<p>The second OpenStack summit is under way. So far the discussions appear to be very detailed, and have lots of contributors. There was quite a bit of debate around IPv6; As of this writing the Austin release of nova does not currently provide IPv6 support, however the Bexar release should contain &#8220;dual stack&#8221; which will allow it to support both IPv4 and IPv6 addresses. This is a major step moving forward because of the well known IPv4 shortage. The faster we can implement a solid IPv6 solution within OpenStack the better. </p>
<p>All in all the summit is going well, and it seems we are going to be making good progress in the future releases. Below is some more information about the summit including the agenda, and registration links. Also keep in mind that OpenStack is an open source cloud computing platform which means that if you like to get your hands dirty and write some code, you can download it and hack away. The best part is that since its open source its free!</p>
<p>Agenda:<br />
11/09/10<br />
9:00 am  &#8211;  11:30 am	Day 1 Morning General Session<br />
12:00 pm  &#8211;  1:00 pm	Day 1 Lunch<br />
1:30 pm  &#8211;  4:30 pm	Day 1 Afternoon Business Session<br />
1:30 pm  &#8211;  4:30 pm	Day 1 Afternoon Developer Session<br />
6:00 pm  &#8211;  10:30 pm	Day 1 Evening Design Summit Reception<br />
Reception and tour at Rackspace Headquarters.<br />
Buses will depart from the Weston Centre lobby at 6:00pm.	  </p>
<p>11/10/10<br />
8:00 am  &#8211;  11:30 am	Day 2 Morning Business Session<br />
8:00 am  &#8211;  11:30 am	Day 2 Morning Developer Session<br />
12:00 pm  &#8211;  1:00 pm	Day 2 Lunch<br />
1:30 pm  &#8211;  4:30 pm	Day 2 Afternoon Business Session<br />
1:30 pm  &#8211;  4:30 pm	Day 2 Afternoon Developer Session<br />
4:30 pm  &#8211;  5:30 pm	Day 2- OpenStack Governance Discussion	  </p>
<p>11/11/10<br />
9:00 am  &#8211;  11:30 am	Day 3 Morning Doc Sprint<br />
9:00 am  &#8211;  12:00 pm	Day 3 Morning InstallFest<br />
12:00 pm  &#8211;  5:00 pm	Day 3 Afternoon OpenStack Developer Coding Experience<br />
12:00 pm  &#8211;  1:00 pm	Day 3 Lunch<br />
6:00 pm  &#8211;  10:00 pm	Day 3 Evening OpenStack Developer Party<br />
Buses will depart the Weston Centre lobby at 6:00pm.	  </p>
<p>11/12/10<br />
9:00 am  &#8211;  11:30 am	Day 4 Morning Doc Sprint<br />
9:00 am  &#8211;  12:00 pm	Day 4 Morning OpenStack Developer Coding Experience	  </p>
<p><a href="http://openstack.org/">http://openstack.org/</a></p>
<p><a href="http://openstack.org/register/">http://openstack.org/register/</a><br />
<a href="http://www.openstack.org/blog/2010/11/openstack-design-summit-day-1-pictures/">http://www.openstack.org/blog/2010/11/openstack-design-summit-day-1-pictures/</a></p>
<p><strong>Update:</strong><br />
Seems I was spotted in the following youtube video, while working on our OpenStack cluster for the install fest today.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/6zeO1ZM3-k8?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/6zeO1ZM3-k8?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p><strong>Update #2:</strong><br />
Pics of the openstack cluster: <a href="http://picasaweb.google.com/tim.galyean/2010OpenStackSummitSanAntonio#">http://picasaweb.google.com/tim.galyean/2010OpenStackSummitSanAntonio#</a><br />
<img src="http://lh3.ggpht.com/_gqwKcwoX3kA/TOLlomliY0I/AAAAAAAACTo/3l1rN4QIiRQ/76608_159599907408529_100000755638029_257233_8163800_n.jpg" alt="Openstack Cluster" width="640" height="385" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/11/2010-openstack-summit-san-antonio-tx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What is CloudFiles?</title>
		<link>http://www.h1tman.com/2010/09/what-is-cloudfiles/</link>
		<comments>http://www.h1tman.com/2010/09/what-is-cloudfiles/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 16:19:58 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[clouddrive]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[jungledisk]]></category>
		<category><![CDATA[object store]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=441</guid>
		<description><![CDATA[So I figured I would write this article as a response to some questions and feedback I received from my earlier post &#8220;CloudFiles curl example&#8221; which outline&#8217;s some example usage to interact with the CloudFiles public API as well as some example code. Ryan over at http://www.ryanuber.com/ brought up some interesting questions that I left [...]]]></description>
			<content:encoded><![CDATA[<p>So I figured I would write this article as a response to some questions and feedback I received from my earlier post &#8220;<a href="http://www.h1tman.com/2010/09/cloudfiles-curl-example/">CloudFiles curl example</a>&#8221; which outline&#8217;s some example usage to interact with the CloudFiles public API as well as some example code. </p>
<p>Ryan over at <a href="http://www.ryanuber.com/">http://www.ryanuber.com/</a> brought up some interesting questions that I left out in my original post based off of the assumption that the reading audience was already familiar with CloudFiles.</p>
<p>Here are two very important and relevant questions that he asked: </p>
<li>&#8220;What kind of output do you get?&#8221;</li>
<li>&#8220;What kinds of practical use you could put it to?&#8221;</li>
<p></p>
<p>Both of these are great questions to ask because without knowing the answer to these knowing how to use the API is a waste of time. So what is CloudFiles and what can I use it for? By definition CloudFiles is a &#8216;distributed object store&#8217;. It can be utilized to store any type of data that resides in some sort of a file format such as images, documents, videos, audio files, and so on.. </p>
<p>Some basic terms you need to know, and understand are objects and containers. Objects are your files regardless of their type (aka what you are going to store), and containers would be the folders where you store objects in within CloudFiles.</p>
<p>Now that you have a base understanding of what CloudFiles is, we can take a look at some of its practical uses. </p>
<li>Remote offsite backups</li>
<li>File level backups using <a href="http://www.rackspace.com/apps/backup_and_collaboration/online_file_storage/">CloudDrive</a></li>
<li>A portable storage solution using <a href="https://www.jungledisk.com/">JungleDisk</a></li>
<li>Content distribution using the built in CDN</li>
<p></p>
<p>These are just a few examples of what you can use CloudFiles for, however there are many uses beyond what I can list as companies all over use it in different ways to best fit their needs. Here is some technical information provided by Rackspace on how CloudFiles works, along with some basic explanation of the CDN and how it works <a href="http://www.rackspacecloud.com/cloud_hosting_products/files/technology">http://www.rackspacecloud.com/cloud_hosting_products/files/technology</a></p>
<p>Here are some additional resources for more information on ReST API&#8217;s and CDN Technology<br />
<a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">http://en.wikipedia.org/wiki/Representational_State_Transfer</a><br />
<a href="http://en.wikipedia.org/wiki/Content_delivery_network">http://en.wikipedia.org/wiki/Content_delivery_network</a></p>
<p>So now that you know what CloudFiles is, and why its API is important lets get into some use cases such as uploading a file via cURL.</p>
<p>Creating a new container:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ curl <span style="color: #660033;">-X</span> PUT <span style="color: #660033;">-d</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>container URL<span style="color: #000000; font-weight: bold;">&gt;/</span>container
<span style="color: #000000;">201</span> Created
<span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$</pre></div></div>

<p>Uploading an object:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ curl <span style="color: #660033;">-X</span> PUT <span style="color: #660033;">-T</span> cf-list.sh <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>container URL<span style="color: #000000; font-weight: bold;">&gt;/</span>container
<span style="color: #000000;">202</span> Accepted
The request is accepted <span style="color: #000000; font-weight: bold;">for</span> processing.
<span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$</pre></div></div>

<p>Deleting a container (destroy&#8217;s all its objects also):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ curl <span style="color: #660033;">-X</span> DELETE <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>container URL<span style="color: #000000; font-weight: bold;">&gt;/</span>container
<span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>www1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$</pre></div></div>

<p>As you can see the API performs many functions which can easily be implemented via a shell script using curl, or by utilizing the API bindings for PHP, Ruby, Python etc.. What you decide to use it for is entirely up to you as is the means in which integrate it into your applications. Hope this helps answer some of the questions I previously left out. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/09/what-is-cloudfiles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CloudFiles curl example</title>
		<link>http://www.h1tman.com/2010/09/cloudfiles-curl-example/</link>
		<comments>http://www.h1tman.com/2010/09/cloudfiles-curl-example/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 17:46:42 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[CloudFiles]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[ReST API]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=396</guid>
		<description><![CDATA[I wrote the following script to simplify accessing CloudFiles container&#8217;s by utilizing cURL. This example will show you how to list your containers as well as their contents, via the command line without having to login to your control panel. This can also be a useful example to provide you with a sample code base [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote the following script to simplify accessing CloudFiles container&#8217;s by utilizing cURL. This example will show you how to list your containers as well as their contents, via the command line without having to login to your control panel. This can also be a useful example to provide you with a sample code base to implement within your own infrastructure.</p>
<p>CloudFiles uses a a &#8220;ReST&#8221; API which allow&#8217;s you to interact with it in a variety of ways by using curl, PHP, Python, and Ruby. This particular script was written in bash so that I could utilize it from a shell, however the same principals can be adapted to the other technologies as the API will interact with them in the same manner. So how does it work?</p>
<p>First the API expects a username and a password to provide initial authentication. In this case you will pass your username and API key provided by the rackspace control panel located <a href="https://manage.rackspacecloud.com/" target="_blank">HERE</a>. Within the script you will see the following code which performs this action:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #800000;">${CURL}</span> <span style="color: #ff0000;">&quot;X-Auth-User: <span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Key: <span style="color: #007800;">${APIKEY}</span>&quot;</span> https:<span style="color: #000000; font-weight: bold;">//</span>auth.api.rackspacecloud.com<span style="color: #000000; font-weight: bold;">/</span>v1.0 <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> \ 
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Storage <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&lt;'</span> <span style="color: #ff0000;">'{print $2}'</span></pre></div></div>

<p>After passing your username and API key to the ReST API it will return you a Storage Token, and a Storage URL. These will be used to access your containers. Keep in mind that the Storage Token should not be saved within a database as the token does expire and is required for any operation which lists, uploads or deletes data. Once we have established authentication and we have our storage token we can then list and modify contents. In this example we are only listing contents, however modifying data is not much different. Here are a few examples on how to list container&#8217;s and their contents.</p>
<p>List all containers:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-s</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>container URL<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>List a containers contents:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-s</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>container URL<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>container<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Additional information on how to manipulate data can be found in the CloudFiles developers guide located on the rackspace website at the following URL:<br />
<a href="http://docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf" target="_blank">http://docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf</a><br />
You can also find various bindings for PHP, Python, Ruby, Java etc.. here:<br />
<a href="http://www.rackspacecloud.com/cloud_hosting_products/files/api" target="_blank">http://www.rackspacecloud.com/cloud_hosting_products/files/api</a></p>
<p>Now that we have covered the basics on how the script works, here are some example usage scenarios:</p>
<p>Basic container listing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$.<span style="color: #000000; font-weight: bold;">/</span>cf-list.sh USERNAME APIKEY</pre></div></div>

<p>Container listing with verbosity(outputs to a log file):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$.<span style="color: #000000; font-weight: bold;">/</span>cf-list.sh USERNAME APIKEY <span style="color: #000000;">1</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># File:         cf-list.sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Written by:   Tim Galyean</span>
<span style="color: #666666; font-style: italic;"># Date:         8/4/2010</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">##################################################</span>
&nbsp;
<span style="color: #007800;">USER</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span>
<span style="color: #007800;">APIKEY</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${2}</span>&quot;</span>
<span style="color: #007800;">DEBUG</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${3}</span>&quot;</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;cflist.log&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> f_exec<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${DEBUG}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># setting debug to 1 allows you to see full HTTP headers</span>
        <span style="color: #666666; font-style: italic;"># using this option will redirect the output to cflist.log</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;redirecting verbose output to <span style="color: #007800;">${LOG}</span>&quot;</span>
        <span style="color: #007800;">CURL</span>=<span style="color: #ff0000;">&quot;curl -v -H&quot;</span>
        f_grabauthtoken <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${LOG}</span>
        f_list <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span><span style="color: #800000;">${LOG}</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># this url can be used to parse your containers and their contents</span>
        <span style="color: #666666; font-style: italic;"># Example: curl -s -H &quot;X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX&quot; &lt;container URL&gt;/&lt;container&gt;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;curl -s -H <span style="color: #000099; font-weight: bold;">\&quot;</span>X-Auth-Token: <span style="color: #007800;">${STORAGETOKEN}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #007800;">$STORAGEURL</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #666666; font-style: italic;"># without using debug this script will just print your containers to stdout</span>
        <span style="color: #007800;">CURL</span>=<span style="color: #ff0000;">&quot;curl -s -H&quot;</span>
        f_grabauthtoken
        f_list
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Grab API Authentication Token, and Storage URL</span>
<span style="color: #000000; font-weight: bold;">function</span> f_grabauthtoken<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># Establish initial authentication</span>
    <span style="color: #800000;">${CURL}</span> <span style="color: #ff0000;">&quot;X-Auth-User: <span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Key: <span style="color: #007800;">${APIKEY}</span>&quot;</span> https:<span style="color: #000000; font-weight: bold;">//</span>auth.api.rackspacecloud.com<span style="color: #000000; font-weight: bold;">/</span>v1.0 <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Storage <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&lt;'</span> <span style="color: #ff0000;">'{print $2}'</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Parse storage token to be used as an authentication key</span>
    <span style="color: #007800;">STORAGETOKEN</span>=<span style="color: #000000; font-weight: bold;">`</span>curl <span style="color: #660033;">-v</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-User: <span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Key: <span style="color: #007800;">${APIKEY}</span>&quot;</span> https:<span style="color: #000000; font-weight: bold;">//</span>auth.api.rackspacecloud.com<span style="color: #000000; font-weight: bold;">/</span>v1.0 <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> \
    <span style="color: #c20cb9; font-weight: bold;">grep</span> Storage <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&lt;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Token <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'\r'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Parse the storage URL which will be the location of your containers</span>
    <span style="color: #007800;">STORAGEURL</span>=<span style="color: #000000; font-weight: bold;">`</span>curl <span style="color: #660033;">-v</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-User: <span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #660033;">-H</span> <span style="color: #ff0000;">&quot;X-Auth-Key: <span style="color: #007800;">${APIKEY}</span>&quot;</span> https:<span style="color: #000000; font-weight: bold;">//</span>auth.api.rackspacecloud.com<span style="color: #000000; font-weight: bold;">/</span>v1.0 <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> \
    <span style="color: #c20cb9; font-weight: bold;">grep</span> Storage <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&lt;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Url <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>   
&nbsp;
<span style="color: #666666; font-style: italic;"># List Containers</span>
<span style="color: #000000; font-weight: bold;">function</span> f_list<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #800000;">${STORAGETOKEN}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># This sends the API your token and storage url</span>
        <span style="color: #666666; font-style: italic;"># the API will return your container listing</span>
        <span style="color: #800000;">${CURL}</span> <span style="color: #ff0000;">&quot;X-Auth-Token: <span style="color: #007800;">${STORAGETOKEN}</span>&quot;</span> <span style="color: #007800;">$STORAGEURL</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Please authenticate first&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Usage instructions</span>
<span style="color: #000000; font-weight: bold;">function</span> f_verify<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># basic usage instructions</span>
    <span style="color: #666666; font-style: italic;"># to enable debugging use: ./cf-list.sh &lt;username&gt; &lt;apikey&gt; 1</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${APIKEY}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: ./cf-list.sh &lt;username&gt; &lt;apikey&gt;&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        f_exec
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
f_verify</pre></div></div>

<p>Download it here: <a href="http://www.h1tman.com/cf-list.sh">http://www.h1tman.com/cf-list.sh</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/09/cloudfiles-curl-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>monitoring url&#8217;s using ruby</title>
		<link>http://www.h1tman.com/2010/09/monitoring-website-urls-using-ruby/</link>
		<comments>http://www.h1tman.com/2010/09/monitoring-website-urls-using-ruby/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 00:33:49 +0000</pubDate>
		<dc:creator>Tim Galyean</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[logger]]></category>
		<category><![CDATA[url monitoring]]></category>
		<category><![CDATA[website monitor]]></category>

		<guid isPermaLink="false">http://www.h1tman.com/?p=304</guid>
		<description><![CDATA[While there are plenty of URL monitor&#8217;s available to verify if your site is working or not, many of them cost money. I was recently debugging a monitoring issue and found that I needed a simple URL monitor which would return the HTTP response code only, and provide some basic logging as well so that [...]]]></description>
			<content:encoded><![CDATA[<p>While there are plenty of URL monitor&#8217;s available to verify if your site is working or not, many of them cost money. I was recently debugging a monitoring issue and found that I needed a simple URL monitor which would return the HTTP response code only, and provide some basic logging as well so that I wouldn&#8217;t have to sift through two day&#8217;s worth of shell output. Long story short this was a temporary solution and not one that I had any desire to spend money on so I threw together the following script.</p>
<p>I wrote it in ruby because I like its logger library which gives enough options and information to accomplish the task. Additionally ruby has network / http libraries built right into it without having to install any additional software, or hack together some curl command to accomplish this with bash. So here it is, feel free to modify or use it as you see fit. If you have any suggestions or feedback please leave a reply. Thanks</p>
<p><strong>Configuration:</strong><br />
Add to a cron job at any given interval. I set mine to just run every minute:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>h1tman ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ crontab <span style="color: #660033;">-l</span>
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> ruby ~<span style="color: #000000; font-weight: bold;">/</span>urlmon.rb www.h1tman.com
<span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>h1tman ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$</pre></div></div>

<p><strong>Basic Usage:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>h1tman ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ .<span style="color: #000000; font-weight: bold;">/</span>urlmon.rb domain.com
<span style="color: #7a0874; font-weight: bold;">&#91;</span>h1tman<span style="color: #000000; font-weight: bold;">@</span>h1tman ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ .<span style="color: #000000; font-weight: bold;">/</span>urlmon.rb www.domain.com</pre></div></div>

<p>Keep in mind that http:// is not required as the domain is appended to it within the script itself.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#008000; font-style:italic;"># File:         urlmon.rb</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;"># Written by:   Tim Galyean</span>
<span style="color:#008000; font-style:italic;"># Date:         9/2/2010</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'logger'</span>
<span style="color:#9966CC; font-weight:bold;">include</span> Net
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$LOG</span> = <span style="color:#CC00FF; font-weight:bold;">Logger</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'monitor.log'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
domain = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">if</span> domain == <span style="color:#0000FF; font-weight:bold;">nil</span>
    usage = <span style="color:#996600;">&quot;Usage: ./urlmon.rb domain.com&quot;</span>
    <span style="color:#ff6633; font-weight:bold;">$LOG</span>.<span style="color:#9900CC;">debug</span> usage
<span style="color:#9966CC; font-weight:bold;">elsif</span> domain != <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
        url = <span style="color:#CC00FF; font-weight:bold;">URI</span>::parse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;http://&quot;</span><span style="color:#006600; font-weight:bold;">+</span>domain.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        request = HTTP.<span style="color:#9900CC;">start</span><span style="color:#006600; font-weight:bold;">&#40;</span>url.<span style="color:#9900CC;">host</span>, url.<span style="color:#9900CC;">port</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>http<span style="color:#006600; font-weight:bold;">|</span>
            <span style="color:#9966CC; font-weight:bold;">begin</span>
                response = http.<span style="color:#9900CC;">request_get</span><span style="color:#006600; font-weight:bold;">&#40;</span>url.<span style="color:#9900CC;">request_uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>
                test = response.<span style="color:#9900CC;">code</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> response.<span style="color:#9900CC;">message</span>
                <span style="color:#ff6633; font-weight:bold;">$LOG</span>.<span style="color:#9900CC;">info</span> url.<span style="color:#9900CC;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> test
            <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Example log output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Logfile created on Sat Sep 04 00:38:53 +0000 2010 by logger.rb/1.5.2.9</span>
I, <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2010</span>-09-04T00:<span style="color: #000000;">38</span>:<span style="color: #000000;">53.794756</span> <span style="color: #666666; font-style: italic;">#12547]  INFO -- : http://google.com 301 Moved Permanently</span>
I, <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2010</span>-09-04T00:<span style="color: #000000;">38</span>:<span style="color: #000000;">58.264756</span> <span style="color: #666666; font-style: italic;">#12549]  INFO -- : http://www.google.com 200 OK</span></pre></div></div>

<p>Download it Here: <a href="http://www.h1tman.com/urlmon.rb">http://www.h1tman.com/urlmon.rb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.h1tman.com/2010/09/monitoring-website-urls-using-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

