|
@@ -61,6 +61,7 @@ class AlertMsgBot(sleekxmpp.ClientXMPP):
|
|
|
logging.info('Connect to redis on server->%s:%s db->%s qname->%s:%s' % (host, port, db, qprefix, qname))
|
|
logging.info('Connect to redis on server->%s:%s db->%s qname->%s:%s' % (host, port, db, qprefix, qname))
|
|
|
jid = config.get("alert_bot", "msg_bot.jid").strip('"').strip("'")
|
|
jid = config.get("alert_bot", "msg_bot.jid").strip('"').strip("'")
|
|
|
password = config.get("alert_bot", "msg_bot.pass").strip('"').strip("'")
|
|
password = config.get("alert_bot", "msg_bot.pass").strip('"').strip("'")
|
|
|
|
|
+
|
|
|
sleekxmpp.ClientXMPP.__init__(self, jid, password)
|
|
sleekxmpp.ClientXMPP.__init__(self, jid, password)
|
|
|
|
|
|
|
|
self.recipients = eval(config.get("alert_bot", "msg_bot.recipients").strip('"').strip("'"))
|
|
self.recipients = eval(config.get("alert_bot", "msg_bot.recipients").strip('"').strip("'"))
|
|
@@ -100,12 +101,12 @@ class AlertMsgBot(sleekxmpp.ClientXMPP):
|
|
|
def process_alerts(self):
|
|
def process_alerts(self):
|
|
|
self.quit = False
|
|
self.quit = False
|
|
|
while self.quit <> True:
|
|
while self.quit <> True:
|
|
|
-
|
|
|
|
|
if not self.rsq.empty():
|
|
if not self.rsq.empty():
|
|
|
msg = self.rsq.get()
|
|
msg = self.rsq.get()
|
|
|
logging.debug('process_alerts: received msg: {%s}' % msg)
|
|
logging.debug('process_alerts: received msg: {%s}' % msg)
|
|
|
self.send_msg(msg)
|
|
self.send_msg(msg)
|
|
|
sleep(1)
|
|
sleep(1)
|
|
|
|
|
+
|
|
|
# Using wait=True ensures that the send queue will be
|
|
# Using wait=True ensures that the send queue will be
|
|
|
# emptied before ending the session.
|
|
# emptied before ending the session.
|
|
|
self.disconnect(wait=True)
|
|
self.disconnect(wait=True)
|
|
@@ -119,6 +120,7 @@ class AlertMsgBot(sleekxmpp.ClientXMPP):
|
|
|
finally:
|
|
finally:
|
|
|
self.tlock.release()
|
|
self.tlock.release()
|
|
|
|
|
|
|
|
|
|
+
|
|
|
#
|
|
#
|
|
|
# alert helper doesn't care whether the xmpp server
|
|
# alert helper doesn't care whether the xmpp server
|
|
|
# has started or not, all it cares is being able to put the message
|
|
# has started or not, all it cares is being able to put the message
|