Exemplo n.º 1
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		self.alert1 = create_alert(host='test host', service='Host status')
		self.alert1.save()
		self.alert2 = create_alert(host='test host', service='Host status', isDown=False)
		self.alert2.save()
		self.events = list()
Exemplo n.º 2
0
	def setUp(self):
		management.call_command('loaddata', 'test_supervisor.json', database='default', verbosity=0)
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)

		self.event1 = create_event(create_alert(host='test host'), message='Aggregation Event#1', criticity='Mineur', glpi=10, mail=True)
		self.event1.save()
		
		self.event2 = create_event(create_alert(host='test host2'), message='Aggregation Event#2', criticity='?')
		self.event2.save()
Exemplo n.º 3
0
    def setUp(self):
        management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
        # Create a first alert with event
        self.alert1 = create_alert(service='test service')
        self.alert1.save()
        self.event1 = self.alert1.link()
        # Create a first alert with event
        self.alert2 = create_alert(service='test service 2')
        self.alert2.save()
        self.event2 = self.alert2.link()
        # Create user and log it
	self.user = User.objects.create_user(username='******',password='******')
        self.client = Client()
        self.client.login(username='******',password='******')
Exemplo n.º 4
0
 def setUp(self):
     management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
     self.alert = create_alert(service='test service')
     self.black_reference = Black_reference.objects.create(
       host=self.alert.host,
       service=self.alert.service
     )
Exemplo n.º 5
0
    def test_RRDTool(self):
        """
        Test to get a list of graph from nagios.demo.netways.de
        for host 'c1-activedirectory' and service 'win-mem+virtual'.
        """
        # Trouver les host supervise sur http://nagios.demo.netways.de/nagios/cgi-bin/status.cgi
        management.call_command('loaddata', 'test_rrdtool_host.json', database='default', verbosity=0)
        GRAPH_LIST_URL = 'https://nagios.demo.netways.de/pnp4nagios/graph?host=c1-activedirectory-1&srv=win-mem+virtual&view=0'
        GRAPH_URL = 'https://nagios.demo.netways.de/pnp4nagios/image?host=c1-activedirectory-1&srv=win-mem+virtual&view=0'
        S = Supervisor.objects.get(name__icontains='Netways')
        opener = S.getOpener()
        A = create_alert(host='c1-activedirectory-1', service='win-mem virtual')
       
        # Find graphs
        ## Test to get a graph list URL
        graph_list_url = S.get_graph_url(alert=A, prefix='graph')
        self.assertEqual(GRAPH_LIST_URL, graph_list_url)

        ## Test to open this URL
        response = opener.open(graph_list_url)
        info = response.info()
        self.assertEqual(200,response.getcode())
        self.assertIn('text/html', info['content-type'])

        # Get graph
        ## Test to get a graph URL
        graph_url = S.get_graph_url(alert=A)
        self.assertEqual(GRAPH_URL, graph_url)

        ## Test to open this URL
        response = opener.open(graph_url)
        info = response.info()
        self.assertEqual(200,response.getcode())
        self.assertIn('image/png', info['content-type'])
Exemplo n.º 6
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		self.service1 = Service.objects.create(name='test service1')
		self.service2 = Service.objects.create(name='test service2')
		self.events = list()

		self.alert1 = create_alert(host='test host',service='test service1')
		self.alert1.save()
		self.alert2 = create_alert_from(self.alert1)
		self.alert2.save()
		self.alert3 = create_alert_from(self.alert2, isDown=False)
		self.alert3.save()

		self.alert4 = create_alert(host='test host',service='test service2')
		self.alert4.save()
		self.alert5 = create_alert_from(self.alert1)
		self.alert5.save()
		self.alert6 = create_alert_from(self.alert2, isDown=False)
		self.alert6.save()
Exemplo n.º 7
0
 def test_N2RDD(self):
     """                                                                                          
     Test to get a list of graph from sysnetmon.diglinks.com
     for host 'core.diglinks.com' and service '02_load'.
     """
     # Trouver les host supervise sur http://nagios.demo.netways.de/nagios/cgi-bin/status.cgi     
     management.call_command('loaddata', 'test_n2rrd_host.json', database='default', verbosity=0)
     GRAPH_LIST_URL = 'http://sysnetmon.diglinks.com/cgi-bin/rrd2graph.cgi?hostname=core.diglinks.com&service=02_load'
     GRAPH_URL = 'http://sysnetmon.diglinks.com/cgi-bin/n2rrd_images_cache/core.diglinks.com/core.diglinks.com_load_Daily.png'
     S = Supervisor.objects.get(name__icontains='SysNetmon')                                      
     opener = S.getOpener()
     A = create_alert(host='core.diglinks.com', service='02_load')                                                          
     
     # Find graphs
     graph_list_url = S.get_graph_url(alert=A, prefix='graph')                                    
     self.assertEqual(GRAPH_LIST_URL, graph_list_url)                                             
     handle = opener.open(graph_list_url)                                                         
Exemplo n.º 8
0
	def test_ticket_management(self):
		from os.path import join
		from base64 import b64encode

		E = create_event(create_alert())
		E.create_ticket()

		# Try to add a picture to a document
		b64doc = b64encode(open(join(settings.BASEDIR, '../sendim/tests/python.png'), 'r').read())
		doc = b64doc
		self.manager.add_ticket_document(E.glpi, doc, 'python.png')

		# Try to add a follow-up
		self.manager.add_follow_up(E.glpi, 'Test follow-up')

		# Try to get the ticket and find added info
		ticket = self.manager.get_ticket(E.glpi)
		self.assertEqual(ticket['documents'][0]['filename'], 'python.png')
		self.assertEqual(ticket['followups'][0]['content'], 'Test follow-up')
Exemplo n.º 9
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		management.call_command('loaddata', 'test_translation.json', database='default', verbosity=0)
		self.alert = create_alert(host='test host',service='test service',status='WARNING')
Exemplo n.º 10
0
	def test_treatment_without_reference(self):
		self.client.post('/snafu/event/reloadAlerts')
	   
		if not Event.objects.all().exists() :
			create_event(create_alert(),3)

		E = Event.objects.all()[0]
		A = E.get_primary_alert()
		self.assertNotEqual(E.message, '?')

		response = self.client.post('/snafu/events',{'eventPk':E.pk,'treatment_q':''})
		self.assertNotIn('event/add-reference.html', response.templates)
		
		ref_post = {
		  'eventPk':E.pk,
		  'host':E.element.pk,
		  'service':A.service.pk,
		  'mail_group':1,
		  'mail_type':1,
		  'glpi_category':1,
		  'glpi_dst_group':1,
		  'glpi_supplier':1,
		  'glpi_source':'Supervision',
		  'escalation_contact':'',
		  'tendancy':'',
		  'outage':'',
		  'explanation':'',
		  'origin':'',
		  'procedure':'',
		}
		if A.service.name == 'Host status' :
			ref_post['form_type'] = 'host'
			ref_post['status'] = A.status.pk
			ref_post['mail_criticity'] = 1
			ref_post['glpi_impact'] = 1
			ref_post['glpi_priority'] = 1
			ref_post['glpi_urgency'] = 1
		else :
			ref_post['form_type'] = 'big'
			ref_post['warning_criticity'] = 1
			ref_post['warning_impact'] = 1
			ref_post['warning_priority'] = 1
			ref_post['warning_urgency'] = 1
			ref_post['critical_criticity'] = 1
			ref_post['critical_impact'] = 1
			ref_post['critical_priority'] = 1
			ref_post['critical_urgency'] = 1
			ref_post['unknown_criticity'] = 1
			ref_post['unknown_impact'] = 1
			ref_post['unknown_priority'] = 1
			ref_post['unknown_urgency'] = 1
		
		self.client.post('/snafu/event/addref',ref_post)
		self.assertIsNotNone(Alert.objects.get(pk=A.pk).reference)

		response = self.client.post('/snafu/events',{'eventPk':E.pk,'treatment_q':''})
		self.assertIsNotNone(Event.objects.get(pk=E.pk))
		self.assertIn('event/preview-mail.html', [ T.name for T in response.templates])

		mail_post = {
		  'eventPk':E.pk,
		  'sendmail_q':'',
		  'to':response.context['msg']['to'],
		  'cc':response.context['msg']['cc'],
		  'ccm':response.context['msg'].get('ccm',''),
		  'subject':response.context['msg']['subject'],
		  'body':response.context['msg']['body'],
		  'graphList':response.context['graphList'],
		}
		response = self.client.post('/snafu/events', mail_post)
		self.assertTrue(Event.objects.get(pk=E.pk).mail)
		self.assertIn('event/event-index.html', [ T.name for T in response.templates])
Exemplo n.º 11
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		self.alert = create_alert(host='test host',service='test service',status=Status.objects.get(pk=1))
		self.events = list()
Exemplo n.º 12
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		self.alert = create_alert(host='test host', service='test service')
		self.alert.save()
		self.events = list()
Exemplo n.º 13
0
	def setUp(self):
		management.call_command('loaddata', 'test_host.json', database='default', verbosity=0)
		self.s_alert = create_alert(host='test host', service='test service', status='WARNING') 
		self.s_alert.save()
		self.h_alert = create_alert_from(self.s_alert, service='Host status', status='DOWN')
		self.h_alert.save()