From Linux

Install Siege on Mac OS X Snow Leopard

I recently needed to install Siege on my MacBookPro. Here’s what I did:

tar -xvf siege-latest.tar.gz
cd siege-2.70/
./configure && make && make install

That’s it! Now you should be able to do something like this:

siege -c50

That will simulate 50 concurrent users hitting that particular URL. After siege runs for a bit, you can hit Ctrl+C to kill it and it will output some handy stats about performance.

Fixing eventfd() failed error after YUM nginx upgrade

After running a Nessus scan on my VPS last night, I ran a yum update to fix a few security holes patched in newer software packages. It was pretty late, so I went to sleep after the upgrade, because everything seemed to be working fine. This morning, when I went to log in to this site’s admin dashboard, I discovered that none of my sites were working. Pings were working fine, but a quick check of the nginx error log revealed this:

2011/03/28 15:18:30 [emerg] 2661#0: eventfd() failed (38: Function not implemented)

A quick Google search turned up this forum, which indicated that the problem was related to the fact that the YUM version of nginx 0.8.53 is compiled with the –with-file-aio option, which uses libraries that were apparently not installed on my system. The solution was to re-install nginx by downloading the latest source and compiling it.

Once I did this, I changed the value of the nginx variable in /etc/init.d/nginx from /usr/sbin/nginx to /usr/local/nginx/sbin/nginx (the location of the new executable). Running service nginx restart did the trick, and my sites were back up and running.

502 Bad Gateway with phpMyAdmin and nginx

I recently ran into an issue with phpMyAdmin served via nginx. When I would click on some of the databases on the sidebar in the home phpMyAdmin screen, the main frame would return a 502 Bad Gateway from nginx. The nginx error.log revealed an “upstream sent too big header while reading response header from upstream” error, which led me to this site. By adding the suggested lines into the http {} section of the nginx.conf file, then restarting nginx, I was able to see the table view load correctly in phpMyAdmin. It’s worth noting that I’m using php-cgi, not php-fpm, so the exact directives required may be slightly different if you’re using php-fpm.

Filtering numerically in a log file

I recently needed to filter some log data to find all the entries that exceeded a certain numeric value (in my case, 100). A little Googling yielded the following solution:

less /web/temp/apache_procs.log | awk '{ if( $6 >= 100) print $1 " " $2 " " $6}'

The first half of this command obviously opens the file in the ‘less’ viewer. The ‘awk‘ command, if you’re not familiar with it, is an excellent tool for printing various bits of tab-separated files. One of the things it does is automatically separate each column of the log file output into a numeric variable, so the first column is $1, the second is $2, and so on. In this case, I wanted to see columns 1, 2, and 6 (log date, log time, and number of apache processes running). Awk also allows for simple if statements, in this case ‘if ($6 >= 100)’, a simple check that results in awk printing out only the log entries where the numeric value of column 6 is greater than (or equal to) 100.

Become root on Mac OS X Snow Leopard (or Leopard)

Here’s a little tip I use all the time, but have yet to commit to the blogosphere. If you’re trying to work on the Terminal command line in 10.6 or 10.5, it’s annoying to be prompted for your password to sudo every 5 minutes, and it gets confusing who’s running what commands. If you just type

sudo /bin/bash

and authenticate once, you’ll get a command prompt as root, without having to auth every few minutes. Just. Remember. To. Log. Out.