def delete(self): aninfo('Delete Job SNMP : %s' % json.dumps(self.request.body)) result = yield self.pc.delete_job_snmp(self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def put(self): aninfo('Put config to AlertManager Receiver : %s' % json.dumps(self.request.body)) result = yield self.amc.update_alert_manage_receiver(self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def put(self): aninfo('Put config to Prometheus Global : %s' % json.dumps(self.request.body)) result = yield self.pc.update_global_config(self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def post(self, group_name, rule_name): aninfo('Post config to AlertRule Resource : %s - %s' % (group_name, json.dumps(self.request.body))) result = yield self.rc.post_rule_resource(group_name, rule_name, self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def put(self): log_config = copy.copy(self.request.body) if 'smtp_auth_password' in log_config: log_config['smtp_auth_password'] = '******' aninfo('Put config to AlertManager Global : %s' % json.dumps(log_config)) result = yield self.amc.update_alert_manage_global(self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def delete(self, name): if not name: self.write_message('Please input the group name.') raise Exception("group name is none.") aninfo('Delete AlertRule Group : %s' % name) result = yield self.rc.delete_rule_group(name) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def delete(self, group_name, rule_name): if not rule_name: self.write_message('Please input the rule_name.') raise Exception("rule_name is none.") aninfo('Delete AlertRule Resource : %s/%s' % (group_name, rule_name)) result = yield self.rc.delete_rule_resource(group_name, rule_name) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def put(self, group_name, rule_name): if not rule_name: self.write_message('Please input the rule_name.') raise Exception('rule_name is none.') aninfo('Put config to AlertRule Resource : %s - %s' % (group_name, json.dumps(self.request.body))) result = yield self.rc.put_rule_resource(group_name, rule_name, self.request.body) if result['error']: self.write_message(result['message']) else: self.write_message('success')
def post(self, name): """ {'name':'name'} """ if not name: self.write_message('Please input the group name.') raise Exception("group name is none.") aninfo('Post config to AlertRule Group : %s' % name) result = yield self.rc.add_rule_group(name) if result['error']: self.write_message(result['message']) else: self.write_message('success')
class Config_SNMP(BaseHandler): def initialize(self): self.sc = SNMPConfig() def get(self): args = self.request.query_arguments result = self.sc.get_snmp_config(args) if result['error']: self.write_message(result['message']) else: self.write_json(result['data']) #@check_fields(['module', 'oid', 'name', 'type', 'help']) # @check_fields(['module']) # @encode_fields() # def post(self): # body = self.request.body # config = self.get_config() # module = body['module'] # if module in config.keys(): # return self.write_message('This module has existed.') # include = [] # if 'include' in body: # include = body['include'] # for item in include: # if item not in Manufacturer: # return self.write_message('%s is undefined.' % item) # include.append('default') # module_config = {module:{'include':include, 'walk':[], 'metrics':[]}} # data = YAML(config)._insert(module_config) # if not data: # return self.write_message('Set config failed.') # return self.write_config(config) @check_fields(['module']) @encode_fields() @gen.coroutine def put(self): body = self.request.body try: module = body['module'] if type( body['module']) == str else Manufacturer[body['module']] except Exception, e: self.write_message('Unknow device type') raise Exception('Unknow device type.') aninfo('Put config snmp : %s' % json.dumps(self.request.body)) if 'community' in body: result = yield self.sc.update_community(body['community'], module) if result['error']: self.write_message(result['message']) raise Exception('update community failed.') self.write_message('success')
def post(self): aninfo('Post Job SNMP : %s' % json.dumps(self.request.body)) message = '' body = self.request.body result_job = yield self.pc.post_job_snmp(body) if result_job['error']: message += result_job['message'] if not message and 'community' in body: result_snmp = yield self.sc.update_community( body['community'], body['module']) if result_snmp['error']: message += result_snmp['message'] if message: self.write_message(message) else: self.write_message('success')