Compiling Varnish/Varnishtop: Issue with do_curses

When compiling varnishtop (and other tools) on RHEL/CentOS 5, I came across the following issue:

varnishtop.o: In function `do_curses':
/tmp/varnish-2.1.4/bin/varnishtop/varnishtop.c:223: undefined reference to `initscr'
/tmp/varnish-2.1.4/bin/varnishtop/varnishtop.c:224: undefined reference to `raw'
/tmp/varnish-2.1.4/bin/varnishtop/varnishtop.c:225: undefined reference to `noecho'
/tmp/varnish-2.1.4/bin/varnishtop/varnishtop.c:226: undefined reference to `nonl'
/tmp/varnish-2.1.4/bin/varnishtop/varnishtop.c:227: undefined reference to `stdscr'
collect2: ld returned 1 exit status
make: *** [varnishtop] Error 1

The issue seems to be with the ncurses library that comes with the standard distribution. So, I installed the ncurses-5.7 libs from source, using:
./configure --with-shared --with-debug --enable-overwrite --with-termlib

and then recompiling/building varnish/varnishtop.

CPU/Processor information in Linux

Finding Physical Processors:
$ grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l

Finding Virtual Processors
$ grep ^processor /proc/cpuinfo | wc -l

Finding CPU cores
$ grep 'cpu cores' /proc/cpuinfo

“2” indicates the two physical processors are dual-core, resulting in 4 virtual processors.
If “1” was returned, the two physical processors are single-core.

If the processors are single-core, and the number of virtual processors is greater than the number of physical processors, the CPUs are using hyper-threading.

Finding CPU Arch
$ grep flags /proc/cpuinfo | uniq | egrep -o -w "rm|tm|lm"

Under “Flags” section in /proc/cpuinfo, you will find any of the flags “tm” or
“rm” or “lm”

  • rm (Real Mode) means it is a 16 bit processor
  • tm (Transparent Mode) means it is a 32 bit processor
  • lm (Long Mode) means it is a 64 bit processor

Piwik Mediawiki Extension

Piwik( is open source self-hostable web analytics tool (like omniture orĀ  google analytics). To integrate piwik with mediawiki, I customized the existing Google Analytics mediawiki plugin ( to work with piwik. To include the extension in your wiki,
unzip the file, and deploy the piwik.php extension file into WIKI_INSTALL_DIR/extensions/. Then include the file in your LocalSettings.php, using:


Download piwik extension

Solution: received end packet from server, apparent master shutdown

If you are getting the below error in your mysql (slave) logs:
090723 21:46:40 [Note] Slave: received end packet from server, apparent master shutdown:
090723 21:46:40 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000012' at postion 106

Then, it means the slave is sharing an ID with another slave/node in the replication setup. Check the server ID to make sure it is unique.

Solution: Dell XPS M1530 Ubuntu 8.10 System Freeze Issue

When using Ubuntu 8.10 and connecting to a Wireless-n (802.11n) network, the system freezes with kernel panic (as indicated by blinking scroll and numlock). The system gets unusable and you would have to reboot. I have had this issue with my Dell XPS M1530, when connecting to Apple Extreme router.

The issue with the intel wireless module driver, and will get fixed by installing the compat-wireless driver.

Try compiling this iwlagn module, .
Extract the archive and then follow these steps:

sudo apt-get install build-essential
cd compat*
sudo make install

Reboot the system, and you will not longer face kernel panic or system freeze.


When installing 9.04, I figured out that 802.11N drivers for Ubuntu are totally broken. Since I did not want to fiddle around much, I added the following lines to /etc/modprobe.d/options(and restart the system):

options iwlagn 11n_disable=1

This would prevent Wireless-N mode, but it will get your Dell M1530 (and M1330) working on Wireless with Ubuntu

Using iTerm with Elasticfox on OS X

Elasticfox plugin for firefox on OS X uses by default(to SSH into the EC2 instances). If you would like to use iTerm instead of

1. Create a script (say ec2-ssh.osascript) in your home directory. This is an applescript.

on run argv
  tell application "iTerm"
    set cmd to "ssh -i " & item 1 of argv & " " & item 2 of argv
    set myterm to the last terminal
    tell myterm
      launch session "Default Session"
      tell the last session
        write text the cmd
      end tell
    end tell
  end tell
end run

2. Edit ElasticFox properties. It should look like the following:

capture 1.png

So, every time you try to SSH, it would use iTerm instead of

Using Tcpdump for MySQL query logging

If you are a privileged user (i.e. root), you can use tcpdump on a database server to take a peek into a network stream and filter for packets that go to MySQL. Those packets contain queries. Here’s a quick one-liner :
# tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if (defined $q) { print "$qn"; }
} else {
$_ =~ s/^[ t]+//; $q.=" $_";

Thanks to: