Jabber with Ruby 1

Posted by Colin A. Bartlett Thu, 20 Dec 2007 02:09:00 GMT

I got curious on how easy it might be to integrate Jabber with some Ruby projects. Turns out, it’s dead simple. (Why would I ever think otherwise?) That’s due to the efforts of the folks over at the xmpp4r project. One can do it with a simple little script of a dozen lines or so, once that package is installed. Something like this:

require 'xmpp4r/client'
include Jabber
client = Client::new(JID::new('username'))
client.connect
client.auth('password')
client.send Message::new(colinbartlett@gmail.com,"test!!").set_type(:normal).set_id('1')
client.close

On our project list coming up is integrating Jabber with our Nagios server so that notifications can be sent to us via IM when we’re online instead of SMS. (To avoid the $70 SMS bills in months when one of the servers has a bad day!).

Comments

Leave a response

  1. Avatar
    Mark about 23 hours later:
    That project sounds pretty useful, is that something that you will contribute back to the community?
Comments