Monday, July 9, 2007

Slow Rails Requests

I just had a short debugging session that ended in one of those "ooooooh! Duh. Why didn't I think of that sooner?" moments.

I was setting up a Debian system running Apache 2.2.3. I installed libfcgi-ruby and libapache2-mod-fcgid. I got that set up, enabled the mod, made an alias to the rails directory, and setup the .htaccess file. However, I was unhappy that my rails applications were terribly slow! There was a pause of 2-5 seconds for every request. Since this was just internal development I figured it was okay. Other hosts worked just fine, so I figured it was something strange about this particular configuration and I had other things to do.

Like any itch you try to ignore, this one only got worse. So today I decided to go over my configuration and figure out what was wrong. All the files are there; the modules are loaded; no strange log messages; how odd. I watched top while reloading a page and my dispatch.cgi just disappeared after the request. It was as if I was running it as a CGI process.

Wait a minute, like a CGI process? Let me see that .htaccess again. That was where I saw it:

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]


Oooooh! Duh. I hadn't pointed the .htaccess file at the fcgi script, so I was running it as a CGI process and it was having to load ruby and the script for every request. No wonder it was slow. I did a quick swap to,

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]


What a difference a single letter can make. It zips long happily now and I once again betray my ignorance.

Tuesday, June 26, 2007

Netatalk with SSL

It appears that the incompatibility of SSL with GNU has struck again. As you may or may not know, Netatalk under Debian/Ubuntu does not come with SSL support, thus all passwords are transmitted in clear text as OS X is happy to nag you about. How do you add SSL support? We use SSH and HTTPS, so why not with netatalk? It turns out it is very easy to add.

A few simple commands will get it built on your Debian system with SSL support.

Monday, June 25, 2007

Setting up Solaris Man Pages

In most Linux distributions the documentation is fairly well unified and centralized. You can find your man pages in /usr/share/man and other documentation in /usr/share/doc. Solaris likes to spread its documentation out a bit more. This is convenient when adding third-party packages or software because it keeps the system's man pages separate from the software. It is inconvenient when software creates a new manual location and doesn't tell the system about it.

The system will search the MANPATH for man pages whenever you use man, whatis, or apropos. This variable is just like the usual PATH in that it is a colon-separated list of paths. For example to set a MANPATH that includes /usr/share/man and /usr/sfw/share/man, and you use pkg-get to install software in /opt/csw, then you might use,

MANPATH=/opt/csw/share/man:/usr/sfw/share/man:/usr/share/man

Now you can can type man vim and get the manpage from /opt/csw/share/man/man1/vim.1.gz to dipslay. Of course if you were to try apropos vim you would get an error:

/opt/csw/share/man/windex: No such file or directory

Oops. Apropos needs a whatis index to be built. You will need to run catman to build the indexes. It will automatically use your MANPATH to do so.

catman -w

Now you can apropos and man to your heart's content.

Thursday, June 21, 2007

Right-Clicking With a One-Button Mouse (Ubuntu)

I recently encountered some one who was running Ubuntu on a non-mac system, yet was stuck with only a one-button mouse. The problem is the issue of right-clicking.

I found a nifty little program called mouseemu which allows you make a key press act as a mouse click. To get it working, simly do the following.

First, you need to install the mouseemu package. You can do this through synaptic or apt-get as follows:

sudo apt-get install mouseemu


Once it is installed you'll want to modify /etc/defaults/mouseemu because unless it detects a PowerPC system it won't set up any keys by default.

Inside /etc/defaults/mouseemu you will find options to set the various clicks. These are exactly as described by the man page and are simply passed as arguments to the daemon when it starts up. You can find a full list of the scan codes in /usr/include/linux/input.h. You want the decimal number after the #define KEY_ entry.

For example the following give the codes for the keys F8 through F12.

#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
#define KEY_F11 87
#define KEY_F12 88


These are scancodes and if you want to use a modify you need to find the scan code for that one too.

Once you have those two numbers you simply uncomment the line for the desired action and insert the right scan codes. For example, to make F12 with no modifiers do a right-click I would have the following line:


RIGHT_CLICK="-right 0 88"


Note that you can only have one key per button, so you can't make multiple buttons map to the same mouse click. The last one in the file is the one that gets used.

After you have set up your /etc/defaults/mouseemu, restart the daemon and things should work without too much trouble. To restart the daemon run the following from the command line.

sudo /etc/init.d/mouseemu restart


And you should have a right-click whenever you hit the F12 button.

Thursday, June 14, 2007

Configuring Solaris Sendmail

I have a lot of hosts behind a router on a non-routable LAN. I like to set them up so that they can send mail to my main mail account, which is outside the LAN's domain. This causes problems when my mail server won't accept mail from systems it can't reverse-lookup, such as my LAN hosts. Thus I use masquerading. Here's a quick HOWTO on configuring Solaris and sendmail to masquerade and send through a smart host. It is a little out of date, and geared primarily for workstations, but it walks you through the otherwise complex sendmail configuration and explains each option along the way.

Configuring Solaris Sendmail

Wednesday, June 13, 2007

Where did the word benchmark come from anyway?

Ben Rockwood, over at cuddletech.com explained in a post on I/O benchmarking where the term originates:

The term comes from wood working and other such crafts. When a craftsman is making, for instance, table legs you first carefully cut your wood to size, measuring for exactness. Once it's done properly you can then take that funny flat pencil, make a pencil mark on your bench and then use that to measure up all the following pieces to speed the process along. Based on the mark you know if your other pieces are too long or short and make the needed alterations. The mark is not a measurement per se, but rather a quick method of judging difference between things that should be similar.


Think about how you use benchmarks. Are they just to get some data to impress your friends, or do you actualy use them to see how your current system measures up to expections? Benchmarks are an important part of system administration, because without them how can you know if a system is behaving as you would expect? I can't give any good examples, but it may be something to look into.

Getting Solaris to use DNS

I was surprised today, after a day of frustration, to find that Solaris doesn't use DNS by default. Whenever I used dig or nslookup the names would resolve just fine, but ping and other utilities would complain about an unknown host. So somewhere there was a disconnect about using my /etc/resolv.conf.


I had previously set up my /etc/nsswitch.conf to get passwd information from a central server, but I was surprised to find out that the nsswitch.conf I had modified didn't include DNS resolution.

hosts: files

You can enable DNS resolution by changing it to the following

hosts: files dns

And suddely ping works again.