/bash, jabber, Linux, xmpppy

Install xmpppy on CentOS

xmpppy is a Python library allowing you to send messages from your server to any Jabber enabled communicator.
Firstly download and unpack xmpppy to a local directory. Next go into the unpacked directory and run:

python setup.py install

Next you need a script that will do the sending. Use your favourite text editor to create file i.e.:

vim xsend.py

Just paste below script which was taken from original site. Create another jabber account that you’ll send messages from and remember to change values in line 20 to those new login details.

# $Id: xsend.py,v 1.8 2006/10/06 12:30:42 normanr Exp $ 
import sys,os,xmpp,time
if len(sys.argv) < 2:
    print "Syntax: xsend JID text"

text=' '.join(sys.argv[2:])

if os.access(os.environ['HOME']+'/.xsend',os.R_OK):
    for ln in open(os.environ['HOME']+'/.xsend').readlines():
        if not ln[0] in ('#',';'):
for mandatory in ['jid','password']:
    if mandatory not in jidparams.keys():
        open(os.environ['HOME']+'/.xsend','w').write('#Uncomment fields before use and type in correct credentials.\n#[email protected]/resource (/resource is optional)\n#PASSWORD=juliet\n')
        print 'Please point ~/.xsend config file to valid JID for sending messages.'


if not con:
    print 'could not connect!'
print 'connected with',con
if not auth:
    print 'could not authenticate!'
print 'authenticated using',auth

#cl.SendInitPresence(requestRoster=0)   # you may need to uncomment this for old server
print 'sent message with id',id

time.sleep(1)   # some older servers will not send the message if you disconnect immediately after sending


All you need to do now is to run the script 🙂 First run will create a file in your home directory which should contain username and password from line 20. Second run should accually send the message.

./xsend.py your_main_jabber@your_jabber.com Hello world!

Now set up your monitoring scripts that will send you jabber messages when something goes wrong.