fixing nagios on debian

January 17th, 2005

I had trouble with CGI access to Nagios after an apt-get upgrade on my debian box. I kept getting the error “It appears as though you do not have permission to view information for any of the services you requested”. The key is to remember to check that all the configuration files are readable by the nagios user, since when it’s running as a CGI, it doesn’t have the same access as it does when running as a daemon.

path python module

December 3rd, 2004

I don’t think I’ve mentioned the path python module in detail before, so I will now.

It’s amazingly useful, and so much more intuitive than the standard library equivalents (os.path, etc.). If you’re like me, and you never got the hang of iteration or recursion in bash scripting, this module is for you.

I’m using it to iterate over all directories on the server with a ‘preproc.log’ file in them and collecting information about some of the files within.


import time
import path

DAY = 24 * 3600 # seconds
NOW = time.time()



globs = (("run*_raw+orig.BRIK", 21), # glob, max age
         ("p*_auto+tlrc.BRIK", 28))

def age(f):
    return int(NOW - f.atime) / DAY

p = path.path("/home")
for preproc_file in p.walkfiles("preproc.log"):
    p_dir = preproc_file.parent
    for glob_pattern, max_age in globs:
        for f in p_dir.files(glob_pattern):
            if f.islink():
                # ignore symlinks
                continue
            elif age(f) > max_age:
                print f.size, f
 

helpful hint

November 23rd, 2004

If it’s a big pain when a workstation’s ssh keypair gets lost, back it up.


#!/bin/sh

HOSTNAME=`hostname`
sudo cat /etc/ssh/ssh_host_dsa_key > ws_keys/ssh_host_dsa_key.${HOSTNAME}
sudo cat /etc/ssh/ssh_host_dsa_key.pub > ws_keys/ssh_host_dsa_key.pub.${HOSTNAME}
sudo cat /etc/ssh/ssh_host_rsa_key >    ws_keys/ssh_host_rsa_key.${HOSTNAME}
sudo cat /etc/ssh/ssh_host_rsa_key.pub > ws_keys/ssh_host_rsa_key.pub.${HOSTNAME}

chmod go-r ws_keys/*.${HOSTNAME}


caretaker indirection

November 22nd, 2004

We’ve got a “data archive” here, where we store all of our raw fMRI data, for safe-keeping. Unfortunately, it’s hard to allow the kind of fine-grained access control which would allow people to insert new data but disallow alteration or removal of data.

The solution I’ve come up with is to use a caretaker pattern, which means a program on the server side which creates, unlocks, and re-locks the appropriate directory. The workstation prepares the new data and then calls out (via ssh and sudo) to the caretaker, which prepares the new directory. The data is copied over, and then the caretaker re-locks the directory.

let’s go zipf

November 15th, 2004

Check out that curve! Woo! I’ve got your logarithm right here!