Nagios Plugin to monitor BOSH services


#!/usr/bin/perl -w
# check_bosh plugin for nagios
# usage:
# check_bosh -U url -H host
# Check if bosh service running at specified address
# initial version: 3 May 2000 by Truongchinh Nguyen and Karl DeBisschop
# current status: $Revision: 1196 $
# Copyright Notice: GPL
# $Id: 1196 2009-06-17 15:20:46Z s.strigler $

use strict;
use lib "/usr/lib/nagios/plugins";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
my ($verbose,$host,$response,$state);
my ($opt_V,$opt_H,$opt_h,$opt_U);
$opt_V = $opt_h, $opt_h = $opt_U = '';
$state = 'UNKNOWN';

$PROGNAME = "check_bosh";
sub print_help ();
sub print_usage ();


use Getopt::Long;
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"U=s" => \$opt_U, "url=s" => \$opt_U,
"H=s" => \$opt_H, "host=s" => \$opt_H,
"v+" => \$verbose, "verbose+" => \$verbose

# -h means display verbose help screen
if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }

# -V means display version number
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1196 $ ');
exit $ERRORS{'OK'};

# -U means URL
unless ($opt_U) { print_usage(); exit $ERRORS{'UNKNOWN'}; }

# -H means host name
unless ($opt_H) { print_usage(); exit $ERRORS{'UNKNOWN'}; }

if (! utils::is_hostname($opt_H)){
print "$opt_H is not a valid host name\n";

# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: No response from RPC server (alarm)\n");

$state = &check_bosh($opt_U, $opt_H);

if ($state eq 'OK') {
print "$state: BOSH service at $opt_U up and running\n";
}elsif ($state eq 'WARNING') {
print "$state: BOSH service not working correctly. Bad hostname given?\n";
print "$state: BOSH service at $opt_U is not running\n";
exit $ERRORS{$state};

sub check_bosh() {
my $url = shift;
my $host = shift;

use LWP::UserAgent;
my $ua = LWP::UserAgent->new;

my $req = HTTP::Request->new(POST => $url);
$req->content_type('text/xml; charset=utf-8');
my $payload = "";
print "SEND: ", $payload, "\n" if($verbose);


my $res = $ua->request($req);

if ($res->is_success) {
print "RECV: ", $res->content, "\n" if ($verbose);

if ($res->content =~ /type='terminate'/) {
return 'WARNING';
} elsif ($res->content =~ /sid='([^']+)'/) {
$req = HTTP::Request->new(POST => $url);
$req->content_type('text/xml; charset=utf-8');

$payload = "";
print "SEND: ", $payload, "\n" if($verbose);

$res = $ua->request($req);

if ($res->is_success) {
print "RECV: ", $res->content, "\n" if ($verbose);
else {
print $res->status_line, "\n" if ($verbose);
return 'CRITICAL';
else {
print $res->status_line, "\n" if ($verbose);
return 'CRITICAL';

return 'OK';

sub print_help() {
print_revision($PROGNAME,'$Revision: 1196 $ ');
print "Copyright (c) 2009 Stefan Strigler\n";
print "adopted from check_rpc by Karl DeBisschop/Truongchinh Nguyen/Subhendu Ghosh\n";
print "\n";
print "Check if bosh service is up and running\n";
print "\n";
print "\n";
print " URL of bosh service\n";
print " XMPP host name\n";
print " [-v] Verbose \n";
print " [-v -v] Verbose - will print supported programs and numbers \n";
print "\n";

sub print_usage () {
print "Usage: \n";
print " $PROGNAME -U url -H host [-v]\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";

Firefox 3.0.6 not able to read Cookie (breaks MUCkl/JWChat with HTTP Polling)

Firefox as of version 3.0.6 seems to not allow reading cookies from HTTP headers when doing AJAX requests. As a consequence JSJaC’s HTTP Polling backend can’t work correctly anymore and breaks usage of MUCkl and JWChat with this version of Firefox. If your site is affected please consider switching to HTTP Binding (aka BOSH) which should fix this issue.
HTTP Binding has been designed specifically to address issues with constrained clients not capable of reading HTTP header cookies.

JSJaC inherit

When integrating a web chat (like JWChat) into your existing community most likely you don’t want to have your users sign in a second time just for the chat. A possible solution to this problem domain is to let your web server handle BOSH session instantiation and xmpp authentication. Once successfull you can pass the credentials (i.e. the runtime data) of this BOSH session to JSJaC. There’s an undocumented method call ‘inherit’ which handles this.
Here’s a fine tutorial on how to do this: Chat Hacking, Part II

dojo vs. isArray

Some days ago a spent many hours to fix a somewhat broken toJson output from dojo. I’ve been copying around an array between different frames and ended up having an object instead of an array as it should be. Seems Ajaxian has a solution to this array bug now. So please dojo could you please fix your dojo.isArray?

ejabberd memory leak

If your ejabberd seems to leak memory it might result out of this bug in erlang’s mnesia database. You can easily find out by starting a remote shell to your running ejabberd and whatch results for the following command:

lists:foldl(fun(Tab, Acc) -> ets:info(Tab, memory) * 8 + Acc end, 0, ets:all()).

The bug is fixed at erlang OTP R12B5.

A good description of the problem can also be found at Yaws, Mnesia stress test notes.

ejabberd mysql drivers for debian and ubuntu

Debian (and ubuntu) packages for ejabberd don’t contain drivers for mysql. If you want to connect your ejabberd to mysql you need to get those drivers separately from the external ejabberd modules repository and compile them on your own.
For convenience I’ve built a debian package containing the precompiled modules:

Note: this package is not of the usual quality you’d expect from an official debian package. It’s just an alien’ed tarball containing the drivers at the right place (i.e. ‘/usr/lib/ejabberd/ebin’).

JWChat 1.0

After releasing JSJaC and MUCkl today I’m proud to announce another long awaited release: JWChat v1.0. JWChat is a web based yet full fledged jabber client. It supports most modern browsers like MSIE 6 and 7, Firefox 2.x, Firefox 3.x, Opera, Safari and many more.
Just like meebo you can do instant messaging with a variety of different networks by use of jabber transports. JWChat also has full support for MUC built in which lets you take part at groupchats.
There is a demo site at where you can give it a first try. Downloads can be found at

I appologize that there is no war file for this release yet. I’ll try to upload one ASAP but I have to fix my tomcat setup here first.

MUCkl 0.4.4 is out

A new release of MUCkl is available. MUCkl is a lightweight spin off project of JWChat. It offers web based access to Jabber/XMPP groupchats/conferences based on the MUC protocol without having to register for a jabber account (just enter your nickname and off you go!).
This release mainly fixes support for Firefox 3 plus some minor bugs.
Try out MUCkl at or download it from

JSJaC v1.3.2 released

A new release of JSJaC is available. JSJaC is a jabber/xmpp library for web based clients written in JavaScript. It supports BOSH and HTTP Polling for connecting to a jabber server. This release mainly fixes issues with Firefox 3.

jabber services back online

Glad to announce that all core services of are back online now. If you’re still experiencing problems let me know! is running on ejabberd-2.0.1 now. Amongst otherst this means you can dive deep into the world of refreshing PEP experience.
Also there is a new SSL certificate now. The old one had expired so I grabbed a new one over there at Please note that the CA has changed. The certificates are issued by StartCom now.
Additionally to and I’ve added a new vhost for Feel free to register there. Currently there’s no dedicated SSL certificate configured for it yet but I hope to change this soon.