<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-gb"><title type="text">Barking Iguana</title>
<subtitle type="text">Tests are for life, not just when you feel like it</subtitle>

<link rel="alternate" type="text/html" href="http://barkingiguana.com/?source=feed" />
<id>tag:barkingiguana.com,2005:49231934267467cd6f9473e1d60d3904</id>
<generator uri="http://textpattern.com/" version="4.0.5">Textpattern</generator>
<updated>2010-07-08T12:56:30Z</updated>
<author>
		<name>Craig Webster</name>
		<email>craig@barkingiguana.com</email>
		<uri>http://barkingiguana.com/</uri>
</author>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/BarkingIguana" /><feedburner:info uri="barkingiguana" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-07-07T11:14:24Z</published>
		<updated>2010-07-06T17:29:17Z</updated>
		<title type="html">My Dot Files: Dot Aliases</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/i9zBEc8DGcw/my-dot-files-dot-aliases" />
		<id>tag:barkingiguana.com,2010-07-06:49231934267467cd6f9473e1d60d3904/98b4cccc2e939b17a05641db3936af6d</id>
		
		
		<summary type="html">
&lt;p&gt;This is the first part of a series in which I'll document the various dotfiles I use to support my work, making it easier and more enjoyable.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt; and &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt; every day at work. To stop my fingers wearing down I've created short aliases for the most common tasks I need to do.&lt;/p&gt;

&lt;p&gt;Stick these in &lt;code class="bash"&gt;~/.aliases&lt;/code&gt;.&lt;/p&gt; 

&lt;pre&gt;&lt;code class="bash"&gt;# ~/.aliases
# Record how much I've used various Git commands:
#   &lt;a href="http://github.com/icefox/git-achievements"&gt;http://github.com/icefox/git-achievements&lt;/a&gt;
alias git="git-achievements"

# Working with Git
alias g='git'
alias gs='git status'
alias gc='git commit'
alias gca='git commit -a'
alias ga='git add'
alias gco='git checkout'
alias gb='git branch'
alias gm='git merge'
alias gd="git diff"

# Working with Rails
alias s='script/server'
alias c='script/console'
alias m='rake db:migrate'
alias r='rake'

# Open the current directory in TextMate
alias e='mate .'

# Serve the contents of the current directory over HTTP
alias serve="ruby -rwebrick -e\"s = WEBrick::HTTPServer.new(:Port =&gt; 3000, :DocumentRoot =&gt; Dir.pwd); trap('INT') { s.shutdown }; s.start\""&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now source the aliases file from your &lt;code class="bash"&gt;~/.profile&lt;/code&gt; to use them.&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;# ~/.profile
for I in aliases; do
  [ -f ~/.$I ] &amp;&amp; . ~/.$I
done&lt;/code&gt;&lt;/pre&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/i9zBEc8DGcw" height="1" width="1"/&gt;</summary>

<category term="snippets" />
<category term="rails" />
<category term="git" />
<feedburner:origLink>http://barkingiguana.com/2010/07/07/my-dot-files-dot-aliases?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-04-12T09:16:50Z</published>
		<updated>2010-04-11T22:21:46Z</updated>
		<title type="html">An updated command prompt</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/3BWwITdlYwA/an-updated-command-prompt" />
		<id>tag:barkingiguana.com,2010-04-11:49231934267467cd6f9473e1d60d3904/cf63973bdbd9da0d57134a73d9ad8eca</id>
		
		
		<summary type="html">
&lt;p&gt;It's been a while since I &lt;a href="http://barkingiguana.com/2008/11/15/get-the-current-git-branch-in-your-command-prompt"&gt;added the current Git branch to my command prompt&lt;/a&gt; to better aid my development efforts. Since then I've started working with several versions of Ruby and find myself working more frequently in situations where the exit status of the last command is a useful thing to know. I've updated my prompt to look like this:&lt;/p&gt;

&lt;img src="http://barkingiguana.com/images/15.jpg" alt="A screen-shot of my command prompt showing username, hostname, exit code of last command, Ruby interpreter information, current working directory and Git information" /&gt;

&lt;p&gt;To get this I declare &lt;code class="bash"&gt;$PS1&lt;/code&gt; like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;# Show the exit code of the last command.
# Idea stolen from &lt;a href="http://twitter.com/mathie"&gt;@mathie&lt;/a&gt;.
function last_exit_code() {
  local code=$?
  if [ $code = 0 ]; then
    printf "$1" $code
  else
    printf "$2" $code
  fi
  return $code
}

# I only want to see the interpreter in the output if I'm not using MRI.
function ruby_version() {
  local i=$(/Users/craig/.rvm/bin/rvm-prompt i)
  case $i in
    ruby) printf "$1" $(/Users/craig/.rvm/bin/rvm-prompt $2) ;;
    *)    printf "$1" $(/Users/craig/.rvm/bin/rvm-prompt $3) ;;
  esac
}

# Show lots of info in the __git_ps1 output.
# Thanks for the info &lt;a href="http://twitter.com/mathie"&gt;@mathie&lt;/a&gt;.
export GIT_PS1_SHOWDIRTYSTATE="true"
export GIT_PS1_SHOWSTASHSTATE="true"
export GIT_PS1_SHOWUNTRACKEDFILES="true"

export PS1='\[\033[01;32m\]\u@\h\[\033[00m\] $(last_exit_code "\[\033[1;32m\]%s\[\033[00m\]" "\[\033[01;31m\]%s\[\033[00m\]") $(ruby_version "\[\033[01;36m\]%s\[\033[00m\]" "v p" "i v p") \[\033[01;34m\]\W\[\033[00m\]$(__git_ps1 "\[\033[01;33m\](%s)\[\033[00m\]")\$ '&lt;/code&gt;&lt;/pre&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/3BWwITdlYwA" height="1" width="1"/&gt;</summary>

<category term="snippets" />
<category term="git" />
<feedburner:origLink>http://barkingiguana.com/2010/04/12/an-updated-command-prompt?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-04-11T16:58:56Z</published>
		<updated>2010-04-11T17:07:22Z</updated>
		<title type="html">A one-line web server in Ruby</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/rl9bsP9uvj8/a-one-line-web-server-in-ruby" />
		<id>tag:barkingiguana.com,2010-04-11:49231934267467cd6f9473e1d60d3904/40e44f358f1b8d2af4840ff096cd65ee</id>
		
		
		<summary type="html">
&lt;p&gt;Prodded by &lt;a href="http://twitter.com/semanticist/status/11958233080"&gt;a tweet&lt;/a&gt;, here's how to serve a directory in one line of Ruby:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port =&gt; 3000, :DocumentRoot =&gt; Dir.pwd).start'&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Handy for sharing files at a conference, for example.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/rl9bsP9uvj8" height="1" width="1"/&gt;</summary>

<category term="ruby" />
<category term="snippets" />
<feedburner:origLink>http://barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-03-21T11:00:00Z</published>
		<updated>2010-03-21T01:31:25Z</updated>
		<title type="html">Command-line EC2 with ec2-api-tools</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/jrAx-SexPZg/command-line-ec2-with-ec2-api-tools" />
		<id>tag:barkingiguana.com,2010-03-15:49231934267467cd6f9473e1d60d3904/255ed2f58f6c8c59026f8e0873d5d1cd</id>
		
		
		<summary type="html">
&lt;p&gt;A company I've been working with hosts some of their applications on EC2. Being a software developer who has worked extensively with Linux and Unix based servers and desktops I find it quite frustrating to work with the EC2 console webpage. Here's how I set things up to work with the EC2 API from my laptop (currently a MacBook Pro).&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;mkdir ~/.ec2
cd ~/Downloads
curl -O -L "http://www.amazon.com/gp/redirect.html/ref=aws_rc_ec2tools?location=http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip&amp;token=A80325AA4DAB186C80828ED5138633E3F49160D9"
unzip ec2-api-tools.zip*
cd ec2-api-tools
mv bin lib ~/.ec2/
echo 'export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
# I use the eu-west-1 - you may want to change this
EC2_REGION="eu-west-1"
export EC2_URL="https://${EC2_REGION}.ec2.amazonaws.com/"
export EC2_KEYPAIR_NAME="aws-`whoami`"' &amp;gt; ~/.ec2/env
echo '[ -f ~/.ec2/env ] &amp;&amp; . ~/.ec2/env' &gt;&gt; ~/.profile
ec2-add-keypair aws-`whoami` &gt; ~/.ec2/aws-`whoami`
chmod 0600 ~/.ec2/aws-`whoami`&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now download the X.509 private key and certificate from the Security Identifiers page of your AWS account and save them to ~/.ec2/ - leave the names as they are with the big messy jumble of letters in them.&lt;/p&gt;

&lt;p&gt;That should be it. You're setup. Try asking for a description of all the machine images owned by Amazon to see if it worked:&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;ec2-describe-images -o amazon&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be a huge list that looks something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;IMAGE	ami-13042f67	amazon/fedora-8-i386-v1.14-std	amazon	available	public		i386	machine	aki-61022915	ari-63022917		ebs
BLOCKDEVICEMAPPING	/dev/sda1		snap-34739d5d	15	
IMAGE	ami-1d042f69	amazon/fedora-8-x86_64-v1.14-std	amazon	available	public		x86_64	machine	aki-6d022919	ari-37022943		ebs
BLOCKDEVICEMAPPING	/dev/sda1		snap-08739d61	15&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;All the ec2 commands start with 'ec2-'. To see them all you can do this: &lt;code&gt;ls ~/.ec2/ec2-*&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you get deprecation notices from Xalan don't worry about it, everything will still work.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US&lt;/code&gt;&lt;/pre&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/jrAx-SexPZg" height="1" width="1"/&gt;</summary>


<feedburner:origLink>http://barkingiguana.com/2010/03/21/command-line-ec2-with-ec2-api-tools?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-03-03T17:31:02Z</published>
		<updated>2010-03-11T10:48:54Z</updated>
		<title type="html">Creating a new Subversion branch from an existing local Git branch</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/bD4pclTa1eY/creating-a-new-subversion-branch-from-an-existing-local-git-branch" />
		<id>tag:barkingiguana.com,2010-03-03:49231934267467cd6f9473e1d60d3904/bf4f84ebdd16ed391e31a30faf308c2f</id>
		<category term="Version-Control" />
		
		<summary type="html">
&lt;p&gt;When I'm coding I frequently have to work with Subversion repositories. I'm a Git user, so I use &lt;code&gt;git-svn&lt;/code&gt; for this. Usually I do my work in local branches, using a fairly regular Git workflow, then checkout the integration branch, merge in my changes and &lt;code&gt;git svn dcommit &lt;/code&gt; to push the code to Subversion.&lt;/p&gt;

&lt;p&gt;Sometimes however I need to share changes that I've made on an existing local branch in my Git repository with a Subversion user before they're ready to integrate back into the mainline. It takes me a while to hunt down and work out exactly what to do whenever I want to do this, so here are the instructions for my future reference. Hopefully they help you too.&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;git checkout master
git svn branch &amp;lt;new_svn_branch_name&amp;gt;
git svn fetch
git branch -r # make sure &amp;lt;new_svn_branch_name&amp;gt; exists
git checkout -b tmp/svn-rebase-target &amp;lt;new_svn_branch_name&amp;gt;
git rebase --onto tmp/svn-rebase-target master &amp;lt;existing_git_branch_name&amp;gt;
# That should have checked out &amp;lt;existing_git_branch_name&amp;gt;.
git svn dcommit -n # This should say it'll commit to &amp;lt;new_svn_branch_name&amp;gt;.
git branch -D tmp/svn-rebase-target # clean up the temporary branch.
git svn dcommit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This time mainly I used comments on a blog post that asked how to do this. Thanks &lt;a href="http://blog.venthur.de/2009/02/27/git-svn-branch/#comment-132890"&gt;Björn Steinbrink&lt;/a&gt; and &lt;a href="http://blog.venthur.de/2009/02/27/git-svn-branch/#comment-132911"&gt;Cameron&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I've turned this into a bash shell script. &lt;a href="http://gist.github.com/raw/329033/ebba3758bcfb2968796385165a83a3b824dc398e/svn-push.sh"&gt;Download it&lt;/a&gt; and make it executable. It takes one argument, the name of the local branch you want to push to Subversion:&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;./svn-push development/avoid-the-wombat-widgets&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This assumes that when you cloned your repository from Subversion you told Git where to find our Subversion branches. I'm not sure what'll happen if you didn't do that. Caveat emptor and all that.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/bD4pclTa1eY" height="1" width="1"/&gt;</summary>

<category term="git" />
<feedburner:origLink>http://barkingiguana.com/2010/03/03/creating-a-new-subversion-branch-from-an-existing-local-git-branch?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-03-02T11:04:21Z</published>
		<updated>2010-03-23T19:21:37Z</updated>
		<title type="html">Installing the MySQL gem on OSX 10.6 (Snow Leopard) with MacPorts MySQL5</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/Uhe9qEPlX5w/installing-the-mysql-gem-on-osx-106-snow-leopard-with-macports-mysql5" />
		<id>tag:barkingiguana.com,2010-03-02:49231934267467cd6f9473e1d60d3904/9d924b65452474cc3c950132ae1fa7f9</id>
		<category term="Systems" />
		<category term="Software" />
		<summary type="html">
&lt;p&gt;Took a while to work this command out. Hopefully it can save someone else some time.&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;sudo port install mysql5-server
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5&lt;/code&gt;&lt;/pre&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/Uhe9qEPlX5w" height="1" width="1"/&gt;</summary>

<category term="snippets" />
<category term="ruby" />
<feedburner:origLink>http://barkingiguana.com/2010/03/02/installing-the-mysql-gem-on-osx-106-snow-leopard-with-macports-mysql5?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-02-23T12:20:11Z</published>
		<updated>2010-02-23T12:25:35Z</updated>
		<title type="html">London Tech Meetups</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/ripH84iithM/london-tech-meetups" />
		<id>tag:barkingiguana.com,2010-02-23:49231934267467cd6f9473e1d60d3904/755476d833c7503d2d36a16bea26d045</id>
		
		
		<summary type="html">
&lt;p&gt;It can be quite hard to find groups in your area that share your interest, and even if you find out that they exist it can be pretty hard to work out when the next meetup is. Some of the meetup groups have frankly &lt;em&gt;mental&lt;/em&gt; scheduling rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://johnstewartsutherland.com/"&gt;John Sutherland&lt;/a&gt; has solved this problem for &lt;a href="http://edinburgh2.com/"&gt;Edinburgh tech community meetups&lt;/a&gt; by listing when various groups meet and who they'd be of interest to. After asking and receiving permission I've duplicated this idea for &lt;a href="http://london2.org/"&gt;London tech community meetups&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If your meetup isn't listed and you'd like it to be, email me at &lt;a href="http://barkingiguana.com/mailto:craig@barkingiguana.com"&gt;craig@barkingiguana.com&lt;/a&gt; and let me know.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/ripH84iithM" height="1" width="1"/&gt;</summary>

<category term="london" />
<category term="meetup" />
<feedburner:origLink>http://barkingiguana.com/2010/02/23/london-tech-meetups?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-02-17T17:49:37Z</published>
		<updated>2010-02-17T17:49:37Z</updated>
		<title type="html">Decoupling Nagios Host and Service check events for fun and profit</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/zWOmhsboa4A/decoupling-nagios-host-and-service-check-events-for-fun-and-profit" />
		<id>tag:barkingiguana.com,2010-02-17:49231934267467cd6f9473e1d60d3904/b7835ebb3e2096cfe89dcdee35cc9322</id>
		<category term="Monitoring" />
		<category term="Systems" />
		<summary type="html">
&lt;p&gt;Nagios does a pretty good job of watching over my services and hosts, but I want to do a little more with the events it creates &amp;#8211; when it checks a service and something is wrong, or when something recovers. In particular I want to give my clients the ability to select at an incredibly high resolution what sort of notifications they get, for what services, how often, and at what level of technical detail. Coupled with this I want to up-sell the services that &lt;a href="http://xeriom.net/"&gt;Xeriom&lt;/a&gt; offers &amp;#8211; if the disk is getting full or the transfer quota is being consumed so fast that it wont last until the end of the month I want to make it easy to upgrade plans. I&amp;#8217;d also like to be able to try out some fun things &amp;#8211; iPhone push notifications, &lt;span class="caps"&gt;SMS&lt;/span&gt; gateways, audible alarms, whatever &amp;#8211; without worrying that I might destroy Nagios and bring my monitoring setup to its knees.&lt;/p&gt;

&lt;p&gt;Message queues are a great way of decoupling systems, moving risk and complexity elsewhere. Nagios shouldn&amp;#8217;t have to worry about all of the stuff I want to build around the monitoring system, it should focus just on the core features that I like it for: monitoring my hosts and services.&lt;/p&gt;

&lt;p&gt;Luckily, &lt;a href="http://barkingiguana.com/2008/12/13/deploying-activemq-on-ubuntu-810"&gt;I already have ActiveMQ running&lt;/a&gt; for other tasks, &lt;a href="http://barkingiguana.com/2009/01/01/writing-rubystomp-clients-with-smqueue"&gt;writing a &lt;span class="caps"&gt;STOMP&lt;/span&gt; client using &lt;span class="caps"&gt;SMQ&lt;/span&gt;ueue&lt;/a&gt; is pretty trivial, and Nagios has several ways to execute external commands when events happen including the &lt;a href="http://nagios.sourceforge.net/docs/3_0/configmain.html#global_host_event_handler"&gt;global host and service event handlers&lt;/a&gt;. All I need is a command to have Nagios run that&amp;#8217;ll accept a bunch of information from Nagios and stick it on the message queue.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s what I came up with:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;require 'rubygems'
require 'smqueue'
require 'json'

message = {
  :hostname =&gt; ARGV[2],
  :service =&gt; ARGV[3],
  :state =&gt; ARGV[4],
  :state_type =&gt; ARGV[5],
  :state_time =&gt; ARGV[6].to_i,
  :attempt =&gt; ARGV[7].to_i,
  :max_attempts =&gt; ARGV[8].to_i,
  :time_t =&gt; Time.now.to_i
}

configuration = {
  :host =&gt; ARGV[0],
  :name =&gt; ARGV[1],
  :adapter =&gt; :StompAdapter
}

broadcast = SMQueue(configuration)
broadcast.put message.to_json, "content-type" =&gt; "application/json"&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You&amp;#8217;ll need Ruby and RubyGems installed. Once you have those, install the script like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class="bash"&gt;sudo su -
gem sources -a http://gems.github.com/
gem install seanohalpin-smqueue json --no-ri --no-rdoc
cd /usr/bin
wget http://gist.github.com/raw/306765/2a3e9cbade88b4c6dd430e108bc8a28f95047462/notify-service-by-stomp.rb
chmod +x notify-service-by-stomp.rb&lt;/code&gt;&lt;/pre&gt;

Once it's installed tell Nagios to use it by adding this to your Nagios configuration:

&lt;pre&gt;&lt;code&gt;define command {
  command_name notify-service-by-stomp
  command_line /usr/bin/notify-service-by-stomp.rb mq.example.com /topic/foo.bar.baz.quux $HOSTADDRESS$ "$SERVICEDESC$" $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEDURATIONSEC$ $SERVICEATTEMPT$ $MAXSERVICEATTEMPTS$
}

global_service_event_handler=notify-service-by-stomp&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change &lt;code&gt;mq.example.com&lt;/code&gt; to be the hostname of your message broker, and &lt;code&gt;/topic/foo.bar.baz.quux&lt;/code&gt; to be the topic or queue that you&amp;#8217;d like notifications to be sent to. Restart Nagios and you should start receiving notifications on that queue or topic.&lt;/p&gt;

&lt;p&gt;If you don&amp;#8217;t receive notifications form Nagios very often then a simple way to test that this is working is to attach stompcat &amp;#8211; a &lt;code&gt;cat&lt;/code&gt; type tool that uses &lt;span class="caps"&gt;STOMP&lt;/span&gt; as a source &amp;#8211; to the topic or queue, then send a few test notifications to the same queue by manually running the same command that Nagios would.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s a simple stompcat tool in case you don&amp;#8217;t have one handy:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;#! /usr/bin/env ruby

# Run me like this:
#
#   ./stompcat.rb mq.example.com /topic/foo.bar.baz.quux
#

require 'rubygems'
require 'smqueue'

configuration = {
  :host =&gt; ARGV[0],
  :name =&gt; ARGV[1],
  :adapter =&gt; :StompAdapter
}

source = SMQueue(configuration)
source.get do |m|
  payload = m.body
  puts "&gt;&gt;&gt; #{payload}"
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here&amp;#8217;s how to send notifications to the queue or topic:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/usr/bin/notify-service-by-stomp.rb mq.example.com \
  /topic/foo.bar.baz.quux service-host.example.com "SERVICE NAME" \
  WARNING HARD 86492 6 6&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If it&amp;#8217;s working you should get an entry like this showing up where you&amp;#8217;re running the &lt;code&gt;stompcat&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class="javascript"&gt;{
  "time_t":1266427384,
  "state":"WARNING",
  "state_type":"HARD",
  "state_time":86492,
  "attempt":6,
  "hostname":"service-host.example.com",
  "max_attempts":6,
  "service":"SERVICE NAME"
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should be able to change the stompcat example to perform more complex and interesting actions &amp;#8211; looking up clients in a database, sending text messages if an account has enough credit, whatever you fancy. If you come up with something fun, please let me know!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/zWOmhsboa4A" height="1" width="1"/&gt;</summary>

<category term="messaging" />
<category term="monitoring" />
<category term="ruby" />
<category term="snippets" />
<category term="system" />
<category term="xeriom" />
<feedburner:origLink>http://barkingiguana.com/2010/02/17/decoupling-nagios-host-and-service-check-events-for-fun-and-profit?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-02-11T23:15:49Z</published>
		<updated>2010-02-11T23:24:01Z</updated>
		<title type="html">Keeping the software on your Ubuntu server up-to-date</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/T7LAnrj3cMs/keeping-the-software-on-your-ubuntu-server-up-to-date" />
		<id>tag:barkingiguana.com,2010-02-11:49231934267467cd6f9473e1d60d3904/5325860bdb60ed41ebcd9f3e13e93198</id>
		<category term="Systems" />
		
		<summary type="html">
&lt;p&gt;New exploits are found just about every day in software both old and new. To combat this, software vendors release security updates which the Ubuntu team package up and use to release new, more secure packages of the software that you install.&lt;/p&gt;

	&lt;p&gt;It&amp;#8217;s very hard to provide software updates for all versions of all software packages ever built for a platform like Ubuntu so the Ubuntu team produce releases of Ubuntu Linux which they offer to support for a known period of time. These support periods are currently one of two lengths depending on the release of Ubuntu you use. Long Term Support (usually noted by including &amp;#8220;&lt;span class="caps"&gt;LTS&lt;/span&gt;&amp;#8221; in the name) releases for the server are supported for 5 years after the release date. Regular releases are supported for 18 months. Beyond these windows support for the release is dropped and you won&amp;#8217;t be able to upgrade or update any packages without a lot of work, so it&amp;#8217;s important to upgrade before support for your release is stopped.&lt;/p&gt;

	&lt;p&gt;The current commonly used releases, their release date, and their end of support window are as follows:&lt;/p&gt;

	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Version    &lt;/th&gt;
			&lt;th&gt;Name           &lt;/th&gt;
			&lt;th&gt;Release Date  &lt;/th&gt;
			&lt;th&gt;Support Ends &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 10.04  [LTS] &lt;/td&gt;
			&lt;td&gt; Lucid Lynx       &lt;/td&gt;
			&lt;td&gt; April 2010      &lt;/td&gt;
			&lt;td&gt; April 2015     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 9.10         &lt;/td&gt;
			&lt;td&gt; Karmic Koala     &lt;/td&gt;
			&lt;td&gt; October 29 2009 &lt;/td&gt;
			&lt;td&gt; April 2011     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 9.04         &lt;/td&gt;
			&lt;td&gt; Jaunty Jackalope &lt;/td&gt;
			&lt;td&gt; April 23 2009   &lt;/td&gt;
			&lt;td&gt; October 2010   &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.10         &lt;/td&gt;
			&lt;td&gt; Intrepid Ibex    &lt;/td&gt;
			&lt;td&gt; October 30 2008 &lt;/td&gt;
			&lt;td&gt; April 2010     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.04.4 [LTS] &lt;/td&gt;
			&lt;td&gt; Hardy Heron      &lt;/td&gt;
			&lt;td&gt; January 28 2010 &lt;/td&gt;
			&lt;td&gt; April 2013     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.04.3 [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; July 16 2009    &lt;/td&gt;
			&lt;td&gt; April 2013     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.04.2 [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; January 22 2009 &lt;/td&gt;
			&lt;td&gt; April 2013     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.04.1 [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; July 3 2008     &lt;/td&gt;
			&lt;td&gt; April 2013     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 8.04   [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; April 24 2008   &lt;/td&gt;
			&lt;td&gt; April 2013     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 7.10         &lt;/td&gt;
			&lt;td&gt; Gutsy Gibbon     &lt;/td&gt;
			&lt;td&gt; October 18 2007 &lt;/td&gt;
			&lt;td&gt; April 2009     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 7.04         &lt;/td&gt;
			&lt;td&gt; Feisty Fawn      &lt;/td&gt;
			&lt;td&gt; April 19 2007   &lt;/td&gt;
			&lt;td&gt; October 2008   &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 6.10         &lt;/td&gt;
			&lt;td&gt; Edgy Eft         &lt;/td&gt;
			&lt;td&gt; October 26 2006 &lt;/td&gt;
			&lt;td&gt; April 2008     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 6.06.2 [LTS] &lt;/td&gt;
			&lt;td&gt; Dapper Drake     &lt;/td&gt;
			&lt;td&gt; January 21 2008 &lt;/td&gt;
			&lt;td&gt; June 2011      &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 6.06.1 [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; August 10 2006  &lt;/td&gt;
			&lt;td&gt; June 2011      &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 6.06   [LTS] &lt;/td&gt;
			&lt;td&gt; &amp;#8220;                &lt;/td&gt;
			&lt;td&gt; June 1 2006     &lt;/td&gt;
			&lt;td&gt; June 2011      &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 5.10         &lt;/td&gt;
			&lt;td&gt; Breezy Badger    &lt;/td&gt;
			&lt;td&gt; October 12 2005 &lt;/td&gt;
			&lt;td&gt; April 2007     &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 5.04         &lt;/td&gt;
			&lt;td&gt; Hoary Hedgehog   &lt;/td&gt;
			&lt;td&gt; April 8 2005    &lt;/td&gt;
			&lt;td&gt; October 2006   &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 4.10         &lt;/td&gt;
			&lt;td&gt; Warty Warthog    &lt;/td&gt;
			&lt;td&gt; October 26 2004 &lt;/td&gt;
			&lt;td&gt; April 2006     &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;

	&lt;p&gt;Currently supported are 6.06, 8.04, 8.10, 9.04 and 9.10. Ubuntu 10.04 will be released in April.&lt;/p&gt;

	&lt;h4&gt;Your responsibilities&lt;/h4&gt;

	&lt;p&gt;There are two things that you as a server operator need to know how to do to stay up-to-date with the software on your server and make sure that it&amp;#8217;s always supported. One is upgrading installed packages, and one is upgrading to the next release of Ubuntu. I&amp;#8217;ll cover them both one at a time, but first we&amp;#8217;ll do a little setup to make sure that both operations are nice and fast.&lt;/p&gt;

	&lt;h5&gt;Using a package mirror&lt;/h5&gt;

	&lt;p&gt;A very time consuming part of the update and upgrade process is downloading a large quantity of files from the servers that host the latest software packages. To make this faster &lt;a href="http://xeriom.net/"&gt;Xeriom Networks&lt;/a&gt; provide a mirror of the software packages for 8.04, 8.10, 9.04 and 9.10. If you&amp;#8217;re not hosted on Xeriom Networks (why not?) you should ask your current provider if they supply a package mirror for your release. If they don&amp;#8217;t you should skip this section and hope that your connection is fast enough to cope.&lt;/p&gt;

	&lt;p&gt;Using the package mirror is simple and requires you to edit just one file. A nice simple editor is nano. Install it by connecting to your server by &lt;span class="caps"&gt;SSH&lt;/span&gt; and using sudo and apt-get to install it:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo apt-get install nano --yes&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The contents of the file is determined by which release of Ubuntu you are running. Find out which release you run by typing this:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;cat /etc/lsb-release&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You should then match your release up with the appropriate box on this Wiki page: &lt;a href="http://wiki.xeriom.net/w/XeriomUbuntuPackagesService"&gt;http://wiki.xeriom.net/w/XeriomUbuntuPackagesService&lt;/a&gt;&lt;/p&gt;

	&lt;p&gt;Copy the text from within only the box that&amp;#8217;s matched with your release. Now we can edit the file to add the local package server:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo nano -w /etc/apt/sources.list&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Delete all the existing lines in that file and replace them with the text you copied from the Wiki page. Now press &lt;span class="caps"&gt;CTRL&lt;/span&gt; and X and say that you do want to save the file.&lt;/p&gt;

	&lt;p&gt;Now we tell Ubuntu to refresh the list of software packages so it knows what&amp;#8217;s available on the local package mirror:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo apt-get update&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Congratulations, you&amp;#8217;re now using the Xeriom Ubuntu package mirror.&lt;/p&gt;

	&lt;h5&gt;Upgrading installed software&lt;/h5&gt;

	&lt;p&gt;Keeping your software up-to-date is an important part of keeping your server secure but since these new packages may break existing functionality it&amp;#8217;s best not to install them automatically. You should sit down and do this yourself, only applying the updates if they&amp;#8217;re appropriate and necessary.&lt;/p&gt;

	&lt;p&gt;To update the software installed on your server you use a set of tools called apt &amp;#8211; and specifically you use apt-get.&lt;/p&gt;

	&lt;p&gt;To make sure you get the latest updates you should first update your servers package database:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo apt-get update&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Then you should ask it to upgrade your existing packages:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo apt-get upgrade&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This will calculate everything that needs upgrading, show you a list of those packages and ask you if you want to continue. Most of the time this command will run smoothly and you&amp;#8217;ll get the latest version of the software on your server, but you should check the list of packages that it will upgrade and be sure that you know what&amp;#8217;s going to change before you let it complete.&lt;/p&gt;

	&lt;h5&gt;Upgrading to the next release&lt;/h5&gt;

	&lt;p&gt;Upgrading Ubuntu is a slightly more time consuming process with a small increase in risk because of the huge number of packages that will be upgraded. It will usually also require you to reboot your server since the kernel is likely to be upgraded so you should plan for a little downtime.&lt;/p&gt;

	&lt;p&gt;To upgrade you should use a package called update-manager-core. If this is your first time upgrading your Ubuntu release you may need to install it:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo apt-get install update-manager-core&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Next configure it to target releases based on your preferred strategy. This is either lts, normal or never.&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo nano -w /etc/update-manager/release-upgrades&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Change the line that starts &amp;#8220;Prompt=&amp;#8221; to be whichever strategy you choose. For example, if I choose the lts strategy which should give me 5 years of support for each release I update to I&amp;#8217;d enter &amp;#8220;Prompt=lts&amp;#8221; here. Now press &lt;span class="caps"&gt;CTRL&lt;/span&gt; and X and tell it that you want to save the file if it asks.&lt;/p&gt;

	&lt;p&gt;Now, before you upgrade, read the &lt;a href="http://www.ubuntu.com/getubuntu/releasenotes/"&gt;release notes&lt;/a&gt; for the version of Ubuntu that you&amp;#8217;re going to upgrade to and make sure you understand all the current issues and caveats surrounding it.&lt;/p&gt;

	&lt;p&gt;Once you&amp;#8217;re happy that you understand what you&amp;#8217;re doing and you&amp;#8217;ve scheduled a time to upgrade your server you can start the upgrade:&lt;/p&gt;

  &lt;pre&gt;&lt;code&gt;sudo do-release-upgrade&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This will calculate all the packages that will be upgraded and ask you if you want to continue. Don&amp;#8217;t just say yes &amp;#8211; read the list of packages and make sure you understand what upgrading them means to your setup.&lt;/p&gt;

	&lt;h4&gt;If it all goes pear-shaped&lt;/h4&gt;

	&lt;p&gt;Sometimes things get messed up. Maybe the release wasn&amp;#8217;t tested enough (rare these days) or perhaps the new release doesn&amp;#8217;t support the same software as the one you upgraded from and you need that to run. If this ever happens we can create you a brand new image of the release you need as long as it&amp;#8217;s still supported. Of course, your data won&amp;#8217;t be on the new release so make sure your backups are up-to-date!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/T7LAnrj3cMs" height="1" width="1"/&gt;</summary>

<category term="ubuntu" />
<category term="system" />
<category term="security" />
<feedburner:origLink>http://barkingiguana.com/2010/02/11/keeping-the-software-on-your-ubuntu-server-up-to-date?source=feed</feedburner:origLink></entry>
<entry>
		<author>
			<name>Craig Webster</name>
		</author>
		<published>2010-02-11T13:54:07Z</published>
		<updated>2010-02-11T13:59:05Z</updated>
		<title type="html">The correct OID for system uptime</title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BarkingIguana/~3/Lr8CWg4Mt4g/the-correct-oid-for-system-uptime" />
		<id>tag:barkingiguana.com,2010-02-11:49231934267467cd6f9473e1d60d3904/011bb16ead89bd321acb0b81d29bdba4</id>
		<category term="Monitoring" />
		<category term="Systems" />
		<summary type="html">
&lt;p&gt;I use &lt;a href="http://www.net-snmp.org/"&gt;SNMP&lt;/a&gt; to track system uptime so I know when my hosts have recently rebooted, but I keep making a mistake when picking which OID to monitor and using &lt;code&gt;sysUpTime.0&lt;/code&gt; which is wrong I should be using &lt;code&gt;hrSystem.hrSystemUptime.0&lt;/code&gt;.&lt;/p&gt;

&lt;dl&gt;
  &lt;dt&gt;&lt;code&gt;sysUpTime.0&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Timeticks (0.01s) since the snmpd started.&lt;/dd&gt;
  &lt;dt&gt;&lt;code&gt;hrSystem.hrSystemUptime.0&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Timeticks since the hardware started.&lt;/dd&gt;
&lt;/dl&gt;
&lt;img src="http://feeds.feedburner.com/~r/BarkingIguana/~4/Lr8CWg4Mt4g" height="1" width="1"/&gt;</summary>

<category term="monitoring" />
<feedburner:origLink>http://barkingiguana.com/2010/02/11/the-correct-oid-for-system-uptime?source=feed</feedburner:origLink></entry></feed>
