Fixing the munin iostat graph on slicehost

Out of the box the munin iostat plugin on Ubuntu doesn't work on
Slicehost. When looking for drives to monitor it skips things that end
in numbers assuming those are partitions of disks it already knows
about. This breaks on Slicehost where the only things exposed to you
as "disks" end in numbers. The following worked to fix the plugin for me:

sudo sed -i 's@if (\$tmpnam =~ /\\d[+]\$/ ) {@if (\$tmpnam =~ /(ram|loop)\d+$/ ) {@' /etc/munin/plugins/iostat

Posted

Ever delete or change the password for debian-sys-maint user in Mysql?

Debian/Ubuntu scripts get grumpy if their mysql user goes away or has it's password changed. Happens to me especially often when cloning slaves. 
Try this out to fix it:
mysql -uroot -p -vv -e "GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@localhost IDENTIFIED BY '`sudo awk '$1 == "password" {print $3}' /etc/mysql/debian.cnf | head -1`'; FLUSH PRIVILEGES;"

Filed under  //  mysql   ubuntu  
Posted

PATH Environment Variable for Rails using Passenger on OS X

Rails couldn't find my ImageMagick binaries. I saw a post that suggests creating a script that wraps ruby and bootstraps the path. I figured there had to be way to do it in apache; using SetEnv in my apache config worked for me.

Put something like this in the VirtualHost (or wherever passenger is set up):

Filed under  //  apache   osx   passenger   rails  
Posted

munin-node-configure rules

It occurred to me that I should be able to do whatever ubuntu does to automatically choose the right plugins when setting up munin-node. So I went looking and found munin-node-configure in all it's glory. Re-purposing a server image for mysql just a little bit easier:

Filed under  //  munin  
Posted

Updated YC Company Hosting Stats

Previous versions are here and here (thanks cperciva). The standout change is the rise of Slicehost.
This time around the script pulled domains straight from YC's FAQ.

Slicehost LLC                            14        anyvite.com        auctomatic.com        cloudkick.com        echodio.com        foodoro.com        heyzap.com        ididwork.com        insoshi.com        mightyquiz.com        picwing.com        polleverywhere.com        posterous.com        tipjoy.com        voxli.comSoftLayer Technologies Inc.              14        280north.com        appjet.com        bountii.com        chatterous.com        disqus.com        fliggo.com        getdropbox.com        heysan.com        scribd.com        slinkset.com        snaptalent.com        startuply.com        virtualmin.com        xobni.comAmazon.com, Inc.                         13        backtype.com        divvyshot.com        fathomdb.com        frogmetrics.com        fuzzwich.com        heroku.com        jamglue.com        socialbrowse.com        textpayme.com        thesixtyone.com        webmynd.com        zecter.com        zumodrive.comRackspace.com, Ltd.                       4        inklingmarkets.com        omgpop.com        snipd.com        ticketstumbler.comThePlanet.com Internet Services, Inc.     3        adpinion.com        mixwit.com        reble.fmGoDaddy.com, Inc.                         3        playturf.net        splashup.com        wundrbar.comServerBeach                               2        addher.com        clickpass.compair Networks                             2        co2stats.com        snipshot.comPeer 1 Network Inc.                       1        rescuetime.comHurricane Electric, Inc.                  1        octopart.comiWeb Technologies Inc.                    1        popcuts.comInternap Network Services Corporation     1        loopt.comRIPE Network Coordination Centre          1        songkick.comJustin.tv, Inc.                           1        justin.tvLevel 3 Communications, Inc.              1        airbnb.comGlobal Netoptex, Inc                      1        clickfacts.comLinode                                    1        draftmix.comnLayer Communications, Inc.               1        reddit.comeNom, Incorporated                        1        likebetter.comLayered Technologies, Inc.                1        buxfer.comBitPusher, LLC                            1        wufoo.comWeebly, Inc.                              1        weebly.comNoZone, Inc.                              1        thinkature.comGlobal Net Access, LLC                    1        contestmachine.comTotal # of Domains                       71Total # of Providers                     24

Filed under  //  ruby   yc  
Posted

Better wildcarded subdomains for testing locally on OS X

Locally testing apps that let users create their own subdomains can be a pain. As much as I wish it were as easy as putting "*" in /etc/hosts as a wildcard, it has to be more complicated. For a long time I had a DNS server running locally that resolved everything under .dev to 127.0.0.1, but when I replaced my hard drive recently I went shopping for a better solution. I found one, proxy auto config files.

With a little help from stack overflow I came up with the following to make anything that ends in .dev route to localhost:

function FindProxyForURL(url, host) {
  if (shExpMatch(host,"*.dev")) {
    var port = url.match(/^\w{3,5}:\/\/[^:\/]*(:(\d+))?/)[2];
    var proxy = "PROXY localhost";
    if(port){proxy += ":" + port;}
    return proxy;
  }
  return "DIRECT";
}

Put the above in a file somewhere (I named mine ~/.proxy.pac) then to add it go to Network in System Prefences and add it to Proxies in advanced mode:
System_preferences

This will work for Safari. You can add it again in the Firefox proxies setting, but even better is to just install the System Proxy extension that will make Firefox use the system wide proxy settings. For IE testing in VMWare I just replaced "localhost" in the var proxy = "PROXY localhost"; line with the IP of my mac that VMWare shares with the IE VM. IE also seemed to deal better with a pac file accessible via an HTTP URL instead of a file path so I hosted the IE pac file on my local webserver.

Filed under  //  osx  
Posted

RSpec has profiling built in. Awesome.

--format profile:spec/profile.txt

Add the above to spec/spec.opt

Filed under  //  rspec  
Posted

Zsh Capistrano Task Completion on OS X

The Zsh task completion I found for Capistrano was a bit out of date.

The following is working for me:

_cap_does_task_list_need_generating () {
  if [ ! -f .cap_tasks ]; then 
    return 0;
  else
    accurate=$(stat -f%m .cap_tasks)
    changed=$(stat -f%m config/deploy.rb)
    return $(expr $accurate '>=' $changed)
  fi
}

_cap () {
  if [ -f config/deploy.rb ]; then
    if _cap_does_task_list_need_generating; then
      echo "\nGenerating .cap_tasks..." > /dev/stderr
      cap -vT | awk 'FB != 1 {if ($0 ~ /^$/){FB=1}else{print $2}}' > .cap_tasks
    fi
    compadd `cat .cap_tasks`
  fi
}

compdef _cap cap

Based on rake task completion.
Put it somewhere like ~/.zsh/cap_completion and add the following to ~/.zshrc or ~/.zprofile

 # enable completion if you haven't already
autoload -U compinit
compinit
 
# load capistrano completion
source ~/.zsh/cap_completion

Filed under  //  capistrano   osx   zsh  
Posted