def searchMonitor(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if len(products) == 1: products.add('') products = tuple(products) mask = self.input.get('mask', '') limit = int(self.input.get('rows')) page = int(self.input.get('page')) if limit and page: start = limit * page - limit # do not put $limit*($page - 1) sql = "select COUNT(*) as count from monitor where PRODUCT in %s and (LOGPATH LIKE '%%%s%%' or NAME like '%%%s%%' or PRODUCT like '%%%s%%')" % ( str(products), mask, mask, mask) count = zmonlib.ExecSql(sql) count = count[0][0] total_pages = int((count + limit - 1) / limit) sql = "select MONITOR_ID,NAME,PRODUCT,LOGPATH,GREP,GREPV,REGULAR_ID_LIST from monitor where PRODUCT in %s and (LOGPATH LIKE '%%%s%%' or NAME like '%%%s%%' or PRODUCT like '%%%s%%') limit %d,%d" % ( str(products), mask, mask, mask, start, limit) rows = [] result = zmonlib.ExecSql(sql) for rec in result: row = [ rec[0], rec[1], rec[2], rec[3], rec[4], rec[5], self.getHostNum(rec[0]), len(eval(rec[6])) ] rows.append(row) #result = filter(self.filterByRe, rows) logging.debug(rows) return self.changejson(rows, page, total_pages, count)
def GET(self): logging.debug(self.input) userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0: web.config.session.kill() return render.forbidden(userName) if self.input == None or len(self.input) == 0: return render.manage(userName, products, web.ctx.homedomain) #更新树形菜单 if self.input['oper'] == 'updatelist': #检查文件夹是否存在,不存在则创建 dirPath = 'data/updateflag' product = self.input['product'] updateflag = '%s/%s' % (dirPath,product) if not os.path.exists(dirPath): os.makedirs(dirPath) #创建更新标志文件以触发updatelist.sh的更新任务 f = open(updateflag, 'w') f.close() while os.path.exists(updateflag): time.sleep(0.1) return json.dumps({'code':200,'txt':u'更新成功'}) elif self.input['oper'] == 'search': s = Search(self.input) return s.search()
def GET(self): logging.debug(self.input) userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0: web.config.session.kill() return render.forbidden(userName) if self.input == None or len(self.input) == 0: return render.manage(userName, products, web.ctx.homedomain) #更新树形菜单 if self.input['oper'] == 'updatelist': #检查文件夹是否存在,不存在则创建 dirPath = 'data/updateflag' product = self.input['product'] updateflag = '%s/%s' % (dirPath, product) if not os.path.exists(dirPath): os.makedirs(dirPath) #创建更新标志文件以触发updatelist.sh的更新任务 f = open(updateflag, 'w') f.close() while os.path.exists(updateflag): time.sleep(0.1) return json.dumps({'code': 200, 'txt': u'更新成功'}) elif self.input['oper'] == 'search': s = Search(self.input) return s.search()
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0: web.config.session.kill() return render.forbidden(userName) if self.input == None or len(self.input) == 0: return render.create(userName, products, web.ctx.homedomain)
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0: web.config.session.kill() return render.forbidden(userName) if self.input == None or len(self.input) == 0: return render.create(userName, products, web.ctx.homedomain)
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0: web.config.session.kill() return render.forbidden(userName) logging.debug('render flowstat.html for %s,products: %s' % (userName,products)) jg = JsGenerate(userName, products) jg.jsGenerate() return render.flowstat(userName, products, web.ctx.homedomain)
def GET(self): logging.debug(self.input) userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0: web.config.session.kill() return render.forbidden(userName) if self.input == None or self.input.get('oper') == None: return render.alarm(userName, products, web.ctx.homedomain) elif self.input['oper'] == 'search': return self.search()
def GET(self): logging.debug(self.input) userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0: web.config.session.kill() return render.forbidden(userName) if self.input == None or self.input.get('oper') == None: return render.alarm(userName, products, web.ctx.homedomain) elif self.input['oper'] == 'search': return self.search()
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0: web.config.session.kill() return render.forbidden(userName) logging.debug('render flowstat.html for %s,products: %s' % (userName, products)) jg = JsGenerate(userName, products) jg.jsGenerate() return render.flowstat(userName, products, web.ctx.homedomain)
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0: web.config.session.kill() return render.forbidden(userName) #raise web.forbidden() logging.debug('render index.html for %s,products: %s' % (userName,products)) logging.info("req_header:%s:%s" % (web.ctx.env.get('REMOTE_ADDR'), web.ctx.env.get('REMOTE_PORT'))) jg = JsGenerate(userName, products) jg.jsGenerate() return render.index(userName, products, web.ctx.homedomain)
def GET(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0: web.config.session.kill() return render.forbidden(userName) #raise web.forbidden() logging.debug('render index.html for %s,products: %s' % (userName, products)) logging.info( "req_header:%s:%s" % (web.ctx.env.get('REMOTE_ADDR'), web.ctx.env.get('REMOTE_PORT'))) jg = JsGenerate(userName, products) jg.jsGenerate() return render.index(userName, products, web.ctx.homedomain)
def GET(self): try: monitorId = self.input['monitorId'] except: return web.notfound(u'监控项不能为空') #加载监控项详情 conf = loadMonitor(monitorId) if conf == None: return web.notfound(u'加载配置错误') monitorId, product, monitorname, logpath, serviceName, grep, grepv, relist, treelist, hostlist = conf #检查是否有权限 userName = auth.uuap_sso() products = auth.getProcByName(userName) if products==None or len(products)==0 or not product in products: web.config.session.kill() return render.forbidden(userName) return render.modify(userName, monitorId, product, monitorname, logpath, serviceName, grep, grepv, relist, treelist, hostlist)
def GET(self): try: monitorId = self.input['monitorId'] except: return web.notfound(u'监控项不能为空') #加载监控项详情 conf = loadMonitor(monitorId) if conf == None: return web.notfound(u'加载配置错误') monitorId, product, monitorname, logpath, serviceName, grep, grepv, relist, treelist, hostlist = conf #检查是否有权限 userName = auth.uuap_sso() products = auth.getProcByName(userName) if products == None or len(products) == 0 or not product in products: web.config.session.kill() return render.forbidden(userName) return render.modify(userName, monitorId, product, monitorname, logpath, serviceName, grep, grepv, relist, treelist, hostlist)
def searchMonitor(self): userName = auth.uuap_sso() products = auth.getProcByName(userName) if len(products) == 1: products.add('') products = tuple(products) mask = self.input.get('mask','') limit = int(self.input.get('rows')) page = int(self.input.get('page')) if limit and page: start = limit * page - limit # do not put $limit*($page - 1) sql = "select COUNT(*) as count from monitor where PRODUCT in %s and (LOGPATH LIKE '%%%s%%' or NAME like '%%%s%%' or PRODUCT like '%%%s%%')" % (str(products), mask, mask, mask) count = zmonlib.ExecSql(sql) count = count[0][0] total_pages = int((count+limit-1)/limit) sql = "select MONITOR_ID,NAME,PRODUCT,LOGPATH,GREP,GREPV,REGULAR_ID_LIST from monitor where PRODUCT in %s and (LOGPATH LIKE '%%%s%%' or NAME like '%%%s%%' or PRODUCT like '%%%s%%') limit %d,%d" % (str(products), mask, mask, mask, start, limit) rows = [] result = zmonlib.ExecSql(sql) for rec in result: row = [rec[0], rec[1], rec[2], rec[3], rec[4], rec[5], self.getHostNum(rec[0]), len(eval(rec[6]))] rows.append(row) #result = filter(self.filterByRe, rows) logging.debug(rows) return self.changejson(rows, page, total_pages, count)