The Life of a Sysadmin

Carousel is a lie!

Entries tagged "python".

Grabbing Confluence markup from an XML export
Thu Oct 15 12:27:22 PDT 2009

As part of a slow migration from Confluence to FosWiki, I had to grab the Confluence markup from an XML dump. I found a Python script to do this, but I think the XML format must have changed in the meantime; the script was unable to grab the body content.

I've lashed together a version available here that works with Confluence 2.10 and Python 2.5 . Now to convert the pages to Foswiki markup...

Ack! Just discovered this updated script in the comments section. Looks like that one grabs a lot more than this does (labels, attachments). Oh well, I needed the practice with Python.

Tags: python.
Sunday blues
Sun Apr 18 11:14:35 PDT 2010

I'm at work today. There was a scheduled power outage in the building that holds our server room. It was set for 7am to 11am; I got in at 6am 'cos I'm a keener and wanted to make sure I had lots of time to swap to the backup website.

Power came back on at 10:30 or so. 10:45 I wandered over to the building to see if that was it; didn't want to rush anyone, but thought it'd be worth asking. There was no one there. Sweet, thinks I, let's head down and turn on some machines. (Most are Sun machines and therefore work just fine remotely; some are older IBM machines, where I haven't figured out how to do IPMI over the network, and some are Dell machines where, whee! who knows how it'll work today?)

Turns out A/C's still off. Call the university folks; turns out someone's still working on it. But they're off for lunch, so no idea just yet how long that'll be. I'll be calling back in an hour to see if we have any idea. If they're working on it 'cos something went wrong, well, that's life. If they're working on it 'cos they had scheduled something, then I'm irritated I wasn't told beforehand. Oh well, we'll see what happens. (Update: Our rooftop A/C failed to come on after the power came back on. A full investigation, with twelve helicopters full of determined journalist-engineers, will be launched tomorrow. THIS GOES ALL THE WAY TO THE TOP, PEOPLE.)

In other news, it wasn't a complete waste of time today:

Loadsoflinks:

And just one more thing: my younger son turns two on Tuesday. We had an early party:

So cute

Tags: dell, python, waitinfortheman.
Time well spent
Wed May 05 21:14:43 PDT 2010

Just spent two hours staring at this Python regex:

method_re = re.compile('(?P<urlcmd>\s*url\s.*)|(?P<nfscmd>\s*nfs\s.*)')

and trying to figure out why it wouldn't match this line:

install url --url http://cobbler.example.org/cobbler/ks_mirror/CentOS-5.4/os/x86_64

After much research, I can report two things:

And now to read more of Dr. Zhivago.

Update: by way of explanation, I was trying to use koan and Cobbler to install a new qemu instance like so:

/usr/bin/koan --nogfx --server=cobbler.example.com --virt --system=virtserver-01.example.com

and was getting two errors:

warning: kickstart found but no install_tree found
Cannot find install source in kickstart file, aborting.

The problem turned out to be that my kickstart file had this line:

install url --url http://cobbler.example.org/cobbler/ks_mirror/CentOS-5.4/os/x86_64

which should have been two lines:

install
url --url http://cobbler.example.org/cobbler/ks_mirror/CentOS-5.4/os/x86_64
Tags: debugging, python.
Config file parsing
Wed May 26 06:14:40 PDT 2010

I've been setting up some new VMs for a separate project at work. I've realized that this is painful for two reasons: Bacula and Nagios.

Both are important...can't have a service without monitoring, and can't have a machine without backups. But each of these are configured by vast files; Bacula's is monolithic (the director's, anyhow, which is where you add new jobs) and Nagios' is legion. And they're hard to configure automagically with sed/awk/perl or cfengine; their stanzas span lines, and whitespace is important.

I've recently added a short script to my Nagios config; it regenerates a file that monitors all the Bacula jobs and makes sure they happen often enough. This is good...and I want more.

I found pynag, a Python module to parse and configure Nagios files. This is a start. I've had problems getting its head around my config files, because it didn't understand recursion in hostgroups (which I think is a recent feature of Nagios) or a hostname equal to "*". I've got the first working, and I'm banging my head against the second. The three books I got recently on Python should help (wow, IronPython looks nice).

There are a lot of example scripts with pynag. None do exactly what I want, but it looks like it should be possible to generate Nagios config files from some kind of list of hosts and services. This would be a big improvement.

But then there's Augeas, which does bi-directional parsing of config files. Have a look at the walk-through...it's pretty astounding. I realized that I've been looking for something like this for a long time: an easier way of managing all sorts of config files. Cfengine (v2 to be sure) just isn't cutting it anymore for me.

Now, the problem with Augeas for my present task is that there isn't anything in the current tree that does what I want, either. There is a commit for parsing nagios.cfg -- not sure if it's been released, or if it will parse everything in a Nagios config_dir. There's nothing for Bacula, either. This will mean a lot more work to get my ideal configuration management tool.

(On a side note, my wife said something to me the other day that was quite striking: I need tasks that can be divvied up into 45-minute chunks. That's how much free time I've got in the morning, bus rides to and from work, and the evening. Commute + kids != long blocks of free time.)

And I've got a congenital weakness for grand overarching syntheses of all existing knowledge...or at least big tasks like managing config files. So I'm trying to be aware of my brain.

...and there's son #2 waking up. Time to post.

1 comments. Tags: backups, monitoring, python.

RSS Feed