Jabber notification

Fred Jordan fjordan at hcssun01.hcs.net
Sat Jul 19 13:44:20 CEST 2003


Ian,
	Sorry to take till today to respond; been busy with the
Cisco IOS vulnerability issue. Guess you being at juniper.net you
can only smile...

Here is my misccommands.cfg entry:
# 'notify-by-jabber' command definition
define command{
        command_name    notify-by-jabber
        command_line    /usr/bin/printf "Service: $SERVICEDESC$, Host:
$HOSTNAME$, State: $SERVICESTATE$, Date: $DATETIME$" |
/usr/local/nagios/notify-by-jabber.pl
        }

My script, notify-by-jabber.pl, sends a message to the "message of the
day" as opposed to your script which sends a message to a single user.
Not being real good on the jabber server side so please excuse the
lame question, but would you know how to send a message to a paticular
conference room? Or is there such a thing as a alias or group of users
on a jabber server? Reason I wasn't wanting to send to individual users
is I thought it would error out if the user my script was sending to
wasn't logged into the jabber server at the time the script fired off.

Also, would rather send 1 message to all on the jabber server, instead of
10 to 20 messages to all of the people who may be logged into the jabber
server.

I eamiled my notify-by-jabber.pl script to this list earlier, but can send
it to you if you missed it or need to see it again.

					Thanks Ian,
						Fred
On Fri, 18 Jul 2003, Ian Davidson wrote:

> I THINK I'm making progress with this. I've devised a slightly different
> perl script which when run manually produces the correct jabber output.
>
> 	# ./test3.pl idavidso at jabber.company.net  "Test Message"
> 	We are connected to the server...
> 	We are disconnected from the server...
> 	[root at fangio ~/jabber-test]#
>
> At this point a chat window appears with the message "Test Message" in.
>
> However I can't work out what command_line is miscommands.cfg to put to
> get an alert generated properly. I've setup a contact with a pager email
> address (idavidso at jabber.company.net) which I'm hoping would appear as
> $ARG[0].
>
> I've tried...
>
> 	command_line    /usr/local/nagios/test3.pl $CONTACTPAGER$
> "Service: $SERVICEDESC$, 	Host: $HOSTNAME$, State: $SERVICESTATE$,
> Date: $DATETIME$"
>
> ...and also tried putting some stuff in manually...
>
> 	command_line    /usr/bin/printf "%b" "Nagios report" |
> /usr/local/nagios/test3.pl 	idavidso at jabber.company.net "Test
> Message"
>
> ...but absolutely nothing happens.
>
> Here's the script...
>
>
> #!/usr/bin/perl
> #use strict;
> use Net::Jabber qw(Client);
> use Net::Jabber qw(Message) ;
> use Net::Jabber qw(Protocol) ;
> use Net::Jabber qw(Presence) ;
>
> #These are the variables called later in the script
> use constant RECIPIENT => $ARGV[0];
> use constant SERVER    => 'jabber.company.net';
> use constant PORT      => 5223;
> use constant USER      => 'my-username';
> use constant PASSWORD  => 'my-passwd';
> use constant RESOURCE  => 'my-nickname';
> use constant MESSAGE   => $ARGV[1];
> use constant MAXWAIT   => 2 ;
>
>
> my $len = scalar @ARGV;
>
> #if there are no arguements given in the command, display the format
> if ($len ne 2) {
>    die "Usage...\n notify [jabberid] [message]\n";
> }
>
> my @field=split(/,/,$ARGV[0]);
>
> $Con = new Net::Jabber::Client();
>
> $Con->Connect(hostname=>"jabber.juniper.net",port=>5223,ssl=>1);
>
> if ($Con->Connected()) {
> print "We are connected to the server...\n";
> }
>
> # Verify authentication has occured correctly
> my @result = $Con->AuthSend( "username" => USER,"password" =>
> PASSWORD,"resource" => RESOURCE );
> if ($result[0] ne "ok") {
>  die "Ident/Auth with server failed: $result[0] - $result[1]\n";
> }
>
> #Send message
> $Con->MessageSend(to=> RECIPIENT,
>                   subject=>"Notification",
>                   body=>MESSAGE,
>                   type=>'chat',
>                   thread=>"ABC123"
>                   );
>
>
>
> #my $message = Net::Jabber::Message->new();
> #$message->SetMessage( "to"           => "icatlin at jabber.juniper.net",
> #                      "subject"      => "Notification",
> #                      "type"         => "chat",
> #                      "body"         => MESSAGE);
> #
> #   $Con->Send($message);
>
> sleep(MAXWAIT);
>
> $Con->Disconnect();
> print "We are disconnected from the server...\n";
> exit;
>
> > -----Original Message-----
> > From: Skip Montanaro [mailto:skip at pobox.com]
> > Sent: 15 July 2003 17:04
> > To: Ian Davidson
> > Cc: Fred Jordan; nagios-users at lists.sourceforge.net
> > Subject: RE: [Nagios-users] Jabber notification
> >
> >
> >
> >     Ian> But when I execute this script...
> >     Ian> [root at fangio ~/jabber-test]# perl test1.pl
> >     Ian> You requested that XML::Stream turn the socket into
> > an SSL socket, but
> >     Ian> you don't have the correct version of
> > IO::Socket::SSL v0.81. at
> >     Ian> /usr/lib/perl5/site_perl/5.6.1/Net/Jabber/Client.pm line 196
> >
> > Sounds like you need to use CPAN to update the version of the
> > IO::Socket::SSL package installed on your system.
> >
> >     Ian> [root at fangio ~/jabber-test]# rpm -qa | grep ssl
> >     Ian> openssl-0.9.6b-18
> >     Ian> docbook-style-dsssl-1.76-1
> >     Ian> mod_ssl-2.8.7-4
> >     Ian> openssl-devel-0.9.6b-18
> >
> > None of these relate directly to the Perl IO::Socket::SSL
> > module. IO:Socket::SSL is layered upon the libraries and
> > header files in the
> > openssl* rpms.
> >
> > To update/install that package, you can do one of two things.
> >
> > 1. Run CPAN:
> >
> >       perl -MCPAN -e shell
> >
> >    At the CPAN prompt, issue this command:
> >
> >       install IO::Socket::SSL
> >
> >    If you've never run CPAN before it will gather some
> > initial information
> >    about how you like doing things and what CPAN mirrors you
> > want to use
> >    before you get to the CPAN's shell prompt ("cpan> ").
> >
> >    CPAN usually works well, though it can be tricky at times.
> >  For instance,
> >    while writing this I tried the above install command.
> > IO::Socket::SSL
> >    depends on Net::SSLeay, which it dutifully tried to install.  That
> >    generated this warning:
> >
> >       *** /usr/bin/openssl appears to be compiled with gcc
> > ... while perl is
> >           compiled with cc. Both must be compiled with the
> > same compiler and
> >           flags. Mixing and matching compilers is not supported. at
> >           Makefile.PL line 137.
> >
> >    However, gcc and cc are the same thing on that computer:
> >
> >       # cc -v
> >       Reading specs from
> > /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
> >       gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.63.1mdk)
> >       # gcc -v
> >       Reading specs from
> > /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
> >       gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.63.1mdk)
> >
> >    Such is life.
> >
> > 2. Assuming there is an RPM on your distribution CD which contains the
> >    relevant Perl module, you can track it down and install
> > it.  My Mandrake
> >    8.1 system doesn't have it, but then I don't do anything with SSL
> >    either. ;-)
> >
> > --
> > Skip Montanaro
> > Got gigs? http://www.musi-cal.com/
> > Got spam? http://spambayes.sf.net/
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list