Generate logs from your jabberd2 server using Bandersnatch

This tutorial attempts to guide the reader through the process of installing Bandersnatch for use with an existing Jabberd2 server.

Get the sources

We need the following:
* Bandersnatch
* Perl 5.8.x * Perl POE * Perl module: XML::Stream
* Perl module: Net::Jabber 2.x
* Perl module: DBI (mysql)
* Perl module: POE::Component-Jabber
* Perl module: POE::Filter-XML

Extract the Bandersnatch installation into a working directory. Install all the above modules, with their dependencies.

Configure database

Ensure that you have a working mySQL server installation. To automatically create the database permissions / structure, run the following command (as a priviledged mySQL user) from the Bandersnatch working directory:

mysql -p < bandersnatch.sql

Then restart the mysql server (we have changed permissions, must reload), by running :

kill -HUP `pidof mysqld`

(If this doesn’t work, restart mySQL manually. This may depend on your distribution)

Config files


This file is where the router gets its component and secret information from for component authentication. We want to tell it about a component called “bandersnatch”, whose secret is also “bandersnatch”…

Add the following lines:


…between the new tags. i.e., a file modified from default will now look like this:



Now that we have defined our component (above), we need to give it access to connect to the router, and log messages. Edit router.xml, and at the bottom, uncomment the log type ACL, as follows:

<acl type='log'>


Finally, we edit bandersnatch’s config.xml, make sure the following are set:


Double-check the port (you may have to change it from 5526 to 5347), and the component name. Also, as per the Bandersnatch documentation, make sure that is set to the name of your jabber server, else you won’t log anything :)

Run it

Finally, once you’ve confirmed that:

  1. Jabberd is running properly
  2. MySQL is running properly
  3. Bandersnatch tables have been created in mySQL
  4. The script is executable (“chmod 755” if it’s not)



The output should be something like this:

Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.8.4/POE/Component/Jabber/Client/ line 293.
Use of uninitialized value in subroutine entry at /usr/local/share/perl/5.8.4/POE/Component/Jabber/Clien t/ line 294.  
Connected to MySQL database (bandersnatch@localhost) ... Bandersnatch is listening! ;)

I ignore the errors. I think they have to do with the Jabber component, and they aren’t fatal. If anybody wants to enlighten me, please go ahead :)

If you found this useful, please share it and follow me on Twitter - I'd love to connect ;)