def GET(self): try: id = web.input().id except: id = 1 moni_nodes = bridge_moni.node(id=id) ######################################################### node = bridge_node.node_list(id=id)[0] img_urls = [] node_dir = os.path.join(ua_conf.rrd_imgs_dir, str(node['rack']), str(node['id'])) try: mkdirs(node_dir) except: raise load_img_path = os.path.join(node_dir, 'load.png') mem_img_path = os.path.join(node_dir, 'mem.png') swap_img_path = os.path.join(node_dir, 'swap.png') nw_img_path = os.path.join(node_dir, 'nw.png') iops_img_path = os.path.join(node_dir, 'iops.png') img_urls.append(load_img_path) img_urls.append(mem_img_path) img_urls.append(swap_img_path) img_urls.append(nw_img_path) img_urls.append(iops_img_path) ############################################################# return render.node_dtls(node=moni_nodes[0], img_urls=img_urls)
def graph_nodes(rrds_dir, imgs_dir, node=None): """ :param node: dict of the node, like: {'id':1, 'rack':1} """ if node: nodes = [node] else: try: nodes = bridge_node.node_list() except: raise for n in nodes: node_dir = os.path.join(rrds_dir, str(n['rack']), str(n['id'])) try: mkdirs(node_dir) except: raise load_rrd_path = os.path.join(node_dir, 'load.rrd') mem_rrd_path = os.path.join(node_dir, 'mem.rrd') swap_rrd_path = os.path.join(node_dir, 'swap.rrd') nw_rrd_path = os.path.join(node_dir, 'nw.rrd') iops_rrd_path = os.path.join(node_dir, 'iops.rrd') disk_rrd_path = os.path.join(node_dir, 'disk.rrd') imgs_node_dir = os.path.join(imgs_dir, str(n['rack']), str(n['id'])) try: mkdirs(imgs_node_dir) except: raise load_img_path = os.path.join(imgs_node_dir, 'load.png') mem_img_path = os.path.join(imgs_node_dir, 'mem.png') swap_img_path = os.path.join(imgs_node_dir, 'swap.png') nw_img_path = os.path.join(imgs_node_dir, 'nw.png') iops_img_path = os.path.join(imgs_node_dir, 'iops.png') disk_img_path = os.path.join(imgs_node_dir, 'disk.png') try: if os.path.exists(load_rrd_path): load.graph(load_rrd_path, load_img_path) if os.path.exists(mem_rrd_path): mem.graph(mem_rrd_path, mem_img_path) if os.path.exists(swap_rrd_path): swap.graph(swap_rrd_path, swap_img_path) if os.path.exists(nw_rrd_path): nw.graph(nw_rrd_path, nw_img_path) if os.path.exists(iops_rrd_path): iops.graph(iops_rrd_path, iops_img_path) if os.path.exists(disk_rrd_path): disk.graph(disk_rrd_path, disk_img_path) except: raise
def GET(self): input = web.input() mytype='proxy' services = bridge_srvc.srvc_list(type=mytype) proxy_list = services[mytype] count = 0 if proxy_list: count = len(proxy_list) limit = int(input.rows) #每页显示行。 sord = input.sord #排序关键字 sidx = input.sidx #升序还是降序 page = input.page #申请的第几页 total_pages = count/limit if count%limit != 0: total_pages += 1 start = (int(page) - 1) * limit end = int(page) * limit print start, end if end > count: end = count rows = [] if proxy_list: for proxy in proxy_list: id = proxy['n'] ip = proxy['ip'] nodes = bridge_node.node_list(ip=ip) node = nodes[0] server = node['hostname'] rows.append({'id':id, 'cell':[id, ip, server, '']}) results = { 'total' : str(total_pages), 'page' : str(page), 'records' : str(count), 'rows' : rows } web.header("Content-Type", "application/json") return json.dumps(results)
def GET(self): input = web.input() mytype = 'proxy' services = bridge_srvc.srvc_list(type=mytype) proxy_list = services[mytype] count = 0 if proxy_list: count = len(proxy_list) limit = int(input.rows) #每页显示行。 sord = input.sord #排序关键字 sidx = input.sidx #升序还是降序 page = input.page #申请的第几页 total_pages = count / limit if count % limit != 0: total_pages += 1 start = (int(page) - 1) * limit end = int(page) * limit print start, end if end > count: end = count rows = [] if proxy_list: for proxy in proxy_list: id = proxy['n'] ip = proxy['ip'] nodes = bridge_node.node_list(ip=ip) node = nodes[0] server = node['hostname'] rows.append({'id': id, 'cell': [id, ip, server, '']}) results = { 'total': str(total_pages), 'page': str(page), 'records': str(count), 'rows': rows } web.header("Content-Type", "application/json") return json.dumps(results)
def POST(self): input = web.input() try: nodes = bridge_node.node_list() except: print "-------------- %s , get message error," % (edog_host) raise web.internalerror(message="%s, get message error," % (edog_host)) # print nodes if not nodes: return render.node_rrd(tip='No node in uss!', img_urls=[]) img_urls = [] for n in nodes: node_dir = os.path.join(ua_conf.rrd_imgs_dir, str(n['rack']), str(n['id'])) try: mkdirs(node_dir) except: raise load_img_path = os.path.join(node_dir, 'load.png') mem_img_path = os.path.join(node_dir, 'mem.png') swap_img_path = os.path.join(node_dir, 'swap.png') nw_img_path = os.path.join(node_dir, 'nw.png') iops_img_path = os.path.join(node_dir, 'iops.png') disk_img_path = os.path.join(node_dir, 'disk.png') if input.attr == 'load': img_urls.append([n['ip'], load_img_path]) elif input.attr == 'mem': img_urls.append([n['ip'], mem_img_path]) elif input.attr == 'swap': img_urls.append([n['ip'], swap_img_path]) elif input.attr == 'nw': img_urls.append([n['ip'], nw_img_path]) elif input.attr == 'iops': img_urls.append([n['ip'], iops_img_path]) elif input.attr == 'disk': img_urls.append([n['ip'], disk_img_path]) else: img_urls.append([n['ip'], load_img_path]) return render.node_rrd(tip='', img_urls=img_urls)
def POST(self): input = web.input() try: nodes = bridge_node.node_list() except: print "-------------- %s , get message error,"%(edog_host) raise web.internalerror(message = "%s, get message error,"%(edog_host)) # print nodes if not nodes: return render.node_rrd(tip='No node in uss!', img_urls=[]) img_urls = [] for n in nodes: node_dir = os.path.join(ua_conf.rrd_imgs_dir, str(n['rack']), str(n['id'])) try: mkdirs(node_dir) except: raise load_img_path = os.path.join(node_dir, 'load.png') mem_img_path = os.path.join(node_dir, 'mem.png') swap_img_path = os.path.join(node_dir, 'swap.png') nw_img_path = os.path.join(node_dir, 'nw.png') iops_img_path = os.path.join(node_dir, 'iops.png') disk_img_path = os.path.join(node_dir, 'disk.png') if input.attr == 'load': img_urls.append([n['ip'],load_img_path]) elif input.attr == 'mem': img_urls.append([n['ip'],mem_img_path]) elif input.attr == 'swap': img_urls.append([n['ip'],swap_img_path]) elif input.attr == 'nw': img_urls.append([n['ip'],nw_img_path]) elif input.attr == 'iops': img_urls.append([n['ip'],iops_img_path]) elif input.attr == 'disk': img_urls.append([n['ip'],disk_img_path]) else: img_urls.append([n['ip'],load_img_path]) return render.node_rrd(tip='', img_urls=img_urls)