posted on Friday October 10, 2008 - 1:59 pm (1 day, 11 hours ago)
tags , , , , ,

Since we have a standalone VMWare ESX Server, we’re not using the consolidated backup (which doesn’t really sound like it would achieve what I want in a backup system anyway). Instead, every night I export all of the Virtual Machine disk and configuration files off to another server.

This way, if the ESX Server and it’s storage cluster completely fails, it is a simple task to rebuild the server and recover the disk images. It is an unlikely occurrence, especially if you’re using external storage such as a NAS or SAN device, but it might just save my bacon.

The script that I use to backup the virtual machines is good. It creates a snapshot of any virtual machine and then exports that snapshot to disk. The problem with the script is that it doesn’t always delete the snapshot even though it’s supposed to. Then, when it next attempts to backup a virtual machine it fails as the existing snapshot conflicts.

So, I came up with a small script to remove and consolidate all snapshots for each running virtual machine prior to the backup. Since I’ve implemented this script to run before the backup script, the problem has gone away. Note that this script is intended to run on VMWare ESX Server 3.5 and is unlikely to work on 3.5i as it does not have the Linux interface. It may work on older versions of ESX Server but it may require some minor changes to do so.

I’ll explain the script bit by bit:

for virtualMachine in $(/usr/bin/vmware-cmd -l)
do
	...
done

This do loop runs through all of the virtual machines that are found by the list command. Next, only limit ourselves to virtual machines that are running (you could skip this step if you wanted to remove snapshots from all virtual machines):

if /usr/bin/vmware-cmd $virtualMachine getstate | grep -q "on"
then
	...
fi

The if statement queries the ESX server to see if the virtual machine is running. If it is running, we’ll next check if it has any snapshots we want to consolidate and remove:

if /usr/bin/vmware-cmd $virtualMachine hassnapshot | grep -q "1"
then
	...
fi

The final thing to do is to actually remove the snapshots:

/usr/bin/vmware-cmd $virtualMachine removesnapshots

Putting it all together, our script looks like this:

for virtualMachine in $(/usr/bin/vmware-cmd -l)
do
	if /usr/bin/vmware-cmd $virtualMachine getstate | grep -q "on"
	then
		echo $virtualMachine is running...
		if /usr/bin/vmware-cmd $virtualMachine hassnapshot | grep -q "1"
		then
			echo $virtualMachine has a snapshot, removing...
			/usr/bin/vmware-cmd $virtualMachine removesnapshots
		else
			echo $virtualMachine has no snapshots.
		fi
	fi

	echo
done

It’s a pretty simple script which you could possibly tart up by logging to /var/log/ or somewhere else. You could even have it email you with the results. For our purposes, though, it’s worked a treat and was a fun re-introduction into shell scripting since I haven’t done it for years.

No comments, make a comment »
posted on Friday October 3, 2008 - 4:59 pm (1 week, 1 day ago)
tags , , ,

Microsoft Outlook can be a great collaborative program, but sometimes it seems to lack features that you think would be no-brainers. For instance, there is no easy way (that I can find) to create categories globally for all users. Obviously, you wouldn’t want to force users into using categories but in some instances it can be useful to have everyone’s “meeting” category with the same name and (probably more importantly) colour which appears in the calendar.

There are two ways to give everyone in a work group the same categories. The first is to set them up on one copy of Outlook, and export the registry keys. These keys are imported for all users. The problem here is that the keys will overwrite any other customisations.

The second way is to use the Windows Scripting Host to connect to a local instance of Outlook and create the categories. Let’s walk through how we’ll do this. Note that this has only been tested with Outlook 2007, but does not require Administrative privileges to run.

First, create an Outlook object and a connection to that object’s MAPI interface:

Dim oOutlook : Set oOutlook = CreateObject("Outlook.Application")
Dim oNameSpace : Set oNameSpace = oOutlook.GetNameSpace("MAPI")

Next, use the MAPI interface to create a new category:

oNameSpace.Categories.Add "Our category", 1, 2

Where the first number is a number between 1 and 25 and the second is between 2 and 12 (more on these later). The first number denotes the category’s colour and the second denotes the shortcut key.

Pretty simple, but you probably want something more robust that you could use in a login script to ensure all users get the same categories. A robust solution should check if the category exists so you don’t tread on anyone’s toes.

Function categoryExists(categoryName)
	Set theCategories = oNameSpace.Categories
	For Each theCategory in theCategories
		If theCategory.Name = categoryName Then
			categoryExists = True
			Exit Function
		End If
	Next
	categoryExists = False
End Function

This function loops through all of the categories and returns True if the category submitted to the function exists. To use the function, we might expand our earlier line into the following:

If Not categoryExists(catName) Then
	oNameSpace.Categories.Add catName, catColour, catShortcut
	WScript.StdOut.Writeline "Added '" & catName & "' into Outlook."
Else
	WScript.StdOut.Writeline "'" & catName & "' already exists in Outlook. Not adding."
End If

Before I mentioned integrating category creation into a login script. To do this, you want to allow people to pass categories in at the command line:

catName = WScript.Arguments.Item(0)
catColour = WScript.Arguments.Item(1)
catShortcut = WScript.Arguments.Item(2)

You can view the list of colours and shortcuts on Microsoft’s MSDN site.

Putting everything together, and we have a script which you can call from the command line using the following command:

cscript /nologo addOutlookCategory.vbs "Hello World" 4 7

This will create a new category named Hello World, which has a corresponding yellow colour, and can be set by pressing CTRL-F7.

Download the entire script for yourself:

If you find this script useful, please drop me a line in the comments below.

No comments, make a comment »
posted on Monday May 19, 2008 - 10:39 pm (4 months, 3 weeks ago)
tags , , , ,
I’ve spent much of this evening fighting, cajoling Wordpress into doing my bidding. I wanted my Twitter posts to appear inline with my blog posts but had not been able to make this happen until tonight.

The reason I had trouble is because the way Wordpress is designed is — in places — extremely limiting. While you’re in the middle of the main “blog post” loop, you can’t use the same infrastructure created to go off on a tangent. No, instead you have two choices, write your own database API (with the possibility of breaking things later), or put data you want to retrieve later into a large and cumbersome array.

I chose the latter. Before the blog posts are loaded, I load all (yes, all)the Twitters into an array. As I pass through the blog posts I check through the Twitter array for Twitters around the same time and output them if relevant. I’ve added a few ways to jump over already-output Twitters and stop if we’re at the last post in a page, but it’s still unwieldy and annoying.  Stupidly, categories and tags seem to be stored in the database in almost the same manner.  This is good if you want them interchangeable — which I don’t; I want categories as categories (think of libraries with their books on certain shelves) and tags as keywords which relate to the content of the post.  It doesn’t seem to work like this (at least internally) and if it does I couldn’t find any good documentation on it in my meagre searching.

Even worse, Wordpress uses a bunch of really common-sounding variables ($post, $query_string) without much documentation on these reserved variables. Now, Wordpress is great if you’re not a tinkerer, which I guess makes me not the regular target user. Still, the more I delve the more frustrating it gets. I changed for interoperability and I got it, just at the expense of hyper-customisation.

On the plus side, I’ve now been able to integrate the Twitters inline with the posts just how I wanted it. I could have had a summary each day using the Twitter plugin I’m using, but I wanted the Twitters running throughout the posts. In addition, they don’t show up on pages 2 and beyond, and aren’t in the sidebar. I like to think of Twitters as non-historic bits of information.

Even though I’m glad I got it all up and running (after three separate attempts using three different approaches over two separate days) I’m not so sure this is how I want to keep it. I’ll be keeping an eye on others using the summaries and a couple of other sites using a similar approach to me and make my decision later. If I post more regularly I think the way it is will be best… but that means I have to post!

One comment, make a comment »
posted on Sunday May 4, 2008 - 9:58 pm (5 months, 1 week ago)
tags , , ,

Since I’ve taken up Twittering with what seems to be a reasonable amount of frequency, I had added the Twitters I… twitter into the list of posts. Previously just the latest was at the top of certain pages. I’ve also moved the “seconds until retirement” counter — which is still going strong — to the right into the side menu bar.

I’ve given the Twitter posts a distinctive look; since they’re a lot shorter they don’t need as much information crowding them. There are still a few problems to resolve which mainly involve removing Twitter posts from a lot of places — they appear in the RSS feeds if you’re already subscribed (if you resubscribe using the links on the page you’ll not get the Twitters any longer), the Twitter posts count towards the “seven posts per page” which I don’t want (I want seven posts per page plus any Twitters inbetween, which isn’t as easy as it seems using Wordpress’ API) and finally the Previously/In History need to have Twitters removed also.

I am thinking about other possible integrations in the future. Examples include Facebook updates (though I also never use it), some sort of public bookmark creation (I don’t use one of these services at the moment) and maybe something else which follows me around. The idea is not just to have a list of posts on the site but sort of a “What’s Mike up to?” stream from around the place. Whether it’s easy or will even work remains to be seen.

Other work includes joining the flickr and regular comments (where relevant) into one comment stream, but this is a bit of work (involving merging two arrays into one with lots of error correction for busted Internet connections) and since it’s already working it’s way down on the list of stuff to do.

Also: ScribeFire — look it up.

No comments, make a comment »
posted on Wednesday June 30, 2004 - 9:05 am (4 years, 3 months ago)
tags , ,

Last night, I created another three styles based on the ahh, relaxed style. They are late night, a rather dark theme (harking back to the early days of the Internet where 8/10 sites had black backgrounds), zen, which is only called “zen” because of the picture at the top, there’s nothing zen about it. The last is called life’s a beach and has lots of blue, and doesn’t really look that great.

I won’t probably bother making any more stylesheets based on these themes, but I think I will have a bit more of a play with yet another completely different look for the site. I haven’t decided on that look yet, so it may take a while.

I think I now have more stylesheets/themes than regular visitors!

No comments, make a comment »
posted on Tuesday June 29, 2004 - 6:54 pm (4 years, 3 months ago)
tags , ,

After much toiling with stylesheets and cross-browser incompatibilities, I have created two new stylesheets for this site.

The first is a comic-inspired theme called Awsoma-power!!. It’s really quite gaudy, and ugly. It was mainly something that resulted from me playing around with PNGs and layers. I might try to make it look a bit less ugly since I didn’t spend much time on it. I wouldn’t mind getting it to look funky.

The second is a complete re-design for the site, called Ahh, relaxed. Just using stylesheets, it makes the site look completely (well, very) different in look and feel. I think I will be basing a few more styles based on this template. The picture at the top is my own, and I will only be using images I’ve taken myself for the site titles.

I am considering having a random style come up each time the site loads if you have not selected a stylesheet. I am also aware that the ‘n’ grey series of stylesheets look pretty crappy in Internet Explorer, I will endeavour to fix this.

Let me know what you think!

No comments, make a comment »
posted on Thursday June 24, 2004 - 8:18 pm (4 years, 3 months ago)
tags , , ,

After a little bit of playing with PHP this evening, I’ve finally managed to get the server to send email via my current ISP. It’s easy at work because there’s no authentication required and it’s just always been setup to work. At home, it was a little more difficult and after a few hitches (complaints of non-existant domains, and so on), it’s finally working.

The reason I’m writing, and you’re reading this is because I’m wondering whether people would find it useful to receive an email whenever a post’s been made. There’s hardly any registered users here as it is, and I suspect not all of them would make use of such a thing. Obviously, such a feature would require people to register, if they wanted to receive email. As part of the registration I’ve already been asking for the email address (in anticipation for this and other possible features down the track) so I already have your details.

So, is this something the people who visit the site want, or wouldn’t you use it? Email me if you’d prefer.

No comments, make a comment »
« Older Posts  
bludger.org (version 9) © 2000-2008 bludger.org. All rights reserved.
Not many animals were harmed in the making of bludger.org, but a lot were eaten. And they were delicious.
I mean, really, really nice. I especially liked the squab, he didn't put up a fight.