Wed, 14 Mar 2007
Playing with Facter
I'm on-call tonight so I invested some time in facter, "A
cross-platform Ruby library for retrieving facts from operating
systems." While facter is an interesting command line program
(its extension mechanism is quite nice) its main claim to fame is that
it's used by puppet (which I'm slowly evaluating as a CFEngine
replacement) to determine facts about a machine.
While the docs are a little light on the ground the tgz contains a couple
of examples and after some playing around I think I've got a basic Linux
Bonding fact ready. For your viewing pleasure, the
Facter Linux Network
Bonding custom fact. It's not amazingly powerful or complex but it does
seem to do what I want and it gave me a reason to look around the Ruby
Dir class so it's not all bad. I've mostly put it up to show
how easy it is for someone with very little ruby knowledge to extend
facter.
Note: I also discovered that you can't do a confine :bonding =>
:true, facter works on literal string values, not on true or false.
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2007/03/14 23:20 | /ruby | Permanent link to this entry | This entry and same date
Linux Laptop Mode and /proc block_dump
Over at the
top-like command for disk io thread on GLLUG Kostas Georgiou mentioned
a Linux /proc file entry I'd never heard of before, and after
some digging it looks like it could be useful when debugging certain IO
problems. Assuming you have 2.6.6 or above - or a vendor patched kernel.
When you activate the option with a echo 1 >
/proc/sys/vm/block_dump as root (read the article and consider
turning syslog off first) the kernel starts to log which processes are
accessing which disk blocks and inodes. Below is a small chunk of its
output on my test VMWare system:
Mar 14 19:16:44 localhost kernel: sshd(2659): dirtied inode 388836 (sshd) on sda1 Mar 14 19:16:44 localhost kernel: sshd(2659): dirtied inode 533395 (libwrap.so.0) on sda1 Mar 14 19:17:23 localhost kernel: cat(2672): dirtied inode 888805 (.bash_history) on sda1 Mar 14 19:17:46 localhost kernel: kjournald(913): WRITE block 14016 on sda1 Mar 14 19:17:48 localhost kernel: pdflush(104): WRITE block 12487672 on sda1
The short version is, 'dirtied' means changed but not written to disk, pdflush
will write the rows out later, and READs are what you'd expect. A brute
force way to trace an inode to a file path is with find: find / -inum
num. The longer explanation can be found at LJs Extending Battery
Life with Laptop Mode under the "Spinup Debugging" heading.
It's no DTrace (and no, SystemTap isn't as good as DTrace) but it is neat and a decent addition to the debugging toolbox.
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2007/03/14 18:18 | /operatingsystems/linux | Permanent link to this entry | This entry and same date

