def post(self): json_request = json_decode(self.request.body) monitor = Monitor(**json_request) monitor.save() self.success({"monitor": monitor.get_attributes()})
def post(self): application.info("creating monitor with attributes %s" % self.request.body) json_request = json_decode(self.request.body) monitor = Monitor(**json_request) monitor.save() self.success({"monitor": monitor.get_attributes()})
def test_list(self): label = 'test' monitor = Monitor(label=label) monitor.save() response = self.fetch('/api/monitors') self.assertEqual(response.code, 200) self.assertIn(label, response.body)
def test_dashboard(self): label = "server.test" monitor = Monitor(label=label, url='http://server.com') monitor.save() response = self.fetch('/') self.assertEqual(response.code, 200) self.assertIn(label, response.body) self.assertIn('TextMonitor', response.body)
def test_dashboard(self): label = "server.test" monitor = Monitor(label=label, url='http://server.com') monitor.save() response = self.fetch('/') self.assertEqual(response.code, 200) self.assertIn(label, response.body) self.assertIn('TextMonitor', response.body) self.assertIn('Default', response.body)
def test_check(self): label = 'test' monitor = Monitor(label=label, url=SERVICE_URL, monitor_type='TextMonitor', data={'expected': 'LIVE'}) monitor.save() response = self.fetch('/api/monitors/%s/check' % label) self.assertEqual(response.code, 200) self.assertIn('false', response.body)
def test_dashboard_with_group(self): label = "server.test" monitor = Monitor(label=label, url='http://server.com', group='test') monitor.save() response = self.fetch('/') self.assertEqual(response.code, 200) self.assertIn(label, response.body) self.assertIn('TextMonitor', response.body) self.assertIn('test', response.body) self.assertNotIn('Default', response.body)
def get(self): monitors = [] for monitor in Monitor().all(): monitors.append(monitor.get_attributes()) self.success({'monitors': monitors})
def get(self): monitor_types = [('Select...', '')] for monitor in list_monitors: item = (list_monitors[monitor]['description'], monitor) monitor_types.append(item) monitors = {} for monitor in Monitor().ordered_by_position(): if hasattr(monitor, "group"): group = monitor.group else: group = "" if group not in monitors: monitors[group] = [] monitors[group].append(monitor) groups = set([monitor for monitor in monitors]) self.render("dashboard.slim.html", monitor_types=monitor_types, groups_monitors=monitors, groups=groups, polling_interval=WEB_POLLING_INTERVAL, version=VERSION)
def test_create(self): body = json_encode({ 'type': 'TextMonitor', 'label': 'server', 'url': SERVICE_URL, 'data': {'expected': 'LIVE'} }) response = self.fetch('/api/monitors', method='POST', body=body) self.assertEqual(response.code, 200) self.assertEqual(len(Monitor().all()), 1)
def post(self): json_request = json_decode(self.request.body) for index, label in enumerate(json_request['monitors']): monitor = Monitor() monitor.load(label) monitor.position = index monitor.save() self.success(json_request)
def delete(self, label): monitor = Monitor() monitor.load(label) application.info("removing monitor %s" % label) self.success({"monitor": monitor.get_attributes(), "destroy": monitor.destroy()})
def test_positions_save(self): monitor_position1 = Monitor(label='position1', url=SERVICE_URL, monitor_type='TextMonitor', data={'expected': 'LIVE'}) monitor_position1.save() monitor_position0 = Monitor(label='position0', url=SERVICE_URL, monitor_type='TextMonitor', data={'expected': 'LIVE'}) monitor_position0.save() body = json_encode({ 'monitors': ['position0', 'position1'] }) self.fetch('/api/monitors/positions', method='POST', body=body) monitor = Monitor() monitor.load('position1') self.assertEqual(monitor.get_position(), 1) monitor = Monitor() monitor.load('position0') self.assertEqual(monitor.get_position(), 0)
def get(self, label): monitor = Monitor() monitor.load(label) alive = check_alive(monitor.monitor_type, monitor.url, **monitor.data) self.success({"monitor": monitor.get_attributes(), "alive": alive})
def delete(self, label): monitor = Monitor() monitor.load(label) self.success({"monitor": monitor.get_attributes(), "destroy": monitor.destroy()})