powered by Jive Software

Problems with using perl to log into Jabber

Hello,

I am trying to setup a very simple alert bot for Jabber that would send a message to me when an event happens.

For some reason every single time I try to connect (with valid credentials, I should add) to my Wildfire Enterprise server, I am given this weird “error not-authorized” message. Here is my short perl script:

#!/usr/bin/perl

use Net::Jabber;

use XML::Parser;

use XML::Stream;

use constant SERVER => ‘‘my.jabber.install’’; # Jabber server to connect to

use constant PORT => ‘‘5222’’; # Port to connect to

use constant USER => ‘‘alertbot’’; # user this script connects as

use constant PASSWORD => ‘‘password-for-alertbot’’; # password associated with USER

use constant RESOURCE => ‘‘perl’’;

my $me = USER . “@” . SERVER;

my $connection = Net::Jabber::Client->new();

$connection->Connect( “hostname” => SERVER,

“port” => PORT )

or die “Cannot connect ($!)\n”;

my @result = $connection->AuthSend( “username” => USER,

“password” => PASSWORD,

“resource” => RESOURCE );

if ($result[0] ne “ok”) {

die “Ident/Auth with server failed: $result[0] - $result[1]\n”;

}

my $msg = Net::Jabber::Message->new();

$msg->SetMessage(

“to” => “dan.u@my.jabber.install”,

“body” => “TESTING TESTING”

);

$connection->Send($msg);

Here is what happens when I execute the test code:

  1. ./index.cgi

Ident/Auth with server failed: error - not-authorized

The exact error message the server returns in $result[0] and $result[1] is “error” and “not-authorized” int he same one.

Is this the script that was originally created for Nagios alerting? If so, we’'ve gotten that one to work, and I can check with my resident Perl wizard to see what modifications he made.

Well anyway, I did some looking. That is the same script. For anyone else who might care, or if midphase ever returns, the solution is to replace the AuthSend call with AuthIQAuth.

What about moinitoring the service I can monitor the executable but not when the service crashes.

Using Nagios, I settled for checking the Java VM was running and running a TCP port check if this is what you mean by monitoring Wildfire - I’‘m sure a bit of grep’'ing could identify Wildfire in the the output of ps aux | grep java to nail it down a bit better, but this simple check works for me.