Today on freshmeat I noticed 2 useful utilities for anyone running Xen Servers.

The first is called Virt-top it is a easier to read top like tool than xm top that shows all virtual machines memory and CPU usage in a nice display including totals etc:


The other - Virt-P2V - it’s a CD Image that you can boot a physical machine with that will then convert it to a virtual machine for you. It will scp the drive image to a destination of your choice and create a config file to boot it after asking you some questions. I intend to use this to move a VMWare virtual machine to Xen soon, will post here and see how it goes.

Both of these come from a Red Hat employee, with some luck we’ll see these included in Red Hat Linux soon.

Passport
Today my UK passport finally arrived, I did have to go for an interview where they re-established that I am who I say I am.

The interview was quite interesting, when I went to write my Britishness Test there were only 4 or so other people at the test and I kind of looked at that as an indication that perhaps, as usual, there is more hype in the media related to immigration than is really needed.

They arrange the interview meetings in blocks of 45 minutes and only allow you in 10 minutes before your block start, so you can know who is in there are all people who are applying for their first passport. I went to the interview center in Elephant & Castle, its a fairly big facility with almost 30 interview cubicles, in my 45 minutes block there were about 80 or so people waiting for the interview.

This kind of brought it home a bit more that yes really there is a massive immigration problem, the interview centers are open 6 days a week and if they are usually anywhere near as busy as when I went - noon on a Friday - then I’d say the rate of immigration is totally unsustainable. It is easier to visualize the problem in a setting like this than to read some big figure in a news paper.

The interview itself was very professionally done, the woman who interviewed me were friendly, thorough and I think the whole thing was actually pretty enjoyable apart from the obvious inconvenience involved. They mostly asked me to confirm what I already filled in on my application forms but also some extra things like what is my Car Registration, what bank accounts I have and when they were opened. It was all simple stuff and went really quick.

Macs and MS Keyboards
Previously I posted about my iMac 17″ that I got, that was January 2006 well I have now upgraded to a bigger mac, this time a 24″ iMac Core 2 Duo Extreme with 2GB RAM.


I still have the 17″ and will keep it, it’s replacing my really old AMD Linux Desktop on my desk but the 17″ has been getting a bit long in the tooth with Parallels, MS Office, and all sorts of other stuff that I have been doing on it as I am now working full time from home.

Previously I bought at the bottom of the spectrum and the machine lasted well, but I was hoping to keep it as my primary machine for at least 3 years. I guess my needs have increased though so this time I bought at the top end of the range and will upgrade it to 4GB RAM soon, just not from Apple as buying direct from Crucial will save me about 200 pounds.

What immediately annoyed me - to the point of cramps in my hands and general unhappyness - were this amazingly crap thinline keyboard that comes with the machines. I soon started looking at other options and found no 3rd party Mac keyboards but did notice that Microsoft keyboards have a utility to configure the various additional keys etc so I took the plunge and got a MS Natural Ergonomic 400 keyboard to replace my very old MS Office keyboard.


I am extremely pleased with this keyboard, everything works as it should. The configuration utility lets you configure every key on the keyboard and everything is mapped correctly as expected. Even the function keys like ‘new’ works by sending ‘apple key-n’ etc right out of the box, this is the case with all the MS keyboards on the market today so I can happily recommend any MS keyboard to mac users.

The iMac itself is lovely, I am really happy with it. Speed wise the Core 2 Duo Extreme chip has made a huge improvement, with Parallels running Windows the machine idles at about 2% while I have Firefox, Netnewswire, iTerm, several Terminal.app, Adium, Skype and all sorts of background stuff going, really cannot have asked for more from a desktop machine.

Extracting only certain lines from a file
This is probably old news to most people but I need to remember this so I figured I may as well blog it.

I made a mysqldump that just takes all databases into a single file, already I want to kick myself because I know if I ever need to import it there will be troubles because the target database will already have the mysql database etc.

Really I should have used MySQL Parallel Dump that makes files per tables etc and is much faster but it didn’t exist at the time.

So how to pull lines 8596 to 9613 from this big file? It’s trivial with sed:

here is a sample file:

$ cat > file.txt line 1 line 2 line 3 line 4 line 5 ^D  $ sed -n '2,4p;4q' file.txt line 2 line 3 line 4 

The sed command just tells it the start to end line and also to quit processing when it hits the end line, really kewl.

Medium Format Film Photography
I’ve a fairly short history with film, only started on it in September 2006 and it’s pretty much taken over for me from much of my digital camera work.

Since September 2006 I bought quite a few bits of film camera equipment, lenses aside this is what I have:

The most recent additions are the bottom two, they’re medium format cameras and something I’ve been intending to get into for a while. I bought the Seagull on eBay for cheap to see if I like the format and have some great results with it, especially considering it cost only GBP40.


So after loving the medium format as a medium I decided to get a proper medium format camera, I decided on a SLR rather than a TLR so got the Bronica SQA, it’s a square format medium format camera with interchangeable lenses, backs and finders. You can even buy Polaroid or digital backs for it to.


We took it out yesterday during lunch for a quick test and I love the shots we got, it’s lovely to use though it has no light meter so I use one of my hand held light meters, the shot below and ones it links too were all done with a 1 degree spot meter and metered using the Zone Systems.


I love working with the medium format negatives, they are roughtly 6 cm x 6cm each with big generous borders between negatives. This makes working with them so easy, easy to cut, easy to handle safely without touching the photos etc.

I found my developing results with them were much better than with 35mm, maybe I have just been more careful, will need to see when I do my next 35mm and compare.

Since using film my general photography has improved a lot, I now find that I am forced to spend a lot more time thinking about a shot, putting up tripod, metering it by hand, looking at every bit of detail of the photo to do the metering correctly etc, my % of shots taken to shots that I love is much higher than before and as a result even my digital photography has improved. I take fewer shots and get many more keepers. I think I’ll be doing film work till they stop making it.

RedHat 5.1 tunable kernel ticks per second
For some time the default clock rate on RedHat machines (and probably others) have been 1000HZ, this is great to keep your mouse moving smooth while something big is happening in the background, but not so great for hosting 10 virtual machines on one poor physical machine as it will have to try and satisfy 10000 ticks per second.

I’ve been using a guest kernel repository by one of the VMWare users that rebuilds the std CentOS/RedHat kernels with HZ=100 and it’s been great, chopped massive amounts off my CPU usage on the host.

Now with RedHat 5.1 this is not needed anymore see this post for a bit of a graph on the impact and the background. The short of it is, simply append divider=10 to your guest kernel boot parameters and enjoy a much happier host. I found that time keeping also becomes more predictable in the guest.

British Citizenship
I previously mentioned that got a letter confirming it all went well with my application for naturalisation, the whole process is now more or less done.

I had the ceremony last Thursday and around 11:24 in the morning the Mayor of Greenwich handed me my certificate so I am now all done with that and a full Citizen of the United Kingdom. I arrived here on the 2nd of Feb 2002 and became a citizen on the 7th of Feb 2008. I could have applied last year in March already and probably would have been done with it all around September but I was procrastinating and eventually the noise about the reforms in the immigration laws gave me the kick I needed to complete it.

The biggest advantage I’ll see immediately is of course the passport, traveling as a South African - or in fact being a South African out of South Africa - is such a liability your whole life is just tough, massive headache of visas, immigration time wasting etcetc, endless hassle. In tourist visas alone I spent about GBP500 in the last few years never mind all the time wasted in getting those and even just in queuing in the non EU citizen lines at airports, all gone now! I’ve also had to struggle quite a lot with tenancy agreements for flats that I rent etc as I was never sure if I’ll even be in the country for the year they want you to sign, so had to always get 6 month break clauses put in etc.

This is a part of the certificate I received during the ceremony:

Today I’ll apply for my first UK passport, it should come through in about 2 weeks unfortunately just too late to attend FOSDEM.

The process for applying for citizenship is all hyped up to be this fantastic experience for applicants, a great introduction to the country and its people. This is done through the test you need to pass and a formal ceremony that even includes singing God Save The Queen.

Overall I’d say the whole thing just left me cold, personally I see little point to most of the hoops I had to jump through. I have to say though that the test has some value - it tests that you have a grasp of English and in that function its a success so I’d keep it for that reason. The ceremonies though? waste of time and money in my eye.

Processing Medical X-Ray Data
Recently one of our snakes died due to an abscess in her body, we tried everything to safe the poor snake but in the end - and almost 1200 later - it passed away one night.

While undergoing treatment we were given copies of the X-Ray data, at the time I tried to read the RAW data files but failed, finally writing it off as some proprietary format specific to the X-Ray machine vendor.

Today I came across an item on MacNN mentioning OsiriX which is basically an Open Source suite to drive all things medical. Turns out the data is encoded in a standard format known as DICOM which defines the data type and also a network protocol for these machines to communicate with each other and their image storage over a network.

The data I got was in RAW format so none of the DICOM headers were present, this led me to some other software and a FAQ for importing unsupported/unknown DICOM data. Using the information there I was able to work out based on file size that my data was 512 x 512 big with an Header offset of 6480.

Armed with this information I was able to do a pretty decent import into OsiriX, the output of the one X-Ray can be seen below (click for full size).

The infection is clearly visible on the left of the image, this was removed but a second formed. Anyway, so the point of this post isn’t to go on about the poor departed snake but to mention the fantastic medical imaging tool OsiriX which is a pure Mac application and while I doubt many of my Blog audience will care for it it might still be of some use to some Googlers.

Nasty PHP Authentication Handling
Sometimes you come across things that just make you wonder what is going on in peoples minds.

For years everyone who wrote applications compatible with the standard HTTP Authentication method has used the REMOTE_USER server variable as set by Apache to check the username that was logged in by the webserver, this has worked well for everyone, CGI’s and all would just grab it there and everyone would be happy.

Along comes PHP and they make great big mess of it, PHP suggests that we use $_SERVER[’PHP_AUTH_USER’] instead, and they give some good reasons for this too, except they have severely crippled this for all but Basic and Digest authentication, the following code from main/main.c


if (auth && auth[0] != ‘\0′ && strncmp(auth, “Basic “, 6) == 0) {
char *pass;
char *user;

user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL);
if (user) {
pass = strchr(user, ‘:’);
if (pass) {
*pass++ = ‘\0′;
SG(request_info).auth_user = user;
SG(request_info).auth_password = estrdup(pass);
ret = 0;
} else {
efree(user);
}
}
}

As you can see above, they only import the user and pass from Apache if the AuthType is Basic, this makes no sense at all. Why not just check with Apache, if it set the username then import it? Surely Apache know if a user has authenticated? Ditto for password. It is so broken in fact that PHP in CGI mode also doesn’t work since those headers don’t get set for that either, countless comments and nasty hacks can be found in the PHP user contributed notes about this, but it is all just sillyness.

The reason this is annoying me is that I have written a Single Singon system in PHP, you can host a identity server on any domain and hook any site in any other domain into the SSO system, its a bit like TypeKey

Of course it’s nice to have a easy to use SSO system in PHP but what is the point if you can’t make legacy apps like Nagios, Cacti, RT etc play along with the SSO? So to solve this I extended Apache::AuthCookie with a new mod_perl module that plugs into Apache and does authentication using my SSO and a small bit of glue that you put on your RT/Cacti/Nagios box.

All’s great, I have SSO to Nagios, RT and countless other things working flawlessly, except of course Cacti because it’s written along the lines of the PHP manual, uses PHP_AUTH_USER instead of REMOTE_USER and so my new fancy AuthType in Apache does not work with Cacti. As it turns out its a quick 2 liner fix in the Cacti code but you would think PHP would be a bit more generic in this regard since as it stands now I think a lot of people who want to do SSO using hardware tokens and such have issues with PHP being silly.