Wednesday, 11 January 2012

Ubuntu LabKey Upgrade Guide

Labkey has pretty thorough installation steps on their website, but just want to document the process using the manual upgrade guide, on Ubuntu 10.04. Guide assumed you are logged in as a local user and downloaded the setup files to your home directory. Also assumed tomcat has been installed through the repositories, which places tomcat binaries in /usr/share/tomcat6, configuration in /etc/tomcat6, labkey logs in /usr/share/tomcat6/logs.

First off, to avoid any issues, stop tomcat.

sudo service tomcat6 stop

Step 1. Untar the tarball

tar zxvf LabKey11.3-*-bin.tar.gz && cd LabKey11.3-*-bin

Step 2. Create a backupdir to move the existing labkey files into

cd /usr/local/labkey
sudo mkdir backup2
sudo mv labkeywebapp/ backup2/
sudo mv modules/ backup2/
sudo cp /etc/tomcat6/Catalina/localhost/labkey.xml backup2/

Step 3. Move the new files into the current directory

sudo cp -rd ~/LabKey11.3-*-bin/labkeywebapp/ ./
sudo cp -rd /home/trent/LabKey11.3-*-bin/modules/ ./

nb: The installation guide also suggest some MS1 and MS2 third party binaries, but I haven't bothered with those. And to avoid any issues, change the owner back to the tomcat user (tomcat6) of the directories just copied across:

sudo chown tomcat6.tomcat6 -R labkeywebapp/ modules/

If not already done, install graphviz

sudo apt-get install graphviz

Step 4. Copy the library files into the lib folder in tomcat, replacing any that already exist.

cd ~/LabKey11.3-*-bin/
sudo cp -i common-lib/* server-lib/* /usr/share/tomcat6/lib/

Step 5. Copy the labkey.xml file to the tomcat cnofiguratino directory

cd ~/LabKey11.3-*-bin
sudo cp -i labkey.xml /etc/tomcat6/Catalina/localhost/labkey.xml

Then it's just a matter of updating the labkey.xml file. Things to update: Point the docBase to the labkeywebapp folder (line 1) <Context docBase="/usr/local/labkey/labkeywebapp" debug="0" reloadable="true" crossContext="true"> Update the username and password in the Resource for the labkey database server Update the mail server configuration Any other resources that may need re-adding e.g. External data sources. Finally, start tomcat

sudo service tomcat6 start

Tuesday, 3 January 2012

Analysing TCP Traffic

There are often times when you want to analyze TCP network traffic to see what is actually being sent over the network in a lower level. There are a few nifty tools around that are able to do this. Graphically, wireshark is one. However, i prefer to just use a command line tool - thankfully, one of the default apps available on Ubuntu on a fresh install can also dump traffic, and this is tcpdump.

By running this command with some default options, you can get aanalyze the packets being transmitted over the network. The packets can be captured in realtime, or to a dump file, which can be later analyzed. What I have found more useful, is to first capture it to an a dump file.

For example, I have a web based application running on port 8080, that I want to inspect to see what is going on, so I issue the following command:

sudo tcpdump -i eth0 -s 0 -nw output.dmp dst port 8080

The argument basically say, in their order:

interface: eth0
snarf: 0 bytes, rather than the default 68 - less information to go through - For me, I am only really interested in the headers
no address/name resolution - maintain their IP address value
write: to output.dmp
dst port: only capture packets going to port 8080; More complex filters can be captured, and documentation on the filter syntax can be viewed in the man page of pcap-filter

This produces a binary file, so it is no good trying to read this in a simple text editor, however you can output the contents by passing in the -r flag (read)

sudo tcpdump -r output.dmp -A

I prefer to use the A flag (ASCII), but you could also use the -X flag. I think the -A flag produces slightly more readable request headers. In saying that, the X flag would be useful for viewing the data in both hex and ASCII format.

Another useful tool (which you need to install) is tcpick, which can also parse the data dumps captured by tcpdump.

sudo tcpick -C -yP -r output.dmp

Which is basically saying, print with syntax highlighting, and to show data contained in the packets. No doubt, this does output the data nicely formatted, but other than that, I see no real reason not just to use tcpdump with the -A flag for viewing the captured packets.