hosts, index, cost = get_domain_hosts(db_connect, Conf.domain_id) head_title, download_url, add_head = get_head_title( db_connect, Conf.head_id) hosts_metrics = get_domain_metrics(db_connect, hosts) disk_space = get_disk_space(pub, hosts, index, db_connect) host_apps = get_host_apps(pub, hosts, db_connect) document = Document(os.path.join(doc_path, 'host-report-tpl.docx')) document.add_heading(add_head) chapter = Chapter(os.path.join(doc_path, 'host-summary-tpl.docx')) chapter.add_context({ 'date_cycle': date_cycle, 'table': hosts, 'fee': cost }) document.add_chapter(chapter, title="主机明细总览", level=2) html_table(hosts, add_head, cost, date_cycle, download_url) for host in hosts: image_host_resource(doc_path, hosts_metrics, host) image_host_apps(doc_path, host_apps, host)
logging.info(' not none') result_doc.update({ 'context': result_doc.get('ExceptionType') + "," + str(result_doc.get('count')) }) result_doc.update({'sumCount': 1}) host_mongo_query_exceptions.update({new_id: result_doc}) # host_mongo_query_exceptions = sorted(host_mongo_query_exceptions.items(), key=lambda d: d[0]) logging.info( f'host_mongo_query_exceptions is {host_mongo_query_exceptions}') # \\print(sorted(host_mongo_query_exceptions.items(), key=lambda d: d[0])) doc_path = '/Users/mtr/PycharmProjects/mongoQuery/com/asiainfo/aihc/doc_1_20190807' document = Document(os.path.join(doc_path, 'host-report-tpl.docx')) chapter = Chapter( os.path.join(doc_path, 'host-mongo_query_exceptions-tpl.docx')) # host_mongo_query_exceptions = [{'ip': '10.19.85.33', 'FunctionName': 'load', 'count': '10', # 'context': 'NullPointException:1,RuntimeException:3'}, # {'ip': '10.19.85.34', 'FunctionName': 'serv', 'count': '20', # 'context': 'NullPointException:2,RuntimeException:6'}] excep_result = host_mongo_query_exceptions.values() logging.info(f'excep_result is {excep_result}') table = {'table': excep_result} chapter.add_context(table) print(f"host-mongo_query_exceptions table is {table}") document.add_chapter(chapter, title="异常数量统计", level=2) document.render() document.save( os.path.join(doc_path, '%s云主机使用情况.docx' % ('mongo_query_exception')))