Adding Smoketrace to a Smokeping install

Adding Smoketrace to a Smokeping install

Smokeping is a very good latency monitoring  tool that runs on Linux and is easy to install via "apt-get install smokeping". With Ubuntu the addition tool, Smoketrace is currently not included in the 2.003006 version from the repository. It is quite straightforward to add Smoketrace to an already working Smokeping install :) The following assumes you have a working Smokeping install already and your using Ubuntu 10.10 (although most of the config would be very similar for Centos etc).

First we need to download and extract the file

cd /tmp
wget && tar xvzf smokeping-2.4.2.tar.gz

Some other libraries we will need for later on

apt-get install libjson-perl libcgi-session-perl traceroute

Now we need to make a couple of directories to hold Smoketrace

mkdir -p /var/www/smoketrace/script

Now we copy the files we want to our new directories.

cp /tmp/smokeping-2.4.2/htdocs/script/Tr.js /var/www/smoketrace/script
cp /tmp/smokeping-2.4.2/htdocs/tr.html /var/www/smoketrace/
cp -r /tmp/smokeping-2.4.2/htdocs/resource /var/www/smoketrace/
cp -r /tmp/smokeping-2.4.2/htdocs/tr.cgi.dist /var/www/smoketrace/tr.cgi
mv /var/www/smoketrace/tr.html /var/www/smoketrace/index.html

Now we copy the smokeping lib to our Perl5 directory

cp -r /tmp/smokeping-2.4.2/lib/ /usr/share/perl5/

Edit the tr.cgi file to configure the location of a couple of things like below (the location of speedy and the smokeping perl lib)

vi /var/www/smoketrace/tr.cgi

Should look like this

#!/usr/bin/speedy -w
use strict;
use lib qw(/usr/share/perl5/lib);
use lib qw(perl);

Now is a good time to test what we just configured. The output should be similar to below, if not recheck the configured locations in tr.cgi.

root@linux:/var/www/smoketrace# perl tr.cgi
Set-Cookie: CGISESSID=3c2efd06604a2591760fca4943148bf; path=/
Date: Wed, 22 Dec 2010 10:49:18 GMT
Content-Type: text/html; charset=ISO-8859-1

Your HTTP Client is not using the JSON-RPC protocol

Add a .htaccess file with rules that allow smoketrace to work

vi /var/www/smoketrace/.htaccess

Then paste in the two lines

AddHandler cgi-script cgi
Options ExecCGI

Now to add some rule to /etc/apache2/sites-available/default specifcally for our new directory

vi /etc/apache2/sites-available/default

Then add the following section

<Directory /var/www/smoketrace>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

At this point you should be able to go to http:///smoketrace and use it no problems :) One problem I did come accross was "The specified type of tracerouting is allowed for superuser only" error from Smoketrace. To resolve this I used the following command to set the setuid bit.

chmod u+s /usr/bin/traceroute

Now you should have a working web based traceroute tool :)