<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[coredump I/O]]></title>
  <link href="http://coredump.io/atom.xml" rel="self"/>
  <link href="http://coredump.io/"/>
  <updated>2014-01-29T22:26:23-05:00</updated>
  <id>http://coredump.io/</id>
  <author>
    <name><![CDATA[José de Paula Eufrásio Júnior]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Making tools that aren't a hammer]]></title>
    <link href="http://coredump.io/blog/2014/01/28/making-tools-that-arent-a-hammer/"/>
    <updated>2014-01-28T18:30:16-05:00</updated>
    <id>http://coredump.io/blog/2014/01/28/making-tools-that-arent-a-hammer</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://i.imgur.com/RQ5l2jm.jpg" width="180" height="240" title="Hammer and screw" alt="A picture of a hammer and a big bolt not working well together"></p>

<p>There&rsquo;s a famous saying about hammers and problems. I think it goes like <em>if all you have is a hammer, everything looks like a nail</em>. That&rsquo;s a common thing to happen on the devops/sysadmin trade and goes completely against the UNIX Philosophy of small tools getting together to achieve big things.</p>

<!-- more -->


<p>Sometimes we will essentially try to fit the problem to the tool, just because we have all this variety of <strong>do everything</strong> tools. That, in my opinion, is not worth it. We like to call us devops, right? So let&rsquo;s throw some dev&#8217;ing and create tools tailored to the tasks.</p>

<p>For example, it is possible to load balance, cache and serve PHP using Nginx. That doesn&rsquo;t mean you <strong>should</strong> do that unless it&rsquo;s a small install or non-critic server (go ahead and do it on your personal site, I mean, even I do it), but if you want to keep flexible and scalable, spread out and try to find the best of it&rsquo;s kind&hellip; or the close second. Cache on <a href="https://www.varnish-software.com/">Varnish</a>, serve PHP from a different box (maybe using <a href="http://www.apache.org/">Apache</a>), load balance on <a href="http://haproxy.1wt.eu/">HAProxy</a> (or Varnish really it&rsquo;s very good at it).</p>

<p><img class="right" src="http://i.imgur.com/h9GWeFP.jpg" width="250" height="250" title="Go away image" alt="Go away or I will replace you with a tiny shell script"></p>

<p>We put this thought in practice at <a href="http://www.voxmedia.com">Vox Media</a> all the time. Not only because we agree with it, it also helps us increase the visibility of our services and do a better job monitoring everything.</p>

<p>Don&rsquo;t consider it a <em>not built here</em> syndrome. As I said, use the best available or make your own, and don&rsquo;t feel bad about having to change later when something better appears. Constant evolution!</p>

<p>For example, those are two tools that I made for very specific objectives:</p>

<ul>
<li><a href="https://github.com/coredump/slowqwatch">slowqwatch</a>: It watches a log and increases a StatsD counter when a regex is matched. Nothing great or fantastic, but allows us to measure rates and plot nice Graphite graphs of stuff like MySQL slow queries (hence the name).</li>
<li><a href="https://github.com/coredump/ipcount">ipcount</a>: This may have been a little over-engineered but I wanted to do some stuff using Redis and Go. What this does is basically watching access logs and sending the IPs to Redis, and then a web page shows the top IPs. You know, to catch those spidering robots that hammer your serves like crazy.</li>
</ul>


<p>I am sure a lot of people will point me to different tools that do <strong>the same thing</strong> or/and are better at doing those things. The point is, we had an itch and we scratched it, custom made. Of course we can make the same with Splunk, but not every company has the money for that&hellip;</p>

<p><strong>TL;DR</strong>: stop hitting your problems with the same tools over and over and think about expanding your toolbox, even if that requires you to create the tools from scratch.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[One old weird trick to speed SSH]]></title>
    <link href="http://coredump.io/blog/2013/10/22/one-old-weird-trick-to-speed-ssh/"/>
    <updated>2013-10-22T16:34:00-04:00</updated>
    <id>http://coredump.io/blog/2013/10/22/one-old-weird-trick-to-speed-ssh</id>
    <content type="html"><![CDATA[<p>SSH is awesome, it&rsquo;s perhaps into the top 10 most important tools for the sysadmin job and still surprises me sometimes with cool features.</p>

<p>Doing some reading about cluster administration using SSH I stumbled into this:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Host *
</span><span class='line'>  ControlMaster auto
</span><span class='line'>  ControlPath /tmp/ssh_mux_%h_%p_%r
</span><span class='line'>  ControlPersist 4h</span></code></pre></td></tr></table></div></figure>


<p>What witchery is that, you ask? Has science gone too far? Well, no, that&rsquo;s actually pretty old and I should be probably ashamed of only discovering it so recently.</p>

<!-- more -->


<p>Those options cause your client to create a master connection to the server you are connecting, with all SSH overhead (key exchange, session setup, authentication, etc) on your first connection. The real magic occurs when you open <em>more</em> connections to the same server: they <em>piggyback</em> on the master, and skip all the long ass initialization phase.</p>

<p>That&rsquo;s a good thing if you (like me) spend most of your day logged into many servers at the same time, and even multiple times to the same server (because you forgot to run tmux).</p>

<p>Another neat thing is that when a master connection is open, you get a bonus tab-completion feature on scp for remote directories/files. You have to try it to see how much difference it makes.</p>

<p>The <code>ControlPersist</code> option is kinda of a controversy IMO because it means (on the above case) that the master connection will remain open for that amount of time after you disconnect the server. That helps a lot when you are going in and out of servers, but still a connection dangling around the network&hellip; so, YMMV.</p>

<p>To read the full description and caveats of each option, check the <code>ssh_config</code> man page, as always.</p>

<p>cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[GnuPG for people that don't like GnuPG]]></title>
    <link href="http://coredump.io/blog/2013/04/29/gpg-for-people-that-dont-like-gpg/"/>
    <updated>2013-04-29T16:43:00-04:00</updated>
    <id>http://coredump.io/blog/2013/04/29/gpg-for-people-that-dont-like-gpg</id>
    <content type="html"><![CDATA[<p>So for some reason you have to use GnuPG (GPG for shorts). It may because you work somewhere with minimal privacy/security conscience, or just because you are on a project that decided to sign commits using a GPG/PGP key (I will use PGP/GPG key interchangeably here). The problem is, you have no idea of what you should be doing. Fear not, you can totally fake it until you make it with a few easy commands.</p>

<!-- more -->


<p><em>If in some of the commands below you see a lot of gibberish on the screen, check if you didn&rsquo;t forget to add <code>--armor</code> to it. It makes the output to be ASCII text and not binary gibberish.</em></p>

<h2>Step One &ndash; Generate a key pair:</h2>

<p>You should have gnupg installed. Use your package manager to do that on Linux, or download it on Windows. If you use Mac OS X use the Homebrew version but be aware that there are some incompatibilities between GnuPG and MacGPG2/GPGTools that require the usage of a nightly version of the later.</p>

<p>This is a full session describing a key pair creation, just answer the questions and you will end with a fully functional PGP key pair ready to use:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --gen-key
</span><span class='line'>gpg (GnuPG) 1.4.13; Copyright (C) 2012 Free Software Foundation, Inc.
</span><span class='line'>This is free software: you are free to change and redistribute it.
</span><span class='line'>There is NO WARRANTY, to the extent permitted by law.
</span><span class='line'>
</span><span class='line'>Please select what kind of key you want:
</span><span class='line'>   (1) RSA and RSA (default)
</span><span class='line'>   (2) DSA and Elgamal
</span><span class='line'>   (3) DSA (sign only)
</span><span class='line'>   (4) RSA (sign only)
</span><span class='line'>Your selection? 1
</span><span class='line'>RSA keys may be between 1024 and 4096 bits long.
</span><span class='line'>What keysize do you want? (2048)
</span><span class='line'>Requested keysize is 2048 bits
</span><span class='line'>Please specify how long the key should be valid.
</span><span class='line'>         0 = key does not expire
</span><span class='line'>      &lt;n&gt;  = key expires in n days
</span><span class='line'>      &lt;n&gt;w = key expires in n weeks
</span><span class='line'>      &lt;n&gt;m = key expires in n months
</span><span class='line'>      &lt;n&gt;y = key expires in n years
</span><span class='line'>Key is valid for? (0) 10y
</span><span class='line'>Key expires at Thu Apr 27 17:16:04 2023 EDT
</span><span class='line'>Is this correct? (y/N) y
</span><span class='line'>
</span><span class='line'>You need a user ID to identify your key; the software constructs the user ID
</span><span class='line'>from the Real Name, Comment and Email Address in this form:
</span><span class='line'>    "Heinrich Heine (Der Dichter) &lt;heinrichh@duesseldorf.de&gt;"
</span><span class='line'>
</span><span class='line'>Real name: Testing Smith
</span><span class='line'>Email address: example@example.com
</span><span class='line'>Comment:
</span><span class='line'>You selected this USER-ID:
</span><span class='line'>    "Testing Smith &lt;example@example.com&gt;"
</span><span class='line'>
</span><span class='line'>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
</span><span class='line'>You need a Passphrase to protect your secret key.
</span><span class='line'>
</span><span class='line'>gpg: gpg-agent is not available in this session
</span><span class='line'>We need to generate a lot of random bytes. It is a good idea to perform
</span><span class='line'>some other action (type on the keyboard, move the mouse, utilize the
</span><span class='line'>disks) during the prime generation; this gives the random number
</span><span class='line'>generator a better chance to gain enough entropy.
</span><span class='line'>.+++++
</span><span class='line'>....+++++
</span><span class='line'>We need to generate a lot of random bytes. It is a good idea to perform
</span><span class='line'>some other action (type on the keyboard, move the mouse, utilize the
</span><span class='line'>disks) during the prime generation; this gives the random number
</span><span class='line'>generator a better chance to gain enough entropy.
</span><span class='line'>+++++
</span><span class='line'>+++++
</span><span class='line'>gpg: key 64E4DFD8 marked as ultimately trusted
</span><span class='line'>public and secret key created and signed.
</span><span class='line'>
</span><span class='line'>gpg: checking the trustdb
</span><span class='line'>gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
</span><span class='line'>gpg: depth: 0  valid:   4  signed:   4  trust: 0-, 0q, 0n, 0m, 0f, 4u
</span><span class='line'>gpg: depth: 1  valid:   4  signed:   0  trust: 0-, 0q, 0n, 3m, 1f, 0u
</span><span class='line'>gpg: next trustdb check due at 2015-08-18
</span><span class='line'>pub   2048R/64E4DFD8 2013-04-29 [expires: 2023-04-27]
</span><span class='line'>      Key fingerprint = 3546 93CD 098B E5E6 0F05  5DBE F5BD 6066 64E4 DFD8
</span><span class='line'>uid                  Testing Smith &lt;example@example.com&gt;
</span><span class='line'>sub   2048R/9A0F9041 2013-04-29 [expires: 2023-04-27]</span></code></pre></td></tr></table></div></figure>


<p>According to most literature, a 2048 bit key should be good for securing data until 2030, so a 10 year expiry date is fine. If you want to use more than 10 years use 4096 bit, but don&rsquo;t go over 30 years expiry and <strong>NEVER make a key that doesn&rsquo;t expire</strong>.</p>

<p>Also, <strong>NEVER create a keypair without a passphrase</strong>. And remember, it&rsquo;s a pass<strong>phrase</strong> not a pass<strong>word</strong>. Use something long, creative and that you won&rsquo;t forget. It&rsquo;s not like you are going to type it every 5 minutes.</p>

<p>Seriously if you just created a keypair that never expires or without a passphrase, delete it with <code>gpg --delete-secret-key</code> and create a new, proper one, or edit your ridiculously unsafe one with <code>gpg --edit-key</code> (using the commands <code>passwd</code> and <code>expire</code> and then <code>save</code>).</p>

<p>If at any point you don&rsquo;t like or get something wrong, just press <code>CTRL+C</code> and start again, the key is only saved after those last lines are printed.</p>

<h2>Step Two &ndash; Export your keys</h2>

<p>You have a key pair. That means you have a private and a public key. The public key you want to make know to people to be able to encrypt/sign things to you while the private key you want to keep safe. For that reason, you want to export both keys to text files to facilitate both those tasks:</p>

<p>Exporting the public key to a file:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --armor --output public_key.gpg --export example@example.com</span></code></pre></td></tr></table></div></figure>


<p>Exporting the private key to a file:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --armor --output private_key.gpg --export-secret-keys example@example.com</span></code></pre></td></tr></table></div></figure>


<p>The private key file you want to save somewhere else. Put it on a thumb drive, backup disk, online backup, anywhere you are confident you won&rsquo;t lose it. If you lose your private key you won&rsquo;t be able to access anything that was encrypted using it. For reals, if you lose it, there goes the data.</p>

<p>The public file is another story. You can lose it, share it, put it on your Facebook, Twitter, send it via email, and if you lose it you can just regenerate it from your private key. Anyone that wants to encrypt or sign stuff for you must have it so make it easily accessible.</p>

<p>If you are a really nice guy you should send your public key to one of the key servers around the world, so people can search your email and retrieve your key automatically. For that you need your Key ID, and since this is a thing that people may ask you someday, this is how you find it:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --list-keys example@example.com
</span><span class='line'>pub   2048R/64E4DFD8 2013-04-29 [expires: 2023-04-27]
</span><span class='line'>uid                  Testing Smith &lt;example@example.com&gt;
</span><span class='line'>sub   2048R/9A0F9041 2013-04-29 [expires: 2023-04-27]</span></code></pre></td></tr></table></div></figure>


<p>When you list a key, the ID is the number after <code>pub   ??????/</code>. In this case the ?????? is 2048R because the key is 2048 bit RSA, but that will vary. So in this case the key ID is 64E4DFD8. With that information you can do:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --keyserver pgp.mit.edu --send-keys 64E4DFD8</span></code></pre></td></tr></table></div></figure>


<p>And your public key will be available on the PGP network after a few days (the servers are connected so they will replicate the key worldwide eventually)</p>

<h2>Step Three &ndash; Encrypt and Decrypt stuff with your keys</h2>

<p>Finally, after creating your keypair and exporting your keys, it&rsquo;s time to do something useful with them. This is a simple example to encrypt a simple text to someone (in this case, myself):</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --armor --encrypt
</span><span class='line'>You did not specify a user ID. (you may use "-r")
</span><span class='line'>
</span><span class='line'>Current recipients:
</span><span class='line'>
</span><span class='line'>Enter the user ID.  End with an empty line: jose
</span><span class='line'>
</span><span class='line'>Current recipients:
</span><span class='line'>4096R/17898967 2010-09-10 "José de Paula Eufrásio Júnior &lt;jose.junior@gmail.com&gt;"
</span><span class='line'>
</span><span class='line'>Enter the user ID.  End with an empty line:
</span><span class='line'>This is just a text message
</span><span class='line'>-----BEGIN PGP MESSAGE-----
</span><span class='line'>Version: GnuPG v1.4.13 (Darwin)
</span><span class='line'>Comment: GPGTools - http://gpgtools.org
</span><span class='line'>
</span><span class='line'>hQIMA7sOk1QXiYlnAQ//U74eBVPt7XLBOhvRAWtEJ2Q2L9eN5wsjtvQaPiTOHSiF
</span><span class='line'>JiD8ZT9giPJLn2Dr2ViS6Qhhm3MOGc3V1SxpQvavigC6nIHgzTXPG5CdsiQgLPIk
</span><span class='line'>iXrxpd3rnrnMiCMb/rodbEeYNiJ6q5OiztCfpjFNMBD4lwCSf7wbQNL/TUzADqlA
</span><span class='line'>gIi1mH9Dw3r5PsY3mD6omoRj5MlVCpKDqnAj58iarvRm2NCUvdnWciwXX1KTBFM1
</span><span class='line'>9EnXH3Kyox2RFW78xfh9/OVcX8UAmN25PdgtoSOQMBLLScslKn5ivlTxqhiTW/8N
</span><span class='line'>XS0G1hkTMKJ6ya6vHshp+ei4pOYtqTlVoTZ5xYVc8jv6xhJC/mbTtC3TEdgrcrsY
</span><span class='line'>UIA4F4BfzTi8Si8JeYK50wjdy+425Zqub7+CkYb8n2uTtyqZRrlvd3vvAYtbcmeO
</span><span class='line'>TgD74CCAGomVmN0uQeLKxoFNE6Fre02wEg0m/37eEustpbI1qRtY4z5MHOFsIYU+
</span><span class='line'>+xBSUEcYaVjK95KIpoaGjBA4l8FrwEQRK1/hlFgQkzm9kCiQGjaeOqXr69MFqvFs
</span><span class='line'>OOkCo1asQGBv3CKTPVX/wg2vTi11KPtpBSIV2+pL+U/UwjG6Z7LF0y++y/7obYdu
</span><span class='line'>QBTKPd9tnVVwuC47kENn33vq7454P70hxwHvDc1BWLHsrHf5GMq7lem8ibpLEEvS
</span><span class='line'>VgFhC0qjKyvFD+Aa24BKqQusBiRhSuV/U2oCV/fnkTmIpjLJMAGlmQPojbrCw3lF
</span><span class='line'>Dyv9VZpmb1do6MobHc+dAieKpptNL94yHxppakOIsCAXfADyKolm
</span><span class='line'>=lBMX
</span><span class='line'>-----END PGP MESSAGE-----</span></code></pre></td></tr></table></div></figure>


<p>So I just typed <em>jose</em>  so it could find my key on my keychain and added it as my single recipient, typed the message to be encrypted (&ldquo;this is just a text message&rdquo;) and finished it with an EOF signal (CTRL+D). The output is the encrypted message that you can send via email or IM or print on a piece of paper, and it&rsquo;s all the content included between the <code>-----BEGIN PGP MESSAGE-----</code> and <code>-----END PGP MESSAGE-----</code>.</p>

<p>Decrypting is just as easy:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>% gpg --decrypt
</span><span class='line'>-----BEGIN PGP MESSAGE-----
</span><span class='line'>Version: GnuPG v1.4.13 (Darwin)
</span><span class='line'>Comment: GPGTools - http://gpgtools.org
</span><span class='line'>
</span><span class='line'>hQIMA7sOk1QXiYlnAQ//U74eBVPt7XLBOhvRAWtEJ2Q2L9eN5wsjtvQaPiTOHSiF
</span><span class='line'>JiD8ZT9giPJLn2Dr2ViS6Qhhm3MOGc3V1SxpQvavigC6nIHgzTXPG5CdsiQgLPIk
</span><span class='line'>iXrxpd3rnrnMiCMb/rodbEeYNiJ6q5OiztCfpjFNMBD4lwCSf7wbQNL/TUzADqlA
</span><span class='line'>gIi1mH9Dw3r5PsY3mD6omoRj5MlVCpKDqnAj58iarvRm2NCUvdnWciwXX1KTBFM1
</span><span class='line'>9EnXH3Kyox2RFW78xfh9/OVcX8UAmN25PdgtoSOQMBLLScslKn5ivlTxqhiTW/8N
</span><span class='line'>XS0G1hkTMKJ6ya6vHshp+ei4pOYtqTlVoTZ5xYVc8jv6xhJC/mbTtC3TEdgrcrsY
</span><span class='line'>UIA4F4BfzTi8Si8JeYK50wjdy+425Zqub7+CkYb8n2uTtyqZRrlvd3vvAYtbcmeO
</span><span class='line'>TgD74CCAGomVmN0uQeLKxoFNE6Fre02wEg0m/37eEustpbI1qRtY4z5MHOFsIYU+
</span><span class='line'>+xBSUEcYaVjK95KIpoaGjBA4l8FrwEQRK1/hlFgQkzm9kCiQGjaeOqXr69MFqvFs
</span><span class='line'>OOkCo1asQGBv3CKTPVX/wg2vTi11KPtpBSIV2+pL+U/UwjG6Z7LF0y++y/7obYdu
</span><span class='line'>QBTKPd9tnVVwuC47kENn33vq7454P70hxwHvDc1BWLHsrHf5GMq7lem8ibpLEEvS
</span><span class='line'>VgFhC0qjKyvFD+Aa24BKqQusBiRhSuV/U2oCV/fnkTmIpjLJMAGlmQPojbrCw3lF
</span><span class='line'>Dyv9VZpmb1do6MobHc+dAieKpptNL94yHxppakOIsCAXfADyKolm
</span><span class='line'>=lBMX
</span><span class='line'>-----END PGP MESSAGE-----
</span><span class='line'>You need a passphrase to unlock the secret key for
</span><span class='line'>user: "José de Paula Eufrásio Júnior &lt;jose.junior@gmail.com&gt;"
</span><span class='line'>4096-bit RSA key, ID 17898967, created 2010-09-10 (main key ID 031161FF)
</span><span class='line'>
</span><span class='line'>gpg: gpg-agent is not available in this session
</span><span class='line'>gpg: encrypted with 4096-bit RSA key, ID 17898967, created 2010-09-10
</span><span class='line'>      "José de Paula Eufrásio Júnior &lt;jose.junior@gmail.com&gt;"
</span><span class='line'>This is just a text message</span></code></pre></td></tr></table></div></figure>


<p>Paste the message, enter the passphrase for the private key, read the message. Simple like that.</p>

<p>Those are arguably the two most useless uses of GPG, though, but they are a very good way to show how it works on a quick and dirty way.</p>

<p>There are tools and plugins out there to make GPG usage painless and quick, like graphical interfaces for encrypting files, key management and plugins for mail clients for easy signing/encrypting of email messages, but creating and managing keys via the command line are good basics to pick up.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Learning Go(lang)]]></title>
    <link href="http://coredump.io/blog/2012/08/13/learning-go-lang/"/>
    <updated>2012-08-13T21:09:00-04:00</updated>
    <id>http://coredump.io/blog/2012/08/13/learning-go-lang</id>
    <content type="html"><![CDATA[<p><img class="right" src="http://i.imgur.com/PSNDx.png"></p>

<p>One of the things I really like to do is learning new languages. So after leaving it on the back burner for almost a year I decided to really concentrate on the Mark Summerfield&rsquo;s <a href="http://www.qtrac.eu/gobook.html">Programming Go</a> book that I had since before printing (I had like 4 different rough cuts that I never started reading for serious). The book is very good, and is doing a fantastic job on giving me the basics on the language, and I am starting the more advanced chapters and not feeling totally lost.</p>

<!-- more -->


<p>Go contrasts a lot with the ones I use day-to-day (mainly python and ruby). It&rsquo;s statically typed, compiled and uses pointers, so the growing pains are understandable. Like trying to print an URL but discovering that you can&rsquo;t simply wait for the language to cast that down to a string automatically. I still get a lot of compiling errors just because I try to skip steps or use the wrong type on the wrong part.</p>

<p>There are some nice parts. Go doesn&rsquo;t really do exceptions (unless it&rsquo;s an exceptional behavior), so the traditional &lsquo;ask forgiveness later&rsquo; thing will not help here. What Go and it&rsquo;s standard lib and the good 3rd party libs do is always return at least an error code on it&rsquo;s functions. So most of the time you will have things like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='go'><span class='line'><span class="n">data</span><span class="p">,</span> <span class="n">err</span> <span class="p">:=</span> <span class="n">json</span><span class="p">.</span><span class="n">Marshal</span><span class="p">(</span><span class="n">result_struct</span><span class="p">)</span>
</span><span class='line'><span class="k">if</span> <span class="n">err</span> <span class="p">!=</span> <span class="n">nil</span> <span class="p">{</span>
</span><span class='line'>    <span class="n">fmt</span><span class="p">.</span><span class="n">Printf</span><span class="p">(</span><span class="s">&quot;Error ocurred while marshaling data: %v\n&quot;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>
</span><span class='line'>    <span class="c1">// do stuff needed to recover from the error and such</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>So you catch errors as they happen, instead of catching an exception 4 levels higher with a lot of crappy stack trace. Error messages in the Go standard library are also very good, no more cryptic voodoo and Googling just to discover wth is that message.</p>

<p>As soon as I got a little confidence on at least how to organize a Go program I decided I wanted to try and start doing some small things, some book exercises and what not. So I got inspiration from <a href="http://xkcd.com/314/">XKCD</a> and created the <a href="http://isitcreepy.coredump.io/">Is it creepy?</a> site. Want to know if that person is too old or too young for you? Check it.</p>

<p>Note that the code is available on Github so if you want to check how Go looks, <a href="https://github.com/coredump/isitcreepy">go ahead</a>. Remember that this is a first program, and also that I over engineered some simple parts to check more advanced techniques (for my current level). Now I have some more ambitious plans for projects, but those will need to wait a little more reading and practice.</p>

<p>Thanks to <a href="https://plus.google.com/116078268286389936989/posts">Yves Junqueira</a>, that annoyed the hell out of me until I finally started putting effort in learning the language.</p>

<p>cya</p>

<p>PS: Changed the theme to light solarized. I like it.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Why I stop]]></title>
    <link href="http://coredump.io/blog/2012/06/23/why-i-stop/"/>
    <updated>2012-06-23T19:47:00-04:00</updated>
    <id>http://coredump.io/blog/2012/06/23/why-i-stop</id>
    <content type="html"><![CDATA[<p>Seems that every post I create is about changes, that can get annoying but I think that discussing the reasons behind those changes is important, interesting, or something like that. I don&rsquo;t really care.</p>

<!-- more -->


<h3>Why I stopped using Ubuntu</h3>

<p><strong>tl;dr</strong>: Canonical crap. I am using Arch Linux.</p>

<p>Debian is great. There&rsquo;s nothing better than apt in the planet to manage packages. Debian Project&rsquo;s commitment to free software is also great. The thing is that you end having to use Debian testing or unstable to have access to software on a timely manner. With time, you just decide that using Ubuntu is a good time saver: you install stuff that is basically Debian Sid (<em>unstable</em>) and it just works 98% of the time.</p>

<p>The problem is the whole Canonical cruft and crap that they add to Debian. I was watching <a href="http://twitter.com/crucially">Artur Bergman</a> talk during 2011 Surge Conference and part of his annoyed sighs was aimed at distros and the Linux kernel trying to do stuff more <em>user friendly</em> that ends being stupid on servers. That&rsquo;s how I felt with Ubuntu sometimes, in their effort to make an user friendly desktop they end pissing off users like me. Some of the ideas that I find horrible: upstart, the new display manager and don&rsquo;t even get me started on that ugly Compiz patch they call Unity Desktop. Why they could&rsquo;t just go with Gnome 3 that is great and works fine? Who knows.</p>

<p>All that quest for <em>user friendleness</em> ends adding a lot of crappy configs and layers and layers that, as all complex systems do, fails in miserable ways. It&rsquo;s not a common thing to happen I agree, but in the last Ubuntu upgrade my notebook started acting up like a spoiled child. Each update consisted in installing Ubuntu and removing every bad idea that Canonical included so I could get a system that, for me, was the ideal. In the end I was faced with the prospect of a full reinstall, so I went all the way and simply changed distros to Arch Linux.</p>

<p><img src="http://i.imgur.com/PZEZr.png"></p>

<p>From their <a href="https://wiki.archlinux.org/index.php/Arch%20Linux">wiki</a>:</p>

<blockquote><p>Arch Linux is an independently developed, i686/x86-64 general purpose GNU/Linux distribution versatile enough to suit any role. Development focuses on simplicity, minimalism, and code elegance. Arch is installed as a minimal base system, configured by the user upon which their own ideal environment is assembled by installing only what is required or desired for their unique purposes. GUI configuration utilities are not officially provided, and most system configuration is performed from the shell by editing simple text files. Based on a rolling-release model, Arch strives to stay bleeding edge, and typically offers the latest stable versions of most software.</p></blockquote>

<p>Is it easy and user friendly? No. How many fucks I give? 0</p>

<p><img class="left" src="http://i3.kym-cdn.com/photos/images/original/000/127/663/tumblr_lgf3pgDzLT1qh4nf6o1_400.gif" title="Fuck-o-meter A gauge showing -20 fucks given" ></p>

<p>At the end of the first install I had <em>choices</em>. Arch Linux uses that braindead <a href="http://en.wikipedia.org/wiki/Init#BSD-style">BSD style init</a>, but <a href="http://www.freedesktop.org/wiki/Software/systemd">systemd</a> was just a <em>pacman install</em> away and I took the plunge. I know I complained about systemd before but after using it for two months I want to change all my linux computers/server to use it. It&rsquo;s a pretty ingenious software, if you ignore the whole <em>journald</em> thing and use syslog.</p>

<p>I give credit that I only changed to Arch because my co-worker <a href="http://www.masterkorp.net/">Alfredo</a> uses it and kept bugging me to give it a try, so I did. Arch is a great distro for devs/sysadmins to have in their work computers because it&rsquo;s simple, updated and made for people that know how to use a computer &mdash; we don&rsquo;t need our computers to be friendly, we need them to be well oiled tools that integrate our body as an extra brain/member or anything cyberpunk-compatible you can think.</p>

<p>BTW you should check the crazy things Alfredo does. He is like a greasy monkey/coder that builds robots and monster cars on his free time.</p>

<h3>Why I stopped using Gnome</h3>

<p><strong>tl;dr</strong>: Tiling Window Managers, more keyboard and console use. Dotfiles at the end of the post.</p>

<p>After I changed from Ubuntu to Arch I started feeling that I was missing something. Had I been using mainstream stuff for so long that I forgot that Linux is about using the tools that you like best? Not that I dislike Gnome 3, I love it, but what else existed around?</p>

<p>Well, <a href="http://en.wikipedia.org/wiki/Tiling_window_manager">Tilling Window Managers</a> of course. Those weird, beautiful things. (I hope you read the Wikipedia article, I am not explaining what TWMs are).</p>

<p><a href="http://i.imgur.com/5m6Xm.png"><img class="right" src="http://i.imgur.com/5m6Xm.png" width="400" title="Screenshot of my dualhead Awesome WM setup" ></a></p>

<p>I tried <a href="http://xmonad.org/">xmonad</a> and <a href="http://awesome.naquadah.org/">Awesome WM</a>, and ended deciding for Awesome because of the way xmonad deals with multihead setups (<a href="http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#Multi_head_and_workspaces_.28desktops.29">it&rsquo;s really weird</a>). Awesome also uses Lua as &lsquo;customization/configuration&rsquo; language, Xmonad uses Haskell. I felt like I had better chances debugging lua than haskell (I can&rsquo;t even understand Haskell code, even more fix stuff).</p>

<p><a href="http://i.imgur.com/1FCVd.png"><img class="left" src="http://i.imgur.com/1FCVd.png" width="400" title="Screenshot of a screen with terminals tiled running vim, logs and git log" ></a></p>

<p>TWM and Awesome, specifically, are aimed at focusing on keyboard usage more than the mouse. To be honest I currently use 80% keyboard when doing my work. TWM are also great for people that like me spend most of the time dealing with terminals. Tiling was what I was doing when using multiple terminals on Terminator, so why don&rsquo;t use a WM that actually knows how to deal with tiled windows? And why lose screen space showing the useless desktop and what not? Makes no sense at all.</p>

<p><a href="http://i.imgur.com/sF0qH.png"><img class="right" src="http://i.imgur.com/sF0qH.png" width="400" title="Screenshot of weechat IRC client" ></a></p>

<p>This also caused me to focus more on console applications. At this moment I have <a href="http://aws.amazon.com/developertools/351">command line clients for EC2</a> (So I can skip using the web interface), a <a href="http://freecode.com/projects/scrot">screenshot tool</a>, a <a href="http://imgur.com/tools/">script that uploads images to imgur.com</a>, <a href="http://www.techdrivein.com/2011/05/mpd-ncmpc-music-nirvana-for-command.html">music player</a>, IRC/Jabber/Twitter client using <a href="http://www.bitlbee.org/">bitlbee</a>, etc. The extra benefit is that my computer uses way less memory than what it used when running all the bloat necessary for Gnome. If you check the screenshots you will notice that I still using Network Manager but it&rsquo;s an independent tool, I also use Gnome Keyring to manage SSH and GPG keys: those tools are simply the best in their areas and replacing that would be not a smart move (believe me I tried to replace NM with netcfg and that thing is horrible).</p>

<p>Finally, I&rsquo;ve got a <a href="https://github.com/coredump/dotfiles">dotfile repo</a> with my configurations, mostly because it&rsquo;s good to keep track of changes I do to my setup but if someone wants to get some ideas, feel free.</p>

<p>It&rsquo;s a never ending process, I guess. That&rsquo;s the beauty of FLOSS in general: choice to make things work the way you want and expand from there. No walled garden here, just a plain full of space and adventure.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ch-ch-ch-changes]]></title>
    <link href="http://coredump.io/blog/2012/03/11/ch-ch-ch-changes/"/>
    <updated>2012-03-11T17:24:00-04:00</updated>
    <id>http://coredump.io/blog/2012/03/11/ch-ch-ch-changes</id>
    <content type="html"><![CDATA[<p>So, since last post some changes happened, most people that follow me on twitter/G+/Facebook or Linkedin are probably aware of them but well, I needed to post something :)</p>

<!-- more -->


<h3>From <code>bash</code> to <code>zsh</code></h3>

<p>I changed my shell after years using <code>bash</code>. <a href="http://www.zsh.org"><code>zsh</code></a> makes for a somewhat better experience and has some options that really help. I tried to use <a href="http://fishshell.com"><code>fish</code></a> some years ago but it let me down, so I was a little scared of changing shells again but now after almost two weeks using <code>zsh</code> I am comfortable to say that it was a good choice.</p>

<p>You can check my <code>.zshrc</code> on <a href="https://gist.github.com/6d5393b2adc39952d6ba">this link</a>. I based it on @wisqnet&rsquo;s one plus some bashisms I like (!$ comes to mind). This is a screenshot from a simple shell showing the <code>rake</code> command completion options inside a git repo (master branch, uncommited changes):</p>

<p><img src="http://i.imgur.com/8LhyV.png" alt="zsh screenshot" /></p>

<h3>From <code>rvm</code> to <code>rbenv</code></h3>

<p>I never had any big problems with <a href="http://beginrescueend.com/">RVM</a>, but <a href="https://github.com/sstephenson/rbenv">rbenv</a> seems to be so less intrusive and works so well that it was a no-brainer. Remember to install the <a href="https://github.com/sstephenson/ruby-build">ruby-build</a> too so you don&rsquo;t suffer too much to install new rubies (it provides the <code>rbenv install</code> command).</p>

<h3>From Shopify to Vox Media, Inc.</h3>

<p>After almost a year working with the fine people at <a href="http://www.shopify.com">Shopify</a> I changed airs to <a href="http://www.voxmedia.com">Vox Media, Inc</a>. Vox Media is the parent company for all star sites like <a href="http://www.theverge.com">The Verge</a>, Vox Games (currently it&rsquo;s inside The Verge but stay tuned) and <a href="http://www.sbnation.com">SBNation</a>.</p>

<p>Change is always hard and I enjoyed my time at Shopify but I am sure that the new challenges at Vox Media will keep me happy for a long time too. The team is awesome and it&rsquo;s the kind of work I enjoy.</p>

<p>I think this is it.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Debugging segfaults from logs to gdb]]></title>
    <link href="http://coredump.io/blog/2012/02/23/debugging-segfaults-from-logs-to-gdb/"/>
    <updated>2012-02-23T22:29:00-05:00</updated>
    <id>http://coredump.io/blog/2012/02/23/debugging-segfaults-from-logs-to-gdb</id>
    <content type="html"><![CDATA[<p>So this week after a version upgrade on GraphicsMagick we got some segfaults on our servers. Nothing terrible, twelve segfaults or close to that on a 24 hour period. The only information was a line on <code>/var/log/kernel.log</code>:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Feb 22 13:28:27 serverXX kernel: [1953364.275653] gm[16356]: segfault at 0 ip 00007fd137bd41e0 sp 00007fff5770dcd0 error 6 in libGraphicsMagick.so.3.7.0[7fd1379b9000+29d000]</span></code></pre></td></tr></table></div></figure>


<p>No core dumps since <code>ulimit -c</code> is zeroed. What to do to at least have an idea of what is happening?</p>

<!--more-->


<p>Well luckily I build the packages for our internal use so I had he build directory available with the unstripped binaries, with that it&rsquo;s trivial to use the GNU Debugger (gdb) and find what is going on.</p>

<p>First, notice that the segfault is happening on a shared lib, this is <em>per se</em> a complication. You see, when you have the segfault to happen on a non-shared lib binary the <em>ip</em> (instruction pointer)  value points to the instruction on the binary, in this case it is pointing to a shared lib, dynamically linked on the <code>gm</code> binary.</p>

<p>To find the instruction, then, subtract the offset given on the segfault message (it&rsquo;s the 7fd1379b9000 part after the lib&rsquo;s name) from the <em>ip</em>:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>00007fd137bd41e0−7fd1379b9000 = 21B1E0</span></code></pre></td></tr></table></div></figure>


<p>Finally, using GDB you can check what is happening @ that addres on the library, provided you have an unstripped object (you can get it with -dbg packages on debian/ubuntu):</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>(gdb) info symbol 0x21B1E0
</span><span class='line'>WriteOnePNGImage + 13648 in section .text</span></code></pre></td></tr></table></div></figure>


<p>There&rsquo;s the culprit. You can also find some info on the stripped library using <code>nm</code>, remember that <code>nm</code> will not show anything on shared libs if not used with the <code>-D</code> option (showing just part of the output):</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>root@XXX:~# nm -D /usr/lib/libGraphicsMagick.so.3.7.0                                                                                                                                                             
</span><span class='line'>0000000000104650 T AccessCacheViewPixels
</span><span class='line'>0000000000104700 T AccessDefaultCacheView
</span><span class='line'>00000000000ea030 T AccessDefinition
</span><span class='line'>00000000001061e0 T AccessImmutableIndexes
</span><span class='line'>0000000000106170 T AccessMutableIndexes
</span><span class='line'>[...]
</span><span class='line'>0000000000210d50 T RegisterJP2Image
</span><span class='line'>0000000000213170 T RegisterPNGImage
</span><span class='line'>0000000000210cf0 T UnregisterJP2Image
</span><span class='line'>0000000000213110 T UnregisterPNGImage</span></code></pre></td></tr></table></div></figure>


<p>You can see that there are some PNG related symbols around the address 0x21xxxx. If you check the code for <a href="http://graphicsmagick.hg.sourceforge.net/hgweb/graphicsmagick/graphicsmagick/file/41dae3dd3710/coders/png.c#l5834">GraphicsMagic PNG support</a> you will see that <code>WritePNGImage</code> is part of the <code>RegisterPNGImage</code> code.</p>

<p>In this case I correlated the logs and found that the request that caused the segfault completed without problems and the PNG image was correctly generated, so my conclusion is that the segfault is happening on some non-crucial part of those functions, but there&rsquo;s not a lot of things to do exactly pinpoint the problem.</p>

<p><code>gdb</code>, <code>nm</code> and <code>ldd</code> are powerful tools when debugging or trying to do a postmortem on a segfault. It would be easier to find what exactly is going on with a core dump and maybe more info.</p>

<p>cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[HoardD javascript support (and #monitoringsucks)]]></title>
    <link href="http://coredump.io/blog/2012/02/13/hoardd-javascript-support/"/>
    <updated>2012-02-13T17:44:00-05:00</updated>
    <id>http://coredump.io/blog/2012/02/13/hoardd-javascript-support</id>
    <content type="html"><![CDATA[<p><strong>First things first</strong>: the latest <a href="https://github.com/coredump/hoardd/commit/4343ac857a9dc7509b8b9221a451cbd59982cf0c">revision of HoardD on github</a> already supports scripts written in pure javascript. Really it was easy to make it work but I kinda overlooked it on the first version. The <a href="https://github.com/coredump/hoardd/blob/master/README.md">README.md</a> is already updated.</p>

<p><strong>Second</strong>: most of you probably know the #monitoringsucks <em>movement/hashtag/discussions</em>. I totally agree that the current monitoring tools only do part of the job and getting them to work together is horrible. I have some ideas on how to solve the problem, but the path from idea to code is a long one. You can read <a href="http://gigaom.com/2012/02/12/why-monitoring-sucks-for-now/">this post</a> about monitoring and understand what is this all about.</p>

<p>Even so, if you are using HoardD with the default sample time and sending intervals, you are getting data 1 minute old. This is normally cool for simple graphing but if you want a realtime feeling I suggest you to send data everytime you sample it. Your graphs will also look better, and the overhead of 6 connections each minute is negligible on a true server.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Announcing HoardD]]></title>
    <link href="http://coredump.io/blog/2012/02/10/announcing-hoardd/"/>
    <updated>2012-02-10T19:50:00-05:00</updated>
    <id>http://coredump.io/blog/2012/02/10/announcing-hoardd</id>
    <content type="html"><![CDATA[<p>Getting back to work as a full time sysadmin was great, I got back to speed on scalability, updated my toolbox and learnt about other fantastic tools, like <a href="http://graphite.wikidot.com/">Graphite</a>. Graphite is a graphing tool, extremely configurable and scalable. One thing, though, bothered me: the lack of good tools to send server metrics to it. I tried collectd graphite plugins and none did what I wanted the way I wanted.</p>

<p>So I decided to flex my node.js dev muscles and here is HoardD. This is a <a href="http://www.nodejs.org">node.js</a> app written in <a href="http://coffeescript.org/">coffee-script</a> that basically runs scripts and tools to get information about a server and sends it to carbon (Graphite&rsquo;s storage backend). It&rsquo;s easily expansible to include more metrics and very very fast and small (11MB or so, depending on scripts loaded, most of it is node).</p>

<!--more-->


<p>At this moment there are basic scripts (uptime, memory, cpu, vmstat) and also 2 DB specific ones (redis and mysql). I will be fixing and adding scripts as I need on my day to day work, but the tool is already very usable. I am accepting push requests and patches to.</p>

<p>You can get HoardD on my <a href="https://github.com/coredump/hoardd">github repo</a>, there&rsquo;s more info on the README there.</p>

<p>Below are some examples of graphics created with Graphite using the metrics sent by HoardD:</p>

<p>CPU stats from <code>vmstat</code>. Not a very busy server right? <img src="http://i.imgur.com/MDYBB.png" alt="vmstat graph" /></p>

<p>Redis memory usage. <img src="http://i.imgur.com/PDoU8.png" alt="Redis memory" /></p>

<p>MySQL Bytes transferred and received: <img src="http://i.imgur.com/slEQT.png" alt="&quot;mysql network&quot;" /></p>

<p>MySQL counters for various operations: <img src="http://i.imgur.com/6qaWf.png" alt="&quot;mysql counters&quot;" /></p>

<p>Catching the exact moment when InnoDB flushes its dirty pages <img src="http://i.imgur.com/r6TzD.png" alt="&quot;innodb pages&quot;" /></p>

<p>MySQL slave lag: <img src="http://i.imgur.com/B7uk3.png" alt="&quot;mysql slave lag&quot;" /></p>

<p>cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Getting the correct name on Gnome 3 Chromium windows]]></title>
    <link href="http://coredump.io/blog/2012/02/03/getting-the-correct-name-on-gnome-3-chromium-windows/"/>
    <updated>2012-02-03T09:24:00-05:00</updated>
    <id>http://coredump.io/blog/2012/02/03/getting-the-correct-name-on-gnome-3-chromium-windows</id>
    <content type="html"><![CDATA[<p><a href="http://www.gnome.org/gnome-3/">Gnome 3</a> is awesome, by far the best user experience I ever had. It&rsquo;s fast, does exactly what I need and has sensible defaults.</p>

<p>One problem that I had for some weeks &mdash; after some upgrade I am sure &mdash; was that <code>Alt+Tab</code> and <code>Alt+(key below ESC)</code> behavior with Google Chromium windows was completely annoying: all my browser windows, including the ones I use <code>--app</code> and a different data directory, were grouped under &ldquo;Google Chromium&rdquo; icon, like in this screenshot I took (click on it for full size):</p>

<!--more-->


<p><a href="http://i.imgur.com/91vHm.jpg"><img class="center" src="http://i.imgur.com/91vHml.jpg"></a></p>

<p>As you can see the Gmail screen is under the Google Chromium &ldquo;group&rdquo; during the <code>Alt+Tab</code>. This is ANNOYING. This happens because Gnome 3 uses the <code>WM_CLASS</code> property from X to decide what is going to be considered the same <em>Application</em>, this is a change from the Gnome 2 behavior, when it considered Windows, not Applications, for grouping. Nice test to do (you have to click a window after running the command):</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='console'><span class='line'><span class="gp">$</span> xprop WM_CLASS
</span><span class='line'><span class="go">WM_CLASS(STRING) = &quot;chromium-browser&quot;, &quot;Chromium-browser&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p>So, how to fix it? Well, it&rsquo;s pretty very trivial. What must be done is to add the <code>--class=value</code> to your .desktop <code>Exec</code> line. Also, add StartupWMClass with the same value to give window managers and docks a tip of what application that belongs, this is my <code>Gmail.Desktop</code>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='cfg'><span class='line'><span class="c">#!/usr/bin/env xdg-open</span>
</span><span class='line'>
</span><span class='line'><span class="k">[Desktop Entry]</span>
</span><span class='line'><span class="na">Version</span><span class="o">=</span><span class="s">1.0</span>
</span><span class='line'><span class="na">Type</span><span class="o">=</span><span class="s">Application</span>
</span><span class='line'><span class="na">Terminal</span><span class="o">=</span><span class="s">false</span>
</span><span class='line'><span class="na">Icon[en_US]</span><span class="o">=</span><span class="s">/home/coredump/Pictures/Gmail-Icon.png</span>
</span><span class='line'><span class="na">Name[en_US]</span><span class="o">=</span><span class="s">Gmail</span>
</span><span class='line'><span class="na">Exec</span><span class="o">=</span><span class="s">chromium-browser --user-data-dir=&quot;/home/coredump/.config/gmail-chromium&quot; --app=&quot;https://mail.google.com&quot; --class=Gmail</span>
</span><span class='line'><span class="na">Comment[en_US]</span><span class="o">=</span><span class="s">Gmail on Chromium</span>
</span><span class='line'><span class="na">Name</span><span class="o">=</span><span class="s">Gmail</span>
</span><span class='line'><span class="na">Comment</span><span class="o">=</span><span class="s">Gmail on Chromium</span>
</span><span class='line'><span class="na">Icon</span><span class="o">=</span><span class="s">/home/coredump/Pictures/Gmail-Icon.png</span>
</span><span class='line'><span class="na">StartupWMClass</span><span class="o">=</span><span class="s">Gmail</span>
</span><span class='line'><span class="na">StartupNotify</span><span class="o">=</span><span class="s">true</span>
</span></code></pre></td></tr></table></div></figure>


<p></p>

<p>Just remember to close all Chromium sessions (including the background one if you use it) before testing it since it will reuse the binary that is not using <code>--class</code> and you will lose minutes in rage (I did). After doing that with as many <code>.desktop</code> files you want, you will have the expected behavior on <code>Alt+Tab</code>:</p>

<p><a href="http://i.imgur.com/2BCal.jpg"><img class="center" src="http://i.imgur.com/2BCall.jpg"></a></p>

<p>Three distinct browser sessions, as it was supposed to be. This problem also affects some docks like <a href="http://wiki.go-docky.com/index.php?title=Welcome_to_the_Docky_wiki">Docky</a> and even <a href="https://launchpad.net/bamf/ubuntu">BAMF</a> (the thing Unity uses to match windows).</p>

<p>cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Async callbacks are async]]></title>
    <link href="http://coredump.io/blog/2012/01/27/async-callbacks-are-async/"/>
    <updated>2012-01-27T17:28:00-05:00</updated>
    <id>http://coredump.io/blog/2012/01/27/async-callbacks-are-async</id>
    <content type="html"><![CDATA[<p>So I&rsquo;ve been spending some of my free time writing things for <a href="http://nodejs.org">Node.js</a>. It&rsquo;s awesome if you know javascript or, like me, decides to <a href="http://coffeescript.org">stop suffering and use CoffeeScript</a>. One of the strangest moments while learning to deal with the async, mono-threaded nature of Node was a code using <code>exec</code> like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='coffeescript'><span class='line'><span class="nv">exec    = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">).</span><span class="nx">exec</span>
</span><span class='line'>
</span><span class='line'><span class="nv">result =</span>
</span><span class='line'>    <span class="nv">error: </span><span class="kc">null</span>
</span><span class='line'>    <span class="nv">stdout: </span><span class="s1">&#39;&#39;</span>
</span><span class='line'>    <span class="nv">stderr: </span><span class="s1">&#39;&#39;</span>
</span><span class='line'><span class="nx">exec</span> <span class="s1">&#39;echo testing&#39;</span><span class="p">,</span> <span class="nf">(error, stdout, stderr) -&gt;</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">error</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stdout&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stdout</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stderr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stderr</span>
</span><span class='line'><span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;&#39;#{result[&#39;error&#39;]}&#39; &#39;#{result[&#39;stderr&#39;]}&#39; &#39;#{result[&#39;stdout&#39;]}&#39;&quot;</span>
</span></code></pre></td></tr></table></div></figure>




<!--more-->


<p>This is the js result compiled by coffee:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">exec</span><span class="p">,</span> <span class="nx">result</span><span class="p">;</span>
</span><span class='line'>  <span class="nx">exec</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">).</span><span class="nx">exec</span><span class="p">;</span>
</span><span class='line'>  <span class="nx">result</span> <span class="o">=</span> <span class="p">{</span>
</span><span class='line'>    <span class="nx">error</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
</span><span class='line'>    <span class="nx">stdout</span><span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
</span><span class='line'>    <span class="nx">stderr</span><span class="o">:</span> <span class="s1">&#39;&#39;</span>
</span><span class='line'>  <span class="p">};</span>
</span><span class='line'>  <span class="nx">exec</span><span class="p">(</span><span class="s1">&#39;echo testing&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="nx">stdout</span><span class="p">,</span> <span class="nx">stderr</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">error</span><span class="p">;</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stdout&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stdout</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stderr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stderr</span><span class="p">;</span>
</span><span class='line'>  <span class="p">});</span>
</span><span class='line'>  <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;&#39;&quot;</span> <span class="o">+</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;&#39; &#39;&quot;</span> <span class="o">+</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stderr&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;&#39; &#39;&quot;</span> <span class="o">+</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stdout&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;&#39;&quot;</span><span class="p">);</span>
</span><span class='line'><span class="p">}).</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span></code></pre></td></tr></table></div></figure>


<p>It took me some minutes to understand that callback functions like the one that exec takes aren&rsquo;t really executed synchronously, they are more like fire and forget, what really happens with this code is that the <code>exec</code> is called and the flow continues, arriving at <code>console.log</code> before the callback has actually finished and updated the values. I am sure that most of the js programmers are looking at me with their &lsquo;noob&rsquo; faces but as I said, I am testing and learning as I go!</p>

<p>The code below illustrates it very well:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='coffeescript'><span class='line'><span class="nv">exec    = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">).</span><span class="nx">exec</span>
</span><span class='line'>
</span><span class='line'><span class="nv">result =</span>
</span><span class='line'>    <span class="nv">error: </span><span class="kc">null</span>
</span><span class='line'>    <span class="nv">stdout: </span><span class="s1">&#39;&#39;</span>
</span><span class='line'>    <span class="nv">stderr: </span><span class="s1">&#39;&#39;</span>
</span><span class='line'><span class="nx">exec</span> <span class="s1">&#39;sleep 10&#39;</span><span class="p">,</span> <span class="nf">(error, stdout, stderr) -&gt;</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">error</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stdout&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stdout</span>
</span><span class='line'>    <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;stderr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">stderr</span>
</span><span class='line'>    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;&#39;#{result[&#39;error&#39;]}&#39; &#39;#{result[&#39;stderr&#39;]}&#39; &#39;#{result[&#39;stdout&#39;]}&#39;&quot;</span>
</span><span class='line'><span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;Out the function&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p>And this is the result of running this code. As you can see, the code reaches the <em>Out of the function</em> line and THEN finishes waiting for the callback to finish.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='coffeescript'><span class='line'><span class="nx">coredump@janie</span><span class="o">:~</span> <span class="nx">$</span> <span class="nx">coffee</span> <span class="nx">test</span><span class="p">.</span><span class="nx">coffee</span>
</span><span class='line'><span class="nx">Out</span> <span class="nx">the</span> <span class="nx">function</span>
</span><span class='line'><span class="s1">&#39;null&#39;</span> <span class="s1">&#39;&#39;</span> <span class="s1">&#39;&#39;</span>
</span><span class='line'><span class="nx">coredump@janie</span><span class="o">:~</span> <span class="nx">$</span>
</span></code></pre></td></tr></table></div></figure>


<p>Functions like that are common specially on browser/javascript applications and force you to think differently about program flow and how exactly to solve that. If the <code>console.log</code> line is moved <em>inside</em> the callback function body, it works, but again it may end printing on a totally different time than what you intended. There are talks and a feature request for Node to support a synchronous version of exec and relatives, but if this is going to happen it will be on version 0.7 or later.</p>

<p>cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Me and Linux]]></title>
    <link href="http://coredump.io/blog/2011/08/25/me-and-linux/"/>
    <updated>2011-08-25T19:27:00-04:00</updated>
    <id>http://coredump.io/blog/2011/08/25/me-and-linux</id>
    <content type="html"><![CDATA[<p>So, 20 years ago Linus was sending his now famous Usenet message about a new hobby. It’s a big date, 20 years and that went from a small project to what we have now and pretty much my only way to make money and live :)</p>

<!--more-->


<p>Me and Linux go way back to 1997, the first Slackware installs using too many disks, the long hours trying to get X to work on those blasted Trident cards.</p>

<p>It was a rough beginning, I usually say that in those times Linux didn’t had users, he had enthusiasts. Me and Linux didn’t hit very well in the first time too. It took a while until I started to really get into it, maybe a year or so watching co-workers battle kernel configurations and etc.</p>

<p>But, when we finally started, it was great. From Slackware I moved to SuSE, then finally Debian (and Ubuntu) where I am to this day, and I could not imagine myself doing the stuff I do with any other OS (yes *BSD I’m looking at you, someday we will talk again).</p>

<p>So, happy birthday Linux, and thanks to all kernel developers and people that make this OS so great.</p>

<p>cya</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Generating a self-signed SSL Certificate, commands only]]></title>
    <link href="http://coredump.io/blog/2011/08/19/self-signed-ssl-cert/"/>
    <updated>2011-08-19T17:11:00-04:00</updated>
    <id>http://coredump.io/blog/2011/08/19/self-signed-ssl-cert</id>
    <content type="html"><![CDATA[<p>This post is one of those quick notes to myself, so I can stop searching this info everytime I need it. This is the sequence of commands to create a self-signed SSL certificate. If you need to know what you are doing please go read <a href="http://www.akadia.com/services/ssh_test_certificate.html">this post</a>.</p>

<p>I suggest you to paste them one by one, and by <strong>you</strong> I mean the <strong>future me</strong>, that will try to paste them all at once and do something stupid.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>openssl genrsa -des3 -out server.key 1024
</span><span class='line'>openssl req -new -key server.key -out server.csr
</span><span class='line'>cp server.key server.key.org
</span><span class='line'>openssl rsa -in server.key.org -out server.key
</span><span class='line'>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
</span></code></pre></td></tr></table></div></figure>


<p>cya.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Finding Those Empty Things on Chef With Knife]]></title>
    <link href="http://coredump.io/blog/2011/08/14/finding-those-empty-things-on-chef-with-knife/"/>
    <updated>2011-08-14T19:27:00-04:00</updated>
    <id>http://coredump.io/blog/2011/08/14/finding-those-empty-things-on-chef-with-knife</id>
    <content type="html"><![CDATA[<p>So after a time with a team dealing with <a href="http://www.opscode.com/chef/">chef</a> and knife you end having a pretty vast chef repository. Git helps but it can get a little messy, use the little loops below to search for empty roles run lists or roles with no nodes. They work on chef 0.9, chef 0.10 apparently has some fancy search plugin to do the same (and more) but I haven&rsquo;t tested it yet.</p>

<p>Also, they were originally one liners but I changed it for the sake of readability.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="k">for </span>file in roles/*
</span><span class='line'><span class="k">do </span>
</span><span class='line'><span class="k">  </span><span class="nv">role</span><span class="o">=</span><span class="k">$(</span>basename <span class="nv">$file</span><span class="k">)</span>
</span><span class='line'>  <span class="nb">echo</span> -n <span class="s2">&quot;Role ${role%.rb}: &quot;</span>
</span><span class='line'>  knife search node <span class="s2">&quot;role:${role%.rb}&quot;</span> -i |grep -v <span class="s1">&#39;^$&#39;</span> |wc -l
</span><span class='line'><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure>


<p>You may not have a directory with roles, so you may need to use that:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="k">for </span>file in <span class="k">$(</span>knife role list|egrep -v <span class="s1">&#39;\[|\]&#39;</span>|tr -d <span class="s1">&#39; ,&quot;&#39;</span><span class="k">)</span>
</span><span class='line'><span class="k">do </span>
</span><span class='line'><span class="k">  </span><span class="nv">role</span><span class="o">=</span><span class="k">$(</span>basename <span class="nv">$file</span><span class="k">)</span>
</span><span class='line'>  <span class="nb">echo</span> -n <span class="s2">&quot;Role ${role%.rb}: &quot;</span>
</span><span class='line'>  knife search node <span class="s2">&quot;role:${role%.rb}&quot;</span> -i |grep -v <span class="s1">&#39;^$&#39;</span> |wc -l;
</span><span class='line'><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure>


<p>To search for those pesky empty <em>run_lists</em> (rare, but it happens, automatic cloud instaces, etc&hellip;)</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="k">for </span>node in <span class="k">$(</span>knife node list |egrep -v <span class="s1">&#39;\[|\]&#39;</span> |tr -d <span class="s1">&#39; &quot;,&#39;</span><span class="k">)</span>
</span><span class='line'><span class="k">do </span>
</span><span class='line'><span class="k">  </span><span class="nb">echo</span> <span class="s2">&quot;Node $node:&quot;</span>
</span><span class='line'>  knife node show -r <span class="nv">$node</span>
</span><span class='line'>  <span class="nb">echo</span> <span class="s2">&quot;-----------&quot;</span>
</span><span class='line'><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure>


<p>Yes, in this last case you will still have to do some manual work and actually find the empty run lists. Search for empty lines, the only ones present on the file will be the empty run lists.</p>

<p>That&rsquo;s it, cya!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Blog]]></title>
    <link href="http://coredump.io/blog/2011/08/14/new-blog/"/>
    <updated>2011-08-14T18:02:00-04:00</updated>
    <id>http://coredump.io/blog/2011/08/14/new-blog</id>
    <content type="html"><![CDATA[<p>So, this is a brand new blog, where I will focus on sysadmin and coding stuff. It&rsquo;s built on the awesome <a href="http://octopress.org">Octopress</a> framework that generates full static content from markdown files and even deploys it using rsync to your site (or github pages, if you are using it). The thing is awesome, I swear.</p>

<p>Stay tunned for more posts on the days coming, I promise that I will try to keep this updated! :)</p>

<p>cya!</p>
]]></content>
  </entry>
  
</feed>
