This section describes how Jabber can easily be extended for Linux system monitoring. Information in this section is not particular to Jabberd 2; however, I have included it in the guide because I have created some system administration tools that use Jabber, and I hope that others may find these scripts useful. Additionally, my scripts may possibly inspire readers to extend Jabber in new ways.
Jabber is ideally suited for system administration alerts because Jabber provides real time notification. Jabber alerts are less likely to be ignored than email alerts, they can be received anywhere the user is logged in, and Jabber alerts are free, unlike pagers.
Each subsection of this appendix describes a way that Jabber can be used for Linux system administration monitoring and alerting:
All of the above tasks rely on scripts available on this site. Impatient readers may wish to peruse scripts in the tools folder before continuing.
The jabber_alert.pl script is a Perl script that sends a pre-formatted alert message via Jabber. It accepts a variety of arguments that are parsed as alert headers for a Jabber message; however, in its simplest usage it can be used to send a Jabber message from the command line:
./jabber_alert.pl -e user1@somedomain.com -n user2@somedomain.com -w user2passwd
Where -e [recipient JID] -n [sender JID] -w [sender password] [message body from STDIN]
The message body comes from standard input, and can contain as many lines as you wish. When you are ready to send the message, press CTRL-d. The -h option displays help information.
The jabber_alert.pl script can be downloaded from the tools folder. Once downloaded, you will need to chmod it (chmod a+x jabber_alert.pl) so that you can run it. jabber_alert.pl relies on these three Perl packages:
Net::Jabber
Time::Local
Getopt::Std
Your Perl installation probably has Time::Local and Getopt::Std installed, and the script will halt if you do not. You can download the Net::Jabber install file from the CPAN.org web site. To install it, first untar it and then build it:
perl Makefile.PL
make
make install
CPAN.pm automates the download, make and install of Perl modules and extensions. To setup CPAN.pm, enter the command perl -MCPAN -e shell (as super user). This starts an interactive script that will set up your machine to fetch and install Perl modules from the command line. Once setup, you would enter the command install Net::Jabber (from the cpan shell) to install Net::Jabber. One of the benefits of using CPAN.pm is that it will also fetch dependencies. Once Net::Jabber is installed, you can use jabber_alert.pl to send Jabber messages from the command line; however, its real purpose here is to work as a Jabber alert message sender for various bash shell scripts. That is, once jabber_alert.pl is installed, it is easy to send a Jabber alert message from a shell script. All of the individual shell scripts in this section rely on jabber_alert.pl.
Once jabber_alert.pl is installed, you can check out the system administration scripts I have written that use it, starting with the next section.
ecasbas, 2004/08/04 03:45 PST
What about if the server only accept ssl connections to port 5223?
Would this procedure be still valid?
Re: SSL Connections on Port 5223 --Will, 2004/08/04 08:01 PST
The jabber_alert.pl script should work for SSL connections on port 5223. It accepts an optional -k argument, which if set to 1, enables SSL, and a -p argument that specifies the port. Run ./jabber_alert.pl -h for a full list of arguments.
All of the subsequent scripts can make use of this feature.
SSL connection --2004/08/10 23:22 PST
This is what I get when using -k 1 and -o 5223
You requested that XML::Stream turn the socket into an SSL socket, but you don't have the correct version of IO::Socket::SSL v0.81. at /usr/lib/perl5/site_perl/5.8.4/Net/Jabber/Client.pm line 251
Any hints?
Re: SSL connection --Will, 2004/08/12 10:09 PST
I would try upgrading your IO::Socket package using the mcpan shell.
© 2003 Will Kamishlian and Robert Norris
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
|
|
|
![]() |