Exemple #1
0
	def post(self):
		form_data = {
				"metric" : self.get_argument('metric', None),         
				"metric_value" : self.get_argument('metric_value', None),         
				"above_below" : self.get_argument('above_below', None),         
				"metric_type": self.get_argument('metric_type', None),
				"metric_options": self.get_argument('metric_options',None),
				"threshold": self.get_argument('threshold', None),
				"email_recepients": self.get_arguments('email', None),
				"sms_recepients": self.get_arguments('sms', None),
				"rule_type": 'server'
		}
		
		try:
			AddServerRuleForm.to_python(form_data)

			self.delete_session_key('errors')
			self.delete_session_key('form_data')
		
			alerts_model.save(form_data)
			self.redirect(self.reverse_url('alerts'))
		
		except InvalidForm, e:
			print e.unpack_errors()
			self.session['errors'] = e.unpack_errors()
			self.session['form_data'] = form_data
			self.redirect(self.reverse_url('add_server_alert'))
Exemple #2
0
	def post(self):
		form_data = {
				"process" : self.get_argument('process', None),  
				"above_below" : self.get_argument('above_below', None),  
				"check" : self.get_argument('check', None),        
				"metric_value" : self.get_argument('metric_value', None),         
				"metric_type" : self.get_argument('metric_type', None),                         
				"threshold": self.get_argument('threshold', None),
				"email_recepients": self.get_arguments('email', None),
				"sms_recepients": self.get_arguments('sms', None),
				"rule_type": 'process'
		}

		try:
			AddProcessRuleForm.to_python(form_data)

			self.delete_session_key('errors')
			self.delete_session_key('form_data')
		
			alerts_model.save(form_data)
			self.redirect(self.reverse_url('alerts'))
		
		except InvalidForm, e:
			self.session['errors'] = e.unpack_errors()
			self.session['form_data'] = form_data
			self.redirect('/alerts/process')
Exemple #3
0
    def post(self):
        form_data = {
            "metric": self.get_argument('metric', None),
            "metric_value": self.get_argument('metric_value', None),
            "above_below": self.get_argument('above_below', None),
            "metric_type": self.get_argument('metric_type', None),
            "metric_options": self.get_argument('metric_options', None),
            "threshold": self.get_argument('threshold', None),
            "email_recepients": self.get_arguments('email', None),
            "sms_recepients": self.get_arguments('sms', None),
            "rule_type": 'server'
        }

        try:
            AddServerRuleForm.to_python(form_data)

            self.delete_session_key('errors')
            self.delete_session_key('form_data')

            alerts_model.save(form_data)
            self.redirect(self.reverse_url('alerts'))

        except InvalidForm, e:
            print e.unpack_errors()
            self.session['errors'] = e.unpack_errors()
            self.session['form_data'] = form_data
            self.redirect(self.reverse_url('add_server_alert'))
Exemple #4
0
    def post(self):
        form_data = {
            "process": self.get_argument('process', None),
            "above_below": self.get_argument('above_below', None),
            "check": self.get_argument('check', None),
            "metric_value": self.get_argument('metric_value', None),
            "metric_type": self.get_argument('metric_type', None),
            "threshold": self.get_argument('threshold', None),
            "email_recepients": self.get_arguments('email', None),
            "sms_recepients": self.get_arguments('sms', None),
            "rule_type": 'process'
        }

        try:
            AddProcessRuleForm.to_python(form_data)

            self.delete_session_key('errors')
            self.delete_session_key('form_data')

            alerts_model.save(form_data)
            self.redirect(self.reverse_url('alerts'))

        except InvalidForm, e:
            self.session['errors'] = e.unpack_errors()
            self.session['form_data'] = form_data
            self.redirect('/alerts/process')
Exemple #5
0
	def test_check(self):
		alerts_model.collection.remove()
		server_model.collection.remove()
		server_model.collection.insert({"server_name" : "test", "key": "test_me"})
		server = server_model.collection.find_one()
		server_id = str(server['_id'])

		rule['server'] = server_id
		alerts_model.save(rule)

		check = self.alerter.check(data=test_system_data, server=server, alert_type='server')
		eq_(check['memory'][0]['rule'], str(rule['_id']))
Exemple #6
0
    def test_check(self):
        alerts_model.collection.remove()
        server_model.collection.remove()
        server_model.collection.insert({
            "server_name": "test",
            "key": "test_me"
        })
        server = server_model.collection.find_one()
        server_id = str(server['_id'])

        rule['server'] = server_id
        alerts_model.save(rule)

        check = self.alerter.check(data=test_system_data,
                                   server=server,
                                   alert_type='server')
        eq_(check['memory'][0]['rule'], str(rule['_id']))