<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Thomas Dudziak&#039;s Blog</title>
	<atom:link href="http://tomdzk.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tomdzk.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 04 Jan 2012 04:30:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tomdzk.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Thomas Dudziak&#039;s Blog</title>
		<link>http://tomdzk.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tomdzk.wordpress.com/osd.xml" title="Thomas Dudziak&#039;s Blog" />
	<atom:link rel='hub' href='http://tomdzk.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Storm &amp; Esper</title>
		<link>http://tomdzk.wordpress.com/2011/09/28/storm-esper/</link>
		<comments>http://tomdzk.wordpress.com/2011/09/28/storm-esper/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 04:12:36 +0000</pubDate>
		<dc:creator>tomdzk</dc:creator>
				<category><![CDATA[computers]]></category>

		<guid isPermaLink="false">http://tomdzk.wordpress.com/?p=93</guid>
		<description><![CDATA[At work, we recently started using Esper for realtime analytics, and so far we quite like Esper. It is a great tool at what it does &#8211; running queries continuously over data. The problem however then becomes how to get data into Esper. The recently released Storm could be one way to do that, so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=93&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.ning.com">work</a>, we recently started using <a href="https://github.com/ning/meteo">Esper for realtime analytics</a>, and so far we quite like Esper. It is a great tool at what it does &#8211; running queries continuously over data. The problem however then becomes how to get data into Esper. The recently released <a href="https://github.com/nathanmarz/storm">Storm</a> could be one way to do that, so I got curios and started playing around with it to see if it could be made to work with Esper. And it turns out, the integration is straightforward.</p>
<h3 id="some-storm-basics">Some Storm basics</h3>
<p>Storm has three basic concepts that are relevant in this context: streams, spouts, and bolts. At the core, Storm facilitates data transfer between spouts and bolts using streams of tuples.</p>
<p>Spouts are the basic data emitters, typically retrieving the data from outside of the Storm cluster. A simple example of this would be a spout that retrieves the tweet stream via the Twitter API and emits the tweets as a stream into the Storm cluster.</p>
<p>Bolts are data processors that receive one or more streams as input and potentially also emit (processed) data on one or more streams. In the twitter example, one could for instance imagine bolts that count the number of tweets per second, or detect the language of the tweet and reemit the tweets into per-language streams.</p>
<p>The data in the streams has a simple tuple form consisting of a fixed number of named values called fields. Storm does not care about the data types of the individual fields in the tuple as long as they can be serialized to the wire format (which is Thrift), whether via serializers provided by Storm or custom ones. Spouts and bolts need to declare the number of fields and their names for each of the tuples they are going to emit as part of the initial setup of the topology. This also means that the number of fields and their names are fixed for the duration of a Storm &#8216;session&#8217;.</p>
<h3 id="some-eper-basics">Some Eper basics</h3>
<p>Esper is, and I&#8217;m simplifying things quite a bit here, a processing engine for data streams that uses queries run on the data streams to processes them. Think of it as a way to run SQL-like queries on data that streams by. The queries run continuously and thus have a time or amount-of-data aspect to them. Continuing the twitter example from above, if we consider the never-ending stream of tweets as the data stream that Esper works with, then an Esper query could for instance return the number of tweets per second like so:</p>
<p><pre class="brush: plain;">
select count(*) as tps from Twitter.win:time_batch(1 sec)
</pre></p>
<p>The <code>time_batch</code> part in this example will direct Esper to apply the <code>count</code> function on 1-sec batches of events.</p>
<p>Esper data streams consist of structured data called events. The types of these events can be POJOs, maps, and other things. Events are typically registered with Esper in advance before submitting a query to Esper. This means that you have to tell Esper about which kind of event type you give it (java class, map, &#8230;) and which properties the event type has. For java classes, Esper can figure that out itself but for map events you need to tell Esper explicitly about the possible keys and the value data types. Fortunately, Esper is forgiving when it comes to the data types. You can tell it that you&#8217;ll give it Objects, and it will happily accept numbers in the actual data stream and perform numeric operations on them.</p>
<h3 id="how-to-combine-the-two">How to combine the two</h3>
<p>Storm&#8217;s tuples are quite similar to Esper&#8217;s map event types. The tuple field names map naturally to map keys and the field values to values for these keys. The tuple fields are not typed when they are defined, but that does not pose a big problem for us as we can simply tell Esper that they are of type <code>Object</code>. In addition, the fact that tuples have to be defined before a topology is run, makes it relatively easy for us to define the map event type in the setup phase.</p>
<p>I am going to use the twitter stream example from the <a href="https://github.com/nathanmarz/storm-starter">storm-starter</a> project to show how you can use Esper to count the number of tweets per second and also find the maximum number of retweets per 1 second interval. This is probably not of great practical use, but will show off some aspects of the Storm &#8211; Esper integration.</p>
<p>All the code is available on <a href="https://github.com/tomdz/storm-esper-experiment">GitHub</a>.</p>
<p>Let&#8217;s get started with the twitter spout, a slightly adapted version of the one from the storm-starter project:</p>
<p><pre class="brush: java;">
public class TwitterSpout implements IRichSpout, StatusListener {
    private static final long serialVersionUID = 1L;

    private final String username;
    private final String pwd;
    private transient BlockingQueue&lt;Status&gt; queue;
    private transient SpoutOutputCollector collector;
    private transient TwitterStream twitterStream;

    public TwitterSpout(String username, String pwd) {
        this.username = username;
        this.pwd = pwd;
    }

    @Override
    public boolean isDistributed() {
        return false;
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields(&quot;createdAt&quot;, &quot;retweetCount&quot;));
    }

    @Override
    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
        this.queue = new ArrayBlockingQueue&lt;Status&gt;(1000);
        this.collector = collector;

        Configuration twitterConf = new ConfigurationBuilder().setUser(username)
                                                              .setPassword(pwd)
                                                              .build();
        TwitterStreamFactory fact = new TwitterStreamFactory(twitterConf);

        twitterStream = fact.getInstance();
        twitterStream.addListener(this);
        twitterStream.sample();
    }

    @Override
    public void onStatus(Status status) {
        queue.offer(status);
    }

    @Override
    public void nextTuple() {
        Status value = queue.poll();
        if (value == null) {
            Utils.sleep(50);
        }
        else {
            collector.emit(tuple(value.getCreatedAt().getTime(),
                                 value.getRetweetCount()));            
        }
    }

    @Override
    public void close() {
        twitterStream.shutdown();
    }

    @Override
    public void ack(Object arg0) {}
    @Override
    public void fail(Object arg0) {}
    @Override
    public void onException(Exception ex) {}
    @Override
    public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {}
    @Override
    public void onTrackLimitationNotice(int numberOfLimitedStatuses) {}
    @Override
    public void onScrubGeo(long userId, long upToStatusId) {}
}
</pre></p>
<p>This defines a spout that emits a single stream of tuples with two fields, <code>createdAt</code> (a timestamp) and <code>retweetCount</code> (an integer).</p>
<p>You&#8217;ll notice that aside from the twitter username and password, all fields in the spout are marked as transient, and initialized in the open <code>method</code>. The reason for this is that Storm requires spouts and bolts to be serializable so it can move them to some node in the Storm cluster before starting the topology.</p>
<p>The Esper bolt itself is generic. You pass it esper statements and the names of the output fields which will be generated by these esper statements. The adapted <code>main</code> method for our Twitter example looks like this:</p>
<p><pre class="brush: java;">
public static void main(String[] args) {
    final String username = args[0];
    final String pwd = args[1];

    TopologyBuilder builder = new TopologyBuilder();
    TwitterSpout spout = new TwitterSpout(username, pwd);
    EsperBolt bolt = new EsperBolt(
        new Fields(&quot;tps&quot;, &quot;maxRetweets&quot;),
        &quot;select count(*) as tps, max(retweetCount) as maxRetweets from Storm.win:time_batch(1 sec)&quot;);

    builder.setSpout(1, spout);
    builder.setBolt(2, bolt).shuffleGrouping(1);

    Config conf = new Config();
    conf.setDebug(true);

    LocalCluster cluster = new LocalCluster();

    cluster.submitTopology(&quot;test&quot;, conf, builder.createTopology());
    Utils.sleep(10000);
    cluster.shutdown();
}
</pre></p>
<p>Note how the Esper statement returns <code>tps</code> and <code>maxRetweets</code> which are also declared as the two output fields for the bolt.</p>
<p>The bolt code itself (see the complete source code <a href="https://raw.github.com/tomdz/storm-esper-experiment/master/src/main/java/org/tomdz/storm/EsperBolt.java">here</a>) consists of three pieces. The setup part constructs map event types for each input stream and registers them with Esper (I omitted the Esper setup code):</p>
<p><pre class="brush: java;">
private void setupEventTypes(TopologyContext context, Configuration configuration) {
    Set&lt;GlobalStreamId&gt; sourceIds = context.getThisSources().keySet();
    singleEventType = (sourceIds.size() == 1);

    for (GlobalStreamId id : sourceIds) {
        Map&lt;String, Object&gt; props = new LinkedHashMap&lt;String, Object&gt;();

        setupEventTypeProperties(
            context.getComponentOutputFields(id.get_componentId(),
                                             id.get_streamId()),
                                             props);
        configuration.addEventType(getEventTypeName(id.get_componentId(),
                                                    id.get_streamId()),
                                                    props);
    }
}

private String getEventTypeName(int componentId, int streamId) {
    if (singleEventType) {
        return &quot;Storm&quot;;
    }
    else {
        return String.format(&quot;Storm_%d_%d&quot;, componentId, streamId);
    }
}

private void setupEventTypeProperties(Fields fields, Map&lt;String, Object&gt; properties){
    int numFields = fields.size();

    for (int idx = 0; idx &lt; numFields; idx++) {
        properties.put(fields.get(idx), Object.class);
    }
}
</pre></p>
<p>The field-to-property mapping is straightforward. It simply registers properties of type <code>Object</code> using the field names in the event type corresponding to the input stream. If the bolt only has a single input stream, then it registers a single event type called <code>Storm</code>. For multiple types, it uses the component id (id of the spout or bolt that the data comes from) and the stream id (spouts and bolts can emit multiple streams) to generate a name <code>Storm_{component id}_{stream id}</code>.</p>
<p>The second part is the transfer of data from Storm to Esper:</p>
<p><pre class="brush: java;">
@Override
public void execute(Tuple tuple) {
    String eventType = getEventTypeName(tuple.getSourceComponent(),
                                        tuple.getSourceStreamId());
    Map&lt;String, Object&gt; data = new HashMap&lt;String, Object&gt;();
    Fields fields = tuple.getFields();
    int numFields = fields.size();

    for (int idx = 0; idx &lt; numFields; idx++) {
        String name = fields.get(idx);
        Object value = tuple.getValue(idx);

        data.put(name, value);
    }

    runtime.sendEvent(data, eventType);
}
</pre></p>
<p>This method is called by Storm whenever a tuple from any of the connected streams is sent to the bolt. The code therefore first has to find the event type name corresponding to the tuple. Then it iterates over the fields in the tuple and puts the values into a map using the field names as the keys. Finally, it passes that map to Esper.</p>
<p>At this moment, Esper will route this map (the event) through the statements which in turn might produce new data that we need to hand back to Storm. For this purpose, the bolt registered itself as a listener for data emitted from any of the statements that we configured during the setup. Esper will then call back the <code>update</code> method on the bolt if one of the statements generated data. The <code>update</code> method will then basically perform the reverse operation of the <code>execute</code> method and convert the event data to a tuple:</p>
<p><pre class="brush: java;">
@Override
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
    if (newEvents != null) {
        for (EventBean newEvent : newEvents) {
            collector.emit(toTuple(newEvent));
        }
    }
}

private List&lt;Object&gt; toTuple(EventBean event) {
    int numFields = outputFields.size();
    List&lt;Object&gt; tuple = new ArrayList&lt;Object&gt;(numFields);

    for (int idx = 0; idx &lt; numFields; idx++) {
        tuple.add(event.get(outputFields.get(idx)));
    }
    return tuple;
}
</pre></p>
<p>The bolt currently has a few limitations that are worth noting:</p>
<ul>
<li>Event types are automatically named. It would be useful to define a mapping of component id and steam id to a name than can then be referenced in the esper queries.</li>
<li>Every Esper statement given to it is assumed to produce data that should be passed to Storm. If you want to route data within Esper then you should pass multiple statements as one statement string.</li>
<li>The bolt currently only supports one output stream. This is a bit annoying when used with multiple statements as the fields object for the output fields must be the union of all the statement&#8217;s generated values and so the bolt will likely emit partial tuples because the individual statements will probably generate data at different times.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tomdzk.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tomdzk.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tomdzk.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=93&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tomdzk.wordpress.com/2011/09/28/storm-esper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18039bff98071ad398b4301cfb0522b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tomdzk</media:title>
		</media:content>
	</item>
		<item>
		<title>Lion tweaks</title>
		<link>http://tomdzk.wordpress.com/2011/07/30/lion-tweaks/</link>
		<comments>http://tomdzk.wordpress.com/2011/07/30/lion-tweaks/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 21:30:40 +0000</pubDate>
		<dc:creator>tomdzk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tomdzk.wordpress.com/?p=80</guid>
		<description><![CDATA[This is a quick summary of all the tweaks handed down from generation to generation (aka found on the Internet), that I applied to a fresh Lion install to get it into a usable state. Turn firewall on Go to System Preferences -&#62; Security &#38; Privacy, then click the lock. Now you can start the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=80&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a quick summary of all the tweaks handed down from generation to generation (aka found on the Internet), that I applied to a fresh Lion install to get it into a usable state.</p>
<h1>Turn firewall on</h1>
<p>Go to <code>System Preferences</code> -&gt; <code>Security &amp; Privacy</code>, then click the lock. Now you can start the firewall via the <code>Start</code> button. Also, click on <code>Advanced...</code> and then check <code>Enable stealth mode</code>.</p>
<h1>Turn off Autocorrect</h1>
<p>Go to <code>System Preferences</code> &gt; <code>Language &amp; Text</code> &gt; <code>Text</code>, then uncheck <code>Correct spelling automatically</code>.</p>
<h1>Trackpad tweaks</h1>
<p>Go to <code>System Preferences</code> -&gt; <code>Trackpad</code>, then uncheck <code>Scroll direction: natural</code>.</p>
<h1>Terminal tweaks</h1>
<p>Start a new terminal, then open the preferences.</p>
<h2>Theme</h2>
<ul>
<li>Select <code>Pro</code>, then click <code>Default</code> at the bottom.</li>
<li>On the left, click <code>Change</code> next to font and select 14pt font size.</li>
<li>Check <code>Antialias text</code>.</li>
<li>Uncheck <code>Use bold fonts</code>.</li>
</ul>
<h2>Dimensions</h2>
<p>Go to the <code>Window tab</code>, then enter <code>120</code> in the <code>Columns</code> input field.</p>
<h2>Keybindings</h2>
<p>Go to the <code>Keyboard</code> tab. Select the first entry <code>control cursor left</code>, then click <code>Edit</code> at the bottom<br />
Delete the last three characters via the <code>Delete one character button</code>, then add a single <code>b</code> (the result should be <code>33b</code>). Do the same with <code>control cursor right</code> and <code>f</code> so that you get <code>33f</code>. These two changes give you <code>Control</code>+<code>Left cursor</code>/<code>Right cursor</code> for going to the previous/next word (quite useful for SSH, for instance).</p>
<p>Check <code>Use option as meta key</code>.</p>
<h2>Other stuff</h2>
<p>On the <code>Advanced</code> tab, uncheck <code>Audible bell</code> and possibly <code>Visual bell</code>.</p>
<h1>Use function keys instead of feature keys</h1>
<p>Go to <code>System Preferences</code> -&gt; <code>Keyboard</code>, then check <code>Use all F1, F2, etc. keys as standard function keys</code>.</p>
<h1>Re-enable key repeat</h1>
<p>In a terminal, enter this:</p>
<pre><code>defaults write -g ApplePressAndHoldEnabled -bool false </code></pre>
<p>Then go to <code>System Preferences</code> -&gt; <code>Keyboard</code>, then move the sliders for <code>Key Repeat</code> and <code>Delay Until Repeat</code> both to the rightmost setting.</p>
<p>Finally, restart the computer.</p>
<h1>Disable the new window animation</h1>
<p>In a terminal, enter this:</p>
<pre><code>defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO </code></pre>
<h1>Mission Control tweaks</h1>
<p>Go to <code>System Preferences</code> -&gt; <code>Mission Control</code>, then uncheck <code>Show Dashboard as a space</code> and <code>Automatically rearrange spaces based on most recent use</code>.</p>
<p>Go to <code>System Preferences</code> -&gt; <code>Keyboard</code> -&gt; <code>Keyboard Shortcuts</code>, then select <code>Spotlight</code>. Double click the key binding for <code>Show Spotlight window</code> and press <code>Shift</code>+<code>Command</code>+<code>Space</code>.</p>
<p>Now, select <code>Mission Control</code>. Double click the key binding for <code>Mission Control</code> and press <code>Option</code>+<code>Command</code>+<code>Space</code>.</p>
<p>Double click the key binding for <code>Move left a space</code> and then press <code>Option</code>+<code>Command</code>+<code>Left cursor</code>. Similarly, for <code>Move right a space</code>, use <code>Option</code>+<code>Command</code>+<code>Right</code> cursor.<br />
This will enable <code>Option</code>-<code>Left cursor</code>/<code>Right cursor</code> for jumping between words (in addition to the <code>Control</code>-<code>Left cursor</code>/<code>Right cursor</code> that we set up above).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tomdzk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tomdzk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tomdzk.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=80&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tomdzk.wordpress.com/2011/07/30/lion-tweaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18039bff98071ad398b4301cfb0522b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tomdzk</media:title>
		</media:content>
	</item>
		<item>
		<title>Internal DNS in Amazon EC2 via tags</title>
		<link>http://tomdzk.wordpress.com/2010/10/16/internal-dns-in-amazon-ec2-via-tags/</link>
		<comments>http://tomdzk.wordpress.com/2010/10/16/internal-dns-in-amazon-ec2-via-tags/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 01:47:51 +0000</pubDate>
		<dc:creator>tomdzk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tomdzk.wordpress.com/?p=67</guid>
		<description><![CDATA[The recent EC2 API update from August 31st introduced the concept of tags which allow us to attach somewhat arbitrary metadata to instances and other resources. One useful application that came to my mind is to use them for maintaining internal DNS. The two blog posts here and here describe how to do this using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=67&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The recent EC2 API update from August 31st introduced the concept of tags which allow us to attach somewhat arbitrary metadata to instances and other resources. One useful application that came to my mind is to use them for maintaining internal DNS. The two blog posts <a href="http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns/">here</a> and <a href="http://m4dsk1llz.wordpress.com/2009/02/21/internal-dns-on-amazon-ec2/">here</a> describe how to do this using the name of the ssh key that was used to create the instance. However that means that a new ssh key has to be used for each instance which is cumbersome. Tags make this a lot easier, especially since they are automatically returned as part of the instance metadata.</p>
<p>The only problem was that Glenn Rempe&#8217;s <a href="http://github.com/grempe/amazon-ec2">AWS ruby library</a> doesn&#8217;t support the new API version yet. So <a href="http://github.com/tomdz/amazon-ec2">forked</a> the library and updated it to support the new API version and added the necessary functions.</p>
<p>So assuming that your instances have a tag named &#8220;hostname&#8221; that contains the desired short hostname (e.g. db1), with this new gem, the script from the above two blog posts becomes:</p>
<p><pre class="brush: ruby; light: true;">
#!/usr/bin/env ruby
%w(optparse rubygems AWS resolv pp).each { |l| require l }
options = {}
parser = OptionParser.new do |p|
  p.banner = &quot;Usage: hosts [options]&quot;
  p.on(&quot;-a&quot;, &quot;--access-key USER&quot;, &quot;The user's AWS access key ID.&quot;) do |aki|
    options[:access_key_id] = aki
  end
  p.on(&quot;-s&quot;,
       &quot;--secret-key PASSWORD&quot;,
       &quot;The user's AWS secret access key.&quot;) do |sak|
    options[:secret_access_key] = sak
  end
  p.on_tail(&quot;-h&quot;, &quot;--help&quot;, &quot;Show this message&quot;) {
    puts(p)
    exit
  }
  p.parse!(ARGV)
end
if options.key?(:access_key_id) and options.key?(:secret_access_key)
  puts &quot;127.0.0.1 localhost&quot;

  AWS::EC2::Base.new(options).describe_instances.reservationSet.item.each do |r|
    r.instancesSet.item.each do |i|
      if i.instanceState.name =~ /running/
        tagSet = i.tagSet
        if (!tagSet.nil? &amp;&amp; !tagSet.item.nil?)
          tagSet.item.each do |hash|
            if hash.key == 'hostname'
              puts(Resolv::DNS.new.getaddress(
                i.privateDnsName).to_s +&quot; #{hash.value}.ec2 #{hash.value}&quot;)
            end
          end
        end
      end
    end
  end
else
  puts(parser)
  exit(1)
end
</pre></p>
<p>P.S.: The documentation for the API can be found <a href="http://docs.amazonwebservices.com/AWSEC2/2010-08-31/APIReference/index.html?ApiReference_query_DescribeTags.html">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tomdzk.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tomdzk.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tomdzk.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=67&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tomdzk.wordpress.com/2010/10/16/internal-dns-in-amazon-ec2-via-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18039bff98071ad398b4301cfb0522b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tomdzk</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install Scribe with HDFS support on Ubuntu Karmic</title>
		<link>http://tomdzk.wordpress.com/2010/01/19/how-to-install-scribe-with-hdfs-support-on-ubuntu-karmic/</link>
		<comments>http://tomdzk.wordpress.com/2010/01/19/how-to-install-scribe-with-hdfs-support-on-ubuntu-karmic/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 00:32:12 +0000</pubDate>
		<dc:creator>tomdzk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tomdzk.wordpress.com/?p=19</guid>
		<description><![CDATA[Prerequisites Install some pre-requisites (more might be needed, my system had a bunch of things already): sudo apt-get install bison flex sun-java6-jdk ruby1.8-dev ant Create a build folder We won&#8217;t install scribe or thrift on the machine itself, instead keep it confined to a folder. For this we should mkdir scribe-build cd scribe-build mkdir dist [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=19&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Prerequisites</h2>
<p>Install some pre-requisites (more might be needed, my system had a bunch of things already):</p>
<pre>
sudo apt-get install bison flex sun-java6-jdk ruby1.8-dev ant
</pre>
<h2>Create a build folder</h2>
<p>We won&#8217;t install scribe or thrift on the machine itself, instead keep it confined to a folder. For this we should</p>
<pre>mkdir scribe-build
cd scribe-build
mkdir dist</pre>
<p>The dist folder will contain the binary distribution of scribe once we&#8217;re done, including all libraries.</p>
<h2>Install Boost</h2>
<p>On Ubuntu, you can simply install boost via the package manager:</p>
<pre>sudo apt-get install libboost1.40-dev libboost-filesystem1.40-dev</pre>
<p>These are the only two parts of boost that are needed. Also, please make sure to get at least version 1.40.</p>
<p>If you want to install from source instead, download boost version 1.40 or newer from <a href="http://www.boost.org/">http://www.boost.org/</a> (current version is 1.41.0) and then unpack it into the scribe-build folder. After that, cd to the created folder and build it:</p>
<pre>cd boost_1_41_0
./bootstrap.sh --prefix=`pwd`/../dist
./bjam install
cd ..</pre>
<h2>Install Libevent</h2>
<p>Again, libevent can simply be installed via the package manager:</p>
<pre>sudo apt-get install libevent-dev</pre>
<p>On Karmic, this will install libevent (if not installed already) and libevent development files for version 1.4.11 or newer. If you want to install it from source, download the 1.4.x source distribution from <a href="http://www.monkey.org/~provos/libevent/">http://www.monkey.org/~provos/libevent/</a> (1.4.13 is the current version) and unpack it into the scribe-build folder. Then cd into the generated folder and build it:</p>
<pre>cd libevent-1.4.13-stable
./configure --prefix=`pwd`/../dist
make
make install
cd ..</pre>
<h2>Thrift and FB303</h2>
<p>Download version 0.2.0-incubating from <a href="http://incubator.apache.org/thrift/download">http://incubator.apache.org/thrift/download</a> and unpack it into scribe-build. This should generate a folder scribe-build/thrift-0.2.0. To build it, run:</p>
<pre>cd thrift-0.2.0
export PY_PREFIX=`pwd`/../dist
export JAVA_PREFIX=`pwd`/../dist
./configure --prefix=`pwd`/../dist \
    --with-boost=`pwd`/../dist \
    --with-libevent=`pwd`/../dist
make
make install
cd ..</pre>
<p>This will most likely throw an error when trying to setup the ruby binding since it won&#8217;t be allowed to write into the system directory. This is due to a bug in the thrift build scripts &#8211; there is no way that I could find to tell it to install the ruby bindings locally. However, the things that we want will have been installed successfully, so let&#8217;s move on.</p>
<p>Next build the FB303 project:</p>
<pre>cd contrib/fb303
export PY_PREFIX=`pwd`/../../../dist
./bootstrap.sh \
    --with-thriftpath=`pwd`/../../../dist \
    --with-boost=`pwd`/../../../dist \
    --prefix=`pwd`/../../../dist
make
make install
cd ../../..</pre>
<h2>Libhdfs</h2>
<p>Scribe currently requires libhdfs 0.20.1 with patches applied &#8211; the stock version from the Hadoop 0.20.1 distribution won&#8217;t work. You can either use the Cloudera 0.20.1 distribution which has these patches applied, or use a newer version &#8211; presumably 0.21 works, but I haven&#8217;t tried it.</p>
<p>On Ubuntu, you can either install the Cloudera Hadoop distribution via debian packages, or you can compile it from source. The Debian/Ubuntu setup steps are described here:<br />
<a href="http://archive.cloudera.com/docs/_apt.html">http://archive.cloudera.com/docs/_apt.html</a>.</p>
<p>We however are going to compile libhdfs from source to get an independent library. Download from<br />
<a href="http://archive.cloudera.com/cdh/testing/hadoop-0.20.1+152.tar.gz">http://archive.cloudera.com/cdh/testing/hadoop-0.20.1+152.tar.gz</a><br />
and unpack it into the scribe-build folder. This will create a hadoop-0.20.1+152 folder, so let&#8217;s go there:</p>
<pre>cd hadoop-0.20.1+152</pre>
<p>Unfortunately, we also need to tweak two files by adding this line</p>
<pre>#include &lt;stdint.h&gt;</pre>
<p>right under the existing</p>
<pre>#include &lt;stdint.h&gt;</pre>
<p>in these two files</p>
<pre>src/c++/utils/api/hadoop/SerialUtils.hh
src/c++/pipes/api/hadoop/Pipes.hh</pre>
<p>Once you&#8217;ve done that, run:</p>
<pre>cd src/c++/libhdfs
./configure --enable-shared \
    JVM_ARCH=tune=k8 \
    --prefix=`pwd`/../../../../dist
make
make install
cd ../../../..</pre>
<p>Note that this seems to have been fixed in the 0.20.1+168.89 cloudera release.</p>
<h2>Build scribe</h2>
<p>Download scribe 2.1 from <a href="http://github.com/facebook/scribe/downloads">http://github.com/facebook/scribe/downloads</a> or clone the git repository (git://github.com/facebook/scribe.git). If you download the distribution, unpack it into the scribe-build directory, yielding a scribe-build/scribe- folder. cd to the scribe folder and the run:</p>
<pre>cd scribe-2.1
export LD_LIBRARY_PATH="`pwd`/../dist/lib:"\
"/usr/lib/jvm/java-6-sun/jre/lib/amd64:"\
"/usr/lib/jvm/java-6-sun/jre/lib/amd64/server"
export CFLAGS="-I/usr/lib/jvm/java-6-sun/include/ "\
"-I/usr/lib/jvm/java-6-sun/include/linux/"
export LDFLAGS="-L`pwd`/../dist/lib "\
"-L/usr/lib/jvm/java-6-sun/jre/lib/amd64 "\
"-L/usr/lib/jvm/java-6-sun/jre/lib/amd64/server"
export LIBS="-lhdfs -ljvm"
./bootstrap.sh --enable-hdfs \
    --with-hadooppath=`pwd`/../dist \
    --with-boost=`pwd`/../dist \
    --with-thriftpath=`pwd`/../dist \
    --with-fb303path=`pwd`/../dist \
    --prefix=`pwd`/../dist
make
make install
cd ..</pre>
<p>Adjust the jre/lib paths in the LDFLAGS to match your environment (e.g. 32bit vs. 64bit). The HDFS/Hadoop path in there is optional (i.e. enabled via the &#8211;enable-hdfs option) and only required if you want hdfs support.</p>
<h2>Test that it works</h2>
<p>Simply start scribe with the library path set correctly:</p>
<pre>cd dist
export LD_LIBRARY_PATH="`pwd`/lib"
./bin/scribed ../scribe-2.1/examples/example1.conf</pre>
<p>This should generate output like this:</p>
<pre>[Tue Jan 19 00:31:07 2010] "STATUS: STARTING"
[Tue Jan 19 00:31:07 2010] "STATUS: configuring"
[Tue Jan 19 00:31:07 2010] "got configuration data from file "
[Tue Jan 19 00:31:07 2010] "CATEGORY : default"
[Tue Jan 19 00:31:07 2010] "Creating default store"
[Tue Jan 19 00:31:07 2010] "configured  stores"
[Tue Jan 19 00:31:07 2010] "STATUS: "
[Tue Jan 19 00:31:07 2010] "STATUS: ALIVE"
[Tue Jan 19 00:31:07 2010] "Starting scribe server on port 1463"</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tomdzk.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tomdzk.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tomdzk.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=19&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tomdzk.wordpress.com/2010/01/19/how-to-install-scribe-with-hdfs-support-on-ubuntu-karmic/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18039bff98071ad398b4301cfb0522b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tomdzk</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up reconnoiter on Ubuntu (Karmic and newer)</title>
		<link>http://tomdzk.wordpress.com/2009/11/24/reconnoiter-on-karmic/</link>
		<comments>http://tomdzk.wordpress.com/2009/11/24/reconnoiter-on-karmic/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 16:35:20 +0000</pubDate>
		<dc:creator>tomdzk</dc:creator>
				<category><![CDATA[computers]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[After it took me about 2 days to figure out how to setup reconnoiter, I figured, it would be nice to document the steps so that it will be much easier for other people. Note: This guide was written for Karmic Koala (9.10) and Lucid Lynx (10.04). It should generally work for Jaunty, too, as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=1&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After it took me about 2 days to figure out how to setup reconnoiter, I figured, it would be nice to document the steps so that it will be much easier for other people.</p>
<p><strong>Note</strong>: This guide was written for Karmic Koala (9.10) and Lucid Lynx (10.04). It should generally work for Jaunty, too, as well as other Linux distributions (minus the package manager instructions obviously).</p>
<p><strong>Note</strong>: This guide has been updated to reconnoiter trunk revision 1404.</p>
<p>Before we begin, here are some useful links:</p>
<p>Reconnoiter home page: <a href="https://labs.omniti.com/trac/reconnoiter">https://labs.omniti.com/trac/reconnoiter</a></p>
<p>Reconnoiter docs: <a href="http://labs.omniti.com/docs/reconnoiter/">http://labs.omniti.com/docs/reconnoiter/</a></p>
<p>Oscon demo: <a href="http://omniti.com/video/noit-oscon-demo">http://omniti.com/video/noit-oscon-demo</a></p>
<h2>1. Build it</h2>
<p>First, let&#8217;s install a bunch of things. In the Synaptic Package Manager under <code>Settings -&gt; Repositories -&gt; Other Software</code> enable the two entries for the partner repositories. Then</p>
<p><pre class="brush: bash; light: true;">
sudo apt-get install autoconf build-essential libtool gettext \
  zlib1g-dev uuid-dev libpcre3-dev libssl-dev libpq-dev \
  libxml2-dev libxslt-dev libapr1-dev libaprutil1-dev xsltproc \
  libncurses5-dev libssh2-1-dev libsnmp-dev libmysqlclient-dev \
  subversion sun-java6-jdk 
</pre></p>
<p>Now we check out reconnoiter from subversion and build it:</p>
<p><pre class="brush: bash; light: true;">
svn co https://labs.omniti.com/reconnoiter/trunk reconnoiter
cd reconnoiter
autoconf
./configure
make
sudo mkdir -p /usr/local/java/libmake
sudo make install
</pre></p>
<h2>2. Setup the DB</h2>
<p>We need PostgreSQL 8.4 server &amp; client. On Karmic you get that via</p>
<p><pre class="brush: bash; light: true;">
sudo apt-get install postgresql postgresql-client
</pre></p>
<p>For Jaunty, follow the steps <a href="http://blog.markfeeney.com/2009/10/installing-postgresql-84-on-ubuntu.html">here</a>.</p>
<p>Next, make sure that the postgresql config file allows local access without password. Edit the <em>/etc/postgresql/8.4/main/pg_hba.conf</em> to change the local entry to use &#8220;trust&#8221;:</p>
<p><pre class="brush: plain; light: true;">
local   all         all                               trust
</pre></p>
<p>After that, restart the postgresql server:</p>
<p><pre class="brush: bash; light: true;">
sudo /etc/init.d/postgresql-8.4 restart
</pre></p>
<p>Now log in into postgresql:</p>
<p><pre class="brush: bash; light: true;">
sudo su postgres
cd sql
psql
</pre></p>
<p>Within <em>psql</em> do</p>
<p><pre class="brush: plain; light: true;">
\i scaffolding.sql
\q
</pre></p>
<h2>3. Setup cron</h2>
<p>First, we need to change the crontab to point to where postgresql is actually installed:<br />
<pre class="brush: bash; light: true;">
exit
sed -i 's/\/opt\/psql835/usr/g' sql/crontab
sudo su postgres
cd sql
</pre></p>
<p>We also need to run the commands in the crontab at least once manually as they will initialize certain database structures. As the postgres user:</p>
<p><pre class="brush: bash; light: true;">
eval &quot;`cat crontab | cut -d' ' -f6- | grep -v ^$ | awk '{print $0\&quot;;\&quot;}'`&quot;
</pre></p>
<p>Finally, and still as user <em>postgres</em> do</p>
<p><pre class="brush: bash; light: true;">
crontab crontab
exit
</pre></p>
<h2>4. Setup the web ui</h2>
<p>For configuring the web UI (PHP), we first need Apache2 and PHP:</p>
<p><pre class="brush: plain; light: true;">
sudo apt-get install apache2 libapache2-mod-php5 php5-pgsql
</pre></p>
<p>This will also enable mod_php5. Every other required module (<em>mod_mime</em>, <em>mod_lib_config</em>, <em>mod_rewrite</em>, <em>mod_proxy</em>, <em>mod_proxy_http</em>, <em>mod_authz_host</em>) should be already enabled or even compiled in the server (<em>apache2 -l</em> will show). To make sure that they are enabled, simply do</p>
<p><pre class="brush: bash; light: true;">
sudo a2enmod mime
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod authz_host
</pre></p>
<p>Next, we need the apache configuration, either as a a new file <em>/etc/apache2/sites-available/reconnoiter</em> that then should be symlinked into <em>/etc/apache2/sites-enabled</em>, or in the current configuration (e.g. <em>/etc/apache2/sites-enabled/000-default</em>). A sample configuration to setup reconnoiter on port 80:</p>
<p><pre class="brush: plain; light: true;">
&lt;VirtualHost *:80&gt;
  ServerAdmin webmaster@localhost
  DocumentRoot @ROOT@/ui/web/htdocs

  &lt;Directory &quot;/&quot;&gt;
      Options None
      AllowOverride None
      Order allow,deny
      Deny from all
  &lt;/Directory&gt;
  &lt;FilesMatch &quot;^\.ht&quot;&gt;
      Order allow,deny
      Deny from all
      Satisfy All
  &lt;/FilesMatch&gt;
  &lt;Directory &quot;@ROOT@/ui/web/htdocs/&quot;&gt;
      php_value include_path @ROOT@/ui/web/lib
      php_value short_open_tag off
      Options FollowSymLinks Indexes
      AllowOverride All
      Order deny,allow
      Allow from all
  &lt;/Directory&gt;

  LogLevel warn
  LogFormat &quot;%h %l %u %t \&quot;%r\&quot; %&gt;s %b&quot; common

  ErrorLog @ROOT@/ui/web/logs/error_log
  CustomLog @ROOT@/ui/web/logs/access_log common

  AddType application/x-compress .Z
  AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php .php
  DefaultType text/plain
&lt;/VirtualHost&gt;
</pre></p>
<p>Replace <em>@ROOT@</em> with the directory where you have installed reconnoiter.</p>
<p>If you chose to add reconnoiter to the Apache config on a different port than 80, say 9090, then you will also have to change Apache&#8217;s port configuration in <em>/etc/apache2/ports.conf</em> by adding:</p>
<p><pre class="brush: plain; light: true;">
NameVirtualHost *:9090
Listen 9090
</pre></p>
<p>Then restart apache:</p>
<p><pre class="brush: bash; light: true;">
sudo /etc/init.d/apache2 restart
</pre></p>
<h2>5. Generate test certificates</h2>
<p>These steps show how to generate test certificates. In a production environment you would of course use a real CA.</p>
<p>Create/go to a temporary directory:</p>
<p><pre class="brush: bash; light: true;">
mkdir ssh-keys
cd ssh-keys
</pre></p>
<p>Next create a file <em>openssl.cnf</em> file in it with this contents:</p>
<p><pre class="brush: plain; light: true;">
HOME = .
RANDFILE = $ENV::HOME/.rnd

oid_section = new_oids

[ new_oids ]

[ ca ]
default_ca = CA_default

[ CA_default ]
dir = ./testCA
certs = $dir/certs
crl_dir = $dir/crl
database = $dir/index.txt
new_certs_dir = $dir/newcerts
certificate = $dir/cacert.pem
serial = $dir/serial
crl = $dir/crl.pem
private_key = $dir/private/cakey.pem
RANDFILE = $dir/private/.rand
x509_extensions = usr_cert
name_opt = ca_default
cert_opt = ca_default
default_days = 365
default_crl_days = 30
default_md = md5
preserve = no
policy = policy_match

[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional

[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName	= optional
commonName	 = supplied
emailAddress = optional

[ req ]
default_bits = 1024
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca
string_mask = nombstr

[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = AU
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Some-State
localityName = Locality Name (eg, city)
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Internet Widgits Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
commonName = Common Name (eg, YOUR name)
commonName_max = 64
emailAddress = Email Address
emailAddress_max = 64

[ req_attributes ]
challengePassword = A challenge password
challengePassword_min	= 4
challengePassword_max = 20
unstructuredName = An optional company name

[ usr_cert ]
basicConstraints = CA:FALSE
nsComment = &quot;OpenSSL Generated Certificate&quot;
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always

[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment

[ v3_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always
basicConstraints = CA:true

[ crl_ext ]
authorityKeyIdentifier = keyid:always,issuer:always

[ proxy_cert_ext ]
basicConstraints = CA:FALSE
nsComment = &quot;OpenSSL Generated Certificate&quot;
subjectKeyIdentifier = hash
authorityKeyIdentifier  = keyid,issuer:always
proxyCertInfo = critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
</pre></p>
<p>Next execute these commands:</p>
<p><pre class="brush: bash; light: true;">
mkdir testCA
touch testCA/index.txt
test -f testCA/serial || echo 00 &gt; testCA/serial

# CA
openssl genrsa -out test-ca.key
openssl req -key test-ca.key -days 365 \
    -new -out test-ca.csr -config openssl.cnf \
    -subj &quot;/C=US/ST=California/O=Ning Inc./CN=Reconnoiter Test CA&quot;
openssl x509 -req -in test-ca.csr -signkey test-ca.key \
    -out test-ca.crt

# noit
openssl genrsa -out test-noit.key
openssl req -key test-noit.key -days 365 \
    -new -out test-noit.csr -config openssl.cnf \
    -subj &quot;/C=US/ST=California/O=Ning Inc./CN=noit-test&quot;
openssl ca -batch -config openssl.cnf \
    -in test-noit.csr -out test-noit.crt \
    -outdir . -keyfile test-ca.key -cert test-ca.crt -days 120

# stratcon
openssl genrsa -out test-stratcon.key
openssl req -key test-stratcon.key -days 365 \
    -new -out test-stratcon.csr -config openssl.cnf \
    -subj &quot;/C=US/ST=California/O=Ning Inc./CN=stratcon&quot;
openssl ca -batch -config openssl.cnf \
    -in test-stratcon.csr -out test-stratcon.crt \
    -outdir . -keyfile test-ca.key -cert test-ca.crt -days 120
</pre></p>
<p>This will create a bunch of <em>.pem</em>, <em>.crt</em>, <em>.csr</em>, and <em>.key</em> files, that you should copy to <em>/usr/local/etc</em>:</p>
<p><pre class="brush: bash; light: true;">
sudo cp *.pem *.crt *.csr *.key /usr/local/etc
</pre></p>
<h2>6. Setup a noit daemon</h2>
<p>Generate the config:</p>
<p><pre class="brush: bash; light: true;">
sudo cp src/noit.conf /usr/local/etc/
</pre></p>
<p>Now you can edit that file to your heart&#8217;s content. Some things to note</p>
<ul>
<li>Comment out/remove sections as necessary, or make sure that they point to existing machines.</li>
<li>For every new item, create a new uuid using the <em>uuidgen</em> tool was installed earlier.</li>
<li>Update the <em>sslconfig</em> section to use the test certificates:<br />
<pre class="brush: xml; light: true;">
&lt;sslconfig&gt;
  &lt;optional_no_ca&gt;false&lt;/optional_no_ca&gt;
  &lt;certificate_file&gt;/usr/local/etc/test-noit.crt&lt;/certificate_file&gt;
  &lt;key_file&gt;/usr/local/etc/test-noit.key&lt;/key_file&gt;
  &lt;ca_chain&gt;/usr/local/etc/test-ca.crt&lt;/ca_chain&gt;
&lt;/sslconfig&gt;
</pre>
</li>
<li>For snmp entries, make sure you have the community set correctly (see <a href="https://labs.omniti.com/docs/reconnoiter/ch05s14.html">https://labs.omniti.com/docs/reconnoiter/ch05s14.html</a>.</li>
</ul>
<p>Finally start the noit daemon:</p>
<p><pre class="brush: bash; light: true;">
sudo /usr/local/sbin/noitd -c /usr/local/etc/noit.conf -D
</pre></p>
<p>The <em>-D</em> option is for debugging purposes. It will tell noitd to run in the foreground and log everything to stdout/stderr. You also might want to tweak the logging settings in the configuration file. Turn the debug logging by changing this line near the top of the config file:</p>
<p><pre class="brush: xml; light: true;">
&lt;log name=&quot;debug&quot; disabled=&quot;true&quot;/&gt;
</pre></p>
<p>to</p>
<p><pre class="brush: xml; light: true;">
&lt;log name=&quot;debug&quot;/&gt;
</pre></p>
<p>Then switch whichever specific modules you want debug logging for. E.g. for snmp debug logging change this line further down in the config file:</p>
<p><pre class="brush: xml; light: true;">
&lt;log name=&quot;debug/snmp&quot; disabled=&quot;true&quot;/&gt;
</pre></p>
<p>to</p>
<p><pre class="brush: xml; light: true;">
&lt;log name=&quot;debug/snmp&quot;/&gt;
</pre></p>
<h2>7. Setup a stratcon daemon</h2>
<p>Again, create the config file using the sample config file:</p>
<p><pre class="brush: bash; light: true;">
sudo cp src/stratcon.conf /usr/local/etc/
</pre></p>
<p>Edit as necessary:</p>
<ul>
<li>Logging is configured in the same way as for noit above.</li>
<li>Set the password in the database config section to <em>stratcon</em> (or whatever you chose in the <em>scaffolding.sql</em> above).</li>
<li>For each noitd instance there needs to be a <em>noitd</em> section.</li>
<li>Configure the <em>listeners</em> section, esp. the <em>port</em> (should be an unused one), the <em>hostname</em> and <em>document_domain</em>.</li>
<li>Update the <em>sslconfig</em> sections (there is two of them, one in the <em>noits</em> section and one in the <em>listeners</em> section) to use the test certificates:<br />
<pre class="brush: xml; light: true;">
&lt;sslconfig&gt;
  &lt;key_file&gt;/usr/local/etc/test-stratcon.key&lt;/key_file&gt;
  &lt;certificate_file&gt;/usr/local/etc/test-stratcon.crt&lt;/certificate_file&gt;
  &lt;ca_chain&gt;/usr/local/etc/test-ca.crt&lt;/ca_chain&gt;
&lt;/sslconfig&gt;
</pre>
</li>
</ul>
<p>Finally start the stratcon daemon:</p>
<p><pre class="brush: bash; light: true;">
sudo /usr/local/sbin/stratcond -c /usr/local/etc/stratcon.conf -D
</pre></p>
<p>Again, the <em>-D</em> option is for debugging. You can tweak the logging settings in pretty much the same was as for noitd.</p>
<h2>8. Verification</h2>
<p>In your browser (note that the UI doesn&#8217;t quite work in Chrome), go to <em>http://localhost:9090</em>. The reconnoiter UI should appear. On the left side click the + next to &#8220;Graph Controls&#8221; and then on &#8220;Browse Data&#8221;. The data that you configured for <em>noitd</em> above should show up, though it might take a few minutes between starting <em>noitd</em> and the first data showing up.</p>
<p>Relevant logs are:</p>
<ul>
<li><em>/var/log/postgresql/postgresql-8.4-main.log</em></li>
<li><em>/tmp/rollup.log</em> &#8211; the log created by the cron rollup job</li>
<li><em>/var/log/syslog</em></li>
<li><em>@ROOT@/ui/web/logs/error_log</em> and <em>@ROOT@/ui/web/logs/access_log</em></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tomdzk.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tomdzk.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tomdzk.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tomdzk.wordpress.com&amp;blog=10656990&amp;post=1&amp;subd=tomdzk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tomdzk.wordpress.com/2009/11/24/reconnoiter-on-karmic/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18039bff98071ad398b4301cfb0522b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tomdzk</media:title>
		</media:content>
	</item>
	</channel>
</rss>
