Monthly Archives: March 2011

Introducing o4send

Awhile ago, Amberdms was contracted to develop an application for sending messages to bluetooth enabled mobile phones for the NZ world expo.

Essentially the idea was that people would visit the expo, receive a file on their mobiles and receive some awesome content about New Zealand. The cool thing about this was that you didn’t need to be paired, any phone with bluetooth active would get this message.

Apparently this worked quite nicely, although I’m not convinced that OPP will be much use for the future, with the two major smartphone platforms (Android and iPhone/iOS) not providing support for it – we found that it worked best with Nokia Symbian phones.

To make this work, I wrote a perl script and coupled it with a CSV or MySQL database backend to track the connections and file distributions – I bundled this into a little application called “o4send” which I’ve now released the source publicly.

You can check out the source and download the application at the Amberdms project tracker at: https://www.amberdms.com/projects/p/oss-o4send/

Take care with this application, it can talk to a lot of mobile phones and I’m not sure of the legality of sending unsolicited messages to bluetooth devices – but I figured this source might be useful to somebody oneday for a project – or at the very least, a “hey that’s cool” moment.

30 days of geek takes off?

Readers who have been around for a little while may recall my 30 days of geek blogging challenge, which I sadly ran out of time to complete the last few questions.

Recently @CyrisXD has taken up the idea and has been promoting it to get a whole bunch of other geeks blogging and talking about it, which is pretty awesome. He has a list of people doing the challenge, starting up on the 1st of April on his website at eguru.co.nz and there seems to be a lot of buzz around it.

It’s pretty awesome to see it take off and it would be shame if I don’t complete it myself, so I’m going to start making a post a day to complete the 30 days of geek challenge myself. :-)

As a side note, I’m also making some effort to go back and tag all the articles on this blog better – I have a few categories, but there’s lots more content that tends to get hidden and hopefully tagging it will make it more accessible to casual readers, so I’ll be doing this over the next week or so.

DHCP, I/O and other virtualisation fun with KVM

I recently shifted from having two huge server racks down to having a single speedy home server running KVM virtual machines, with the intent of packaging all my servers – experimental, development, staging, etc, into a single reliable system which will reduce power and maintenance costs.

As part of this change, I went from having dedicated DHCP & DNS servers to having everything located onto the KVM host.

The design I’ve used, has the host OS running with minimal services – the host just runs KVM, OpenVPN, DHCP and a DNS caching nameserver – all other services run as guest VMs, with a virtual network for the guests and host to communicate over.

Guests run as DHCP clients – this makes it easy to assign or adjust addressing if needed and get their information from the host OS.

However this does mean you can’t get away with hammering the host too badly – for example, running an I/O and network intensive backup can cause some interesting problems when you also need the host for services, such as DHCP.

Take a look at the following log messages from a mostly idle VM – these were taken whilst another VM on the server was running a bonnie++ process to test performance:

Mar  6 10:18:06 virtguest dhclient: 5 bad udp checksums in 5 packets
Mar  6 10:18:27 virtguest dhclient: DHCPREQUEST on eth0 to 10.8.12.1 port 67
Mar  6 10:18:45 virtguest dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Mar  6 10:19:00 virtguest dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Mar  6 10:19:07 virtguest dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Mar  6 10:19:15 virtguest dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Mar  6 10:19:15 virtguest dhclient: 5 bad udp checksums in 5 packets

That’s some messed up stuff – what you’re seeing is that the guest VM is trying to renew the DHCP address with the host server – but the host is so sluggish with having to run the I/O intensive virtual machine that is actually corrupting or dropping the UDP packets, preventing the guest VM from renewing it’s address.

This of course raises the most important question: What happens if the guest can’t renew it’s IP address?


In this case, the Linux/CentOS 5 guest VM actually completely lost it’s IP address after a long period of DHCPREQUEST attempts, fell off the network entirely and caused my phone to go nuts with Nagios alerts.

Now of course in any sane production environment, nobody would be running a bonnie++ processes on a VM on an active server – however there’s some pretty key points still made here:

  • The isolation is a lie: Guests are only *somewhat* isolated from one another – one guest can still mess with another and effectively denial-of-service attack the other VMs by utilising all the available resources.
  • Guests can be jerks: Organisations running KVM (or some other systems) with untrusted guest VMs should carefully consider how they are going to monitor and protect the service from users running crazily resource intensive processes. (after all, there will be someone who wants to bonnie++ test their new VM simply for the lols).
  • cgroups to the rescue? Linux cgroups does have an I/O controller (blkio-cgroup) although whilst this controls read/write flow, it won’t restrict seeks which can also badly impact spinning rust based servers.
  • WTF DHCP? The approach of the guests simply dropping their DHCP address after losing contact with the DHCP server is a pretty bad design limitation – if the DHCP server is unreachable, it should keep the original address (of course if the “physical” ethernet connection dropped, that would be a different situation, and it should drop it’s address to match).
  • Also: I wonder what OSes/distributions have the above behavior?

I’m currenting running a number of bonnie++ tests on my KVM server and will have a blog post in the near future detailing these findings in more detail, I’m also planning to look into cgroups and other resource control and limiting functions and will report back on how these fare when you have guest VMs running heavy processes.

Overall it made my weekend of geekery that bit more exciting. :-D

Kickstarting Christchurch

Now that the immediate quake issues are being addressed, attention is being turned to how New Zealand is going to fund the repair to Christchurch.

There’s discussions about introducing new taxes, re-introducing student loan taxes and of course there’s likely to be an increase to our existing earthquake levy and building insurance.

I have a few immediate thoughts on this:

  • Student Loan Interest: Just about the worst possible idea I’ve ever heard, introducing tax on student loans will mean that more students will want to leave NZ for better wages overseas – we want to RETAIN talented youth in NZ.
  • Earthquake Levy Increases: What’s happened to the fees that we’ve been paying out for the past 50 or so years? Surely there should be a nice pile of money available for a disaster such as this? Or has the government been spending it all and not retaining it like it should?
  • New Taxes: I’m wary of new taxes being introduced for specific events, we should have factored our taxes to factor in for a disaster like this once every 100 years or so – if we need to adjust, so be it, but it should be transparent.

There’s also the tricky question of how do we encourage and help Christchurch rebuild? It’s going to be very interesting to see how much of the population leaves the city for other areas, there have already been stories of families planning to move out permanently.

In some ways there could be a good opportunity to build Christchurch up again, by trying to encourage younger people and businesses to the city to replace those who are leaving – I’m expecting land and house values to drop, which will make buying there more attractive for younger people with less money – assuming there is good work available.

And how do we go about encouraging business and employers to get started? My suggestion is that the NZ government cuts taxes almost entirely for any business of less than 25 people in Christchurch region for an entire year and make low-interest loans available to businesses.

This is a big step, it would cost a lot of money, but consider this:

  • Large wealthy companies that can afford to keep on going, will do so, the government won’t be propping up the large international corporations or anything.
  • Young and small hard hit existing companies will lose a lot of pressure and be able to focus on rebuilding business and getting started again without worrying about how bills are going to get paid.
  • The loans will allow them to get a quick cash injection to rebuild and get running – every week that a company can’t bill is a huge impact and many small businesses will go broke without a bit of cash investment to help them out, which would be a terrible loss.
  • It will encourage people starting new business to consider Christchurch – for example, anyone doing an IT startup will consider “hey, we can located in Christchurch and get some big savings, why not?”. This is less of an immediate benefit, but long term could pay off hugely for Christchurch region, by encouraging growth in a city that people might otherwise decide to avoid.

I don’t claim to be an economist, this is my opinion based on what I’d like to see if I was running a small business in Christchurch and what would encourage me to keep at it after a disaster like this.

It’s not going to be cheap, but nothing about this disaster is going to be cheap – best if we can do something than ends up kick starting and enabling Christchurch to rebuild and grow itself, than losing lots of businesses and suffering more economic impact in future.