def vnodes_monitor(user, beans, form, con_id, issue): global G_clustername global G_historymgr logger.info("handle request: monitor/vnodes") res = {} fetcher = monitor.Container_Fetcher(con_id) if issue == 'info': res = fetcher.get_info() elif issue == 'cpu_use': res['cpu_use'] = fetcher.get_cpu_use() elif issue == 'mem_use': res['mem_use'] = fetcher.get_mem_use() elif issue == 'disk_use': res['disk_use'] = fetcher.get_disk_use() elif issue == 'basic_info': res['basic_info'] = fetcher.get_basic_info() elif issue == 'net_stats': res['net_stats'] = fetcher.get_net_stats() elif issue == 'history': res['history'] = G_historymgr.getHistory(con_id) elif issue == 'owner': names = con_id.split('-') result = post_to_user("/user/query/", data={"token": form.get(token)}) if result['success'] == 'false': res['username'] = "" res['truename'] = "" else: res['username'] = result['data']['username'] res['truename'] = result['data']['truename'] else: res = "Unspported Method!" return json.dumps({'success': 'true', 'monitor': res})
def hosts_monitor(user, beans, form, com_id, issue): global G_clustername logger.info("handle request: monitor/hosts") res = {} fetcher = monitor.Fetcher(com_id) if issue == 'meminfo': res['meminfo'] = fetcher.get_meminfo() elif issue == 'gpuinfo': res['gpuinfo'] = fetcher.get_gpuinfo() elif issue == 'cpuinfo': res['cpuinfo'] = fetcher.get_cpuinfo() elif issue == 'cpuconfig': res['cpuconfig'] = fetcher.get_cpuconfig() elif issue == 'diskinfo': res['diskinfo'] = fetcher.get_diskinfo() elif issue == 'osinfo': res['osinfo'] = fetcher.get_osinfo() #elif issue == 'concpuinfo': # res['concpuinfo'] = fetcher.get_concpuinfo() elif issue == 'containers': res['containers'] = fetcher.get_containers() elif issue == 'status': res['status'] = fetcher.get_status() elif issue == 'containerslist': res['containerslist'] = fetcher.get_containerslist() elif issue == 'containersinfo': res = [] conlist = fetcher.get_containerslist() for container in conlist: ans = {} confetcher = monitor.Container_Fetcher(etcdaddr, G_clustername) ans = confetcher.get_basic_info(container) ans['cpu_use'] = confetcher.get_cpu_use(container) ans['mem_use'] = confetcher.get_mem_use(container) res.append(ans) else: return json.dumps({ 'success': 'false', 'message': 'not supported request' }) return json.dumps({'success': 'true', 'monitor': res})