Esempio n. 1
0
    def testAlarms(self):
	#Jenifer sends out messages to all short codes (6767, 8500) via the various modems (mtn-modem, utl-modem) etc
	call_command('send_qos_messages')

	#Only a few modems reply with messages to Jenny
	for connection in Connection.objects.filter(backend__name__endswith='modem').exclude(
		identity__in=['256777773260', '256752145316', '256711957281', '256701205129'])[:5]:
	    self.fake_incoming(datetime.now().strftime('%Y-%m-%d %H'), connection)

	#Jennifer kicks in with the monitoring service
	call_command('monitor_qos_messages')
	alarms = get_alarms()

	#Jenny complains about her missing replies
	self.assertEquals(len(alarms), 8)

	#Poor Jenny spams everyone in protest
	msgs = []
	for msg in Message.objects.filter(direction='O').exclude(
		connection__identity__in=Message.objects.filter(direction='I').values_list('connection__identity')):
	    identity = msg.connection.identity
	    modem = msg.connection.backend
	    network = msg.connection.backend.name.split('-')[0]
	    msgs.append('Jennifer did not get a reply from %s using the %s, %s appears to be down!' % (
		identity, modem, network.upper()))
	self.assertEquals(msgs, get_alarms())
Esempio n. 2
0
    def testNoAlarms(self):
	#Jenifer sends out messages to all short codes (6767, 8500) via the various modems (mtn-modem, utl-modem) etc
	call_command('send_qos_messages')

	#Through the various apps, all short codes send back replies to Jennifer
	for connection in Connection.objects.filter(backend__name__endswith='modem'):
	    self.fake_incoming(datetime.now().strftime('%Y-%m-%d %H'), connection)

	#Jennifer kicks in with the monitoring service
	call_command('monitor_qos_messages')
	alarms = get_alarms()

	#no alarms expected since all apps replied
	self.assertEquals(len(alarms), 0)
Esempio n. 3
0
 def check_qos_messages(self):
     allow = getattr(settings, 'QOS_INCLUDE_MANAGERS_AS_RECIPIENTS', False)
     recipients = get_recipients(include_managers=allow)
     for msg in get_alarms(mode=getattr(settings, 'QOS_BACKEND_TYPE', 'shortcode')):
         send_mail("QOS Alarm", msg, "*****@*****.**", recipients, fail_silently=True)