diff --git a/tools/acceptance_command_line.py b/tools/acceptance_command_line.py deleted file mode 100644 index 47f07090a3d0053dbb01a7c9e725987498b15772..0000000000000000000000000000000000000000 --- a/tools/acceptance_command_line.py +++ /dev/null @@ -1,109 +0,0 @@ -import os -import zipfile -import tarfile -import argparse - - -class AcceptanceTool(object): - def devkit_acceptance_report(self, compressed_report_package): - if not os.path.exists(compressed_report_package): - print("请输入正确的报告压缩包") - return - file_ext = os.path.splitext(compressed_report_package)[1].lower() - if file_ext not in (".zip", ".gz", ".bz2"): - print("请使用以下格式的压缩包:zip、gz、bz2") - return - report_name = compressed_report_package.split("/")[-1].split("_") - devkit_pipeline_name = "" - devkit_pipeline_id = "" - if len(report_name) == 3: - devkit_pipeline_name = report_name[0] - devkit_pipeline_id = report_name[1] - decompress = {".zip": decompress_zip, ".gz": decompress_gz_bz, ".bz2": decompress_gz_bz} - current_path = os.getcwd() - print("开始解压") - file_names = decompress.get(file_ext)(compressed_report_package) - command_line_html = {"64-bit-running-mode-check.html": "64位运行模式检查", - "memory-consistency-check.html": "内存一致性检查", - "SoftwareMigrationAssessment.html": "软件迁移评估", - "byte-alignment-check.html": "字节对齐检查", "SourceCodeScanningReport.html": "源码迁移", - "compatibility_report.html": "云测工具"} - print("解压完成。") - print("流水线{}构建{}devkit-pipeline相关工具报告扫描中...".format(devkit_pipeline_name, devkit_pipeline_id)) - html_line = "" - contents = "" - for file in file_names: - if file.split("/")[-1] in command_line_html.keys(): - try: - with open(os.path.join(current_path, file), encoding="utf-8") as f: - content = f.readlines() - except UnicodeDecodeError: - with open(os.path.join(current_path, file), encoding="gbk") as f: - content = f.readlines() - if file.split("/")[-1] != "compatibility_report.html": - flag = 0 - for html_line in content: - if "Source File Path" in html_line and file != "SoftwareMigrationAssessment.html": - flag += 1 - continue - elif "Software Package Path or Name" in html_line: - flag += 1 - continue - if flag == 1: - html_line = \ - html_line.replace("""""", "").replace("""""", "").strip().split("/")[ - -1] - break - else: - for html_line in content: - if "Compatibility_Application_Start" in html_line: - str1 = html_line.find("7528") - str2 = html_line.find("542f") - html_line = html_line[str1 + 3 + 1: str2 - 2] - break - output_content = """{}: - 报告路径:{} - 被扫描软件名称:{}""".format(command_line_html.get(file.split("/")[-1]), - os.path.join(current_path, file), html_line) - print(output_content) - contents += "
  • {}
  • ".format(output_content) - - if not html_line: - print("""\033[31m未发现的devkit-pipeline相关工具报告\033[0m""") - - html_contents = '

    Acceptance report

    '.format( - contents) - with open('./{}_{}_htmlreports.html'.format(devkit_pipeline_name, devkit_pipeline_id), 'w') as f: - f.write(html_contents) - - -def decompress_zip(compressed_report_package): - with zipfile.ZipFile(compressed_report_package) as zip: - zip.extractall("./") - file_names = zip.namelist() - return file_names - - -def decompress_gz_bz(compressed_report_package): - with tarfile.open(compressed_report_package, "r") as tar: - tar.extractall(path="./") - file_names = tar.getnames() - return file_names - - -if __name__ == "__main__": - try: - parser = argparse.ArgumentParser() - parser.add_argument('-tool', help='DevKit or BoostKit') - parser.add_argument('-package', help='Compressed package') - args = parser.parse_args() - acceptance_tool = AcceptanceTool() - if args.tool == "DevKit": - acceptance_tool.devkit_acceptance_report(args.package) - elif args.tool == "BoostKit": - pass - else: - print("请输入正确的参数,如-tool Devkit 或 -tool BoostKit") - except Exception as err: - print(err) - print("请输入正确的参数") \ No newline at end of file diff --git a/tools/collect_msg.sh b/tools/collect_msg.sh new file mode 100644 index 0000000000000000000000000000000000000000..8beaa24883054f2db4d2f3bce87bc6ff66aef2b3 --- /dev/null +++ b/tools/collect_msg.sh @@ -0,0 +1,146 @@ +######################################################################### +# File Name: collect_msg.sh +# Author: **** +# mail: ****.com +# Created Time: Wed Mar 27 14:56:03 2024 +######################################################################### +#!/bin/bash +current_path=$(pwd) +config_file=$current_path/config.ini +log_path=$current_path/log +default_project="Bigdata Database Storage Arm Cala Kae Virtual" + + +#####################根据section以及key值获取对应value############ +acquire_value(){ + + project=$1 + key=$2 + grep $project -A 2 $config_file |awk -F -v section=$key '$1==section{print $2}' |awk '{print $1}' +} + + +######################获取配置文件中选择校验的解决方案########### +acquire_select_project(){ + all_name="" + for per_project in $default_project + do + status=$(acquire_value $per_project check) + if [[ $status = True ]]; then + all_name="$all_name $per_project" + fi + done + echo $all_name +} + +###################arm原生特性信息收集################# +# $1 docker容器名 + + +collect_arm_native(){ + kbox_container=$1 + vdeio_container=$2 + instruction_container=$3 + # kbox基础云手机 + docker exec -i $kbox_container logcat |grep gralloc.kbox.so >> $log_path/arm_native_kbox.log + docekr exec -i $kbox_container cat /proc/sys/fs/binfmt_misc/ubt_a32a64 >> $log_path/arm_native_kbox.log + + + # 视频流 + docker exec -it $video_container logcat |grep -i "Init engine module" >> $log_path/arm_native_kbox.log + + # 指令流 + docekr exec -it $instruction_container ps -ef|grep VmiAgent >> $log_path/arm_native_kbox.log + + +} + +#################虚拟化特性信息收集################## + +collect_virtual(){ + ovs-appctl hwoff/dump-hw-flows |grep "No flow available" >> virtual_feautre.log + sudo systemctl status waasagent.service >> virtual_feature.log + waasctl --version >> virtual_feature.log +} + +################数据库特性信息收集################## +collect_database(){ + mysql_install_path=$1 + plugin_path=$1/lib/plugin + ls $plugin_path |grep thread_pool.so >> $log_path/database_mysql.log + ls $plygin_path |grep ha_kovae.so >> $log_path/database_mysql.log + cd $mysql_install_path + readelf -a bin/mysqld|grep bolt >> $log_path/database_mysq.log + no_lock: $(objdump -d mysqld|grep -c row_vers_build_for_semi_consistent_readP5trx_t) >> $log_path/database_mysql.log + objdump -d bin/mysqld |grep crc32cb >> $log_path/database_mysql.log + cd - +} + + +####################机密计算特性信息收集################ + +collect_virtcca_msg(){ + cvm_name=$2 + username=$3 + passwd=$4 + ret=$(grep -i "type='cvm'" /etc/libvirt/qemu/$cvm_name) + if [-e $ret];then + echo "$ret" > $log_path/virtcca_status.log + expect << EOF + spawn virsh console $cvm_name + expect "Escape character is \\^]" + send "\r" + expect "login:" + send "$username\r" + expect "Password:" + send "$passwd\r" + interact + EOF + dirret = cd / && ls + echo "$dirret" > $log_path/virtcca_status.log + else + echo "virtcca status is Error" > $log_path/virt_status.log +} + + + + + +main(){ + if [ -e $config_file ]; then + select_project=$(acquire_select_project) + echo "开始收集BoostKit 特性信息如下:$select_project" + mkdir -p $log_path + echo "日志存放位置: $log_path" + else + echo "config.ini not exist" + exit 1 + fi + + for per_project in $select_project + do + if [ $per_project = "Bigdata" ]; + then + echo "start collect Bigdata msg..." + elif [ $per_project = "virtcca" ]; + then + echo "start collect virtcca msg..." + elif [ $per_project = "database" ]; + then + echo "start collect database msg..." + collect_database $(acquire_value database mysql_install_path) + + fi + done +} + + + + + + + + + + + diff --git a/tools/config.ini b/tools/config.ini new file mode 100644 index 0000000000000000000000000000000000000000..b74e3fc2065b1f118dfda8982c76ebedfbafbbc1 --- /dev/null +++ b/tools/config.ini @@ -0,0 +1,18 @@ +[virtcca] +check=True +cvm_name=cvm1 +cvm_username=root +cvm_password=huawei + + + +[arm] +check=True +kbox_container=kbox_1 # 基础kbox +video_container=kbox_2 # 视频流容器 +instuction_container=kbox_3 #指令流容器 + + +[database] +check=True +mysql_install_path=/usr/local/mysql diff --git a/tools/isv_tool.py b/tools/isv_tool.py new file mode 100644 index 0000000000000000000000000000000000000000..9d6addc25f9176d9e02629749ac9092a05c445a4 --- /dev/null +++ b/tools/isv_tool.py @@ -0,0 +1,131 @@ +import re +import logging + + +Logger = logging.getLogger() +Logger.setLevel(level=logging.INFO) +File_log = logging.FileHandler("./isv.log", "a") +File_log.setFormatter(logging.Formatter("%(message)s")) +Logger.addHandler(File_log) + + +class IsvTool: + def __init__(): + self.log = Logger + self.method_dict = { + "database_no_lock": self.no_lock, + "database_thread_pool": self.thread_pool, + } + self.basic_key_word = [ + "", + + ] + + def no_lock(self, log_path): + self.log.info(f"no_lock: {log_path}") + return True + + def thread_pool(self, log_path): + self.log.info(f"thread_pool: {log_path}") + return True + + def check_virtcca_cvm(self, log_path): + create_cvm_status = False + start_cvm_status = False + with open(log_path) as f: + for per_line in f.readlines(): + if "launchSecurity type=\'cvm\''" + create_cvm_status = True + elif "etc" in per_line: + start_cvm_status = True + + self.log.info(f"create_cvm_status: {create_cvm_status} start_cvm_status: {start_cvm_status}") + if start_cvm_status and create_cvm_status + return True + else: + return False + + def check_arm_native(self, log_path): + basic = True + video = True + instruction = True + with open(log_path) as f: + content = f.read() + for per_key_word in self.basic_key_word: + re_res = re.compile(f"{per_key_word}").findall(content) + if not re_res: + basic = False + break + + video_res = re.compile(f"Init engine module").findall(content) + if not video_res: + video = False + + instruction_res = re.compile(f"VmiAgent instruction").findall(content) + if not instruction_res: + instruction = False + + return { "basic": basic, "video": video, "instruction": instruction} + + def check_virtual_ovs(self, log_path): + # ovs 卸载检测 + status = False + with open(log_path) as f: + if not re.compile("No flow available").findall(f.read()) + status = True + + return status + + def check_load_awareness(self, log_path): + # 负载动态感知检测 + running_status = False + version_status = False + with open(log_path) as f: + if re.compile("active (running)").findall(f.read()) + running_status = True + if re.compile("waasctl: 1.0.0").findall(f.read()) and \ + re.compile("Wass Agent: 1.0.0").findall(f.read()): + version_status = True + + if running_status and version_status: + return True + else: + return False + + + def check_database(self, log_path): + thread_pool, kovae, gcc_compile, no_lock, crc32 = False, False, False, False, False + with open(log_path) as f: + content = f.read() + if re.compile("thread_pool.so").findall(content): + thread_pool = True + + if re.compile("ha_kovae.so").findall(content): + kovae = True + + if re.compile("blot").findall(content): + gcc_compile = True + + no_lock_list = re.compile("no_lock: (\d+)").findall(content): + if int(no_lock_list[0]) > 0: + no_lock = True + + if re.compile("crcewcb").findall(content): + crc32 = True + + return {"thread_pool": thread_pool, "kovae": kovae, "gcc_compile": gcc_compile, "nolock": no_lock, "crc32": crc32} + + + + def analysis(self, *log_path_list): + not_include_log = list() + result = dict() + for per_log in log_path_list: + per_log_strip = per_log.replace(".log", "") + method_exec = self.method_dict.get(per_log_strip, None) + if not method_exec: + not_include_log.append(per_log) + continue + result[per_log_strip] = meth_exec(per_log) + + return result