From: hornsby <adr...@tu...> - 2009-12-03 09:36:58
|
hi, They are several functions in Class Roster that shoiuld help you do the trick: getRoster(self) and getStatus(self,jid). check the link: http://xmpppy.sourceforge.net/apidocs/xmpp.roster.Roster-class.html cheers, adrian On Tue, 2009-12-01 at 11:02 -0500, Frank Laszlo wrote: > Hello, > > I'm currently working on a script for server monitoring, specifically > the notification module for it. Since we use Jabber in house, I'd like > to be able to send alerts this way. > > Actually sending the alerts was not difficult, however, I cannot find a > solution to be able to verify that the person its being sent to is > "Available." Currently, it will send it regardless of their status, but > if they are offline, they get flooded with messages as soon as they sign > on. > > I've pasted the applicable code below, if anyone could give me some > guidance I'd greatly appreciate it. As a bit of background, jabber() is > called with all strings as arguments. > > def jabber(name, jabberid, servername, load, eximcount, type): > jid = xmpp.protocol.JID(config.jabberID) > cl = xmpp.Client(jid.getDomain(), debug=[]) > con = cl.connect() > if not con: > print "Could not connect to jabber\n" > auth = cl.auth(jid.getNode(), config.jabberPass, > resource=jid.getResource()) > if not auth: > print "Could not authenticate to jabber\n" > if type == 'exim': > msg = "[ALERT]: Too many messages in queue on %s > - Current count: %s" % (servername, eximcount) > elif type == 'load': > msg = "[ALERT]: Processor load high on %s - > Current load: %s" % (servername, load) > elif type == 'down': > msg = "[ALERT]: Server %s is unreachable. - Last > recorded load: %s" % (servername, load) > else: > print "Invalid alert type: '%s'" % (type) > id = cl.send(xmpp.protocol.Message(jabberid, msg)) > time.sleep(1) > print "Jabber alert message sent to %s" % (jabberid) > > > > -Frank > > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > Xmpppy-devel mailing list > Xmp...@li... > https://lists.sourceforge.net/lists/listinfo/xmpppy-devel |