使用命令行进行系统迁移应用信息收集
命令功能
使用命令通过终端工具进行系统迁移应用信息收集。
命令格式
- Linux环境
devkit porting sys-mig -c,--command {stmt/sbom} -cf,--config configure_file_path -d,--directory scan_path -t,--template stmt_template_path -o,--output report_dir -f,--format {html/json} -e,--exclude-fields {version/checkOutPath} -l,--log-level {0/1/2/3} -v,--version -h,--help
- Windows环境
.\sys-mig.exe -c,--command {stmt/sbom} -cf,--config configure_file_path -d,--directory scan_path -t,--template stmt_template_path -o,--output report_dir -f,--format {html/json} -e,--exclude-fields {version/checkOutPath} -l,--log-level {0/1/2/3} -v,--version -h,--help
参数说明
参数 |
参数选项 |
说明 |
---|---|---|
-c/--command |
stmt/sbom |
收集信息的模式。
|
-cf/--config |
configure_file_path |
输入参数配置文件路径。 |
-d/--directory |
scan_path |
输入扫描文件目录,支持输入多个目录,多个目录间以空格分隔。 |
-t/--template |
stmt_template_path |
stmt模式参数,输入台账扫描结果模板路径,默认按照程序内置模板生成扫描结果。 |
-o/--output |
report_dir |
报告输出目录,默认为二进制所在report目录。 |
-f/--format |
html/json |
sbom模式参数,输入生成报告格式,支持选择html、json格式,可以选择多个报告格式,默认为HTML格式,多个报告格式以空格间隔。 |
-e/--exclude-fields |
version/checkOutPath |
sbom模式参数,表示需要隐藏的参数信息,可选参数范围:version和checkOutPath,支持同时选择。 version表示成分版本号,checkOutPath表示成分检出路径,多个参数信息以空格间隔。 |
-v/--version |
- |
展示程序版本信息,无输入参数。 |
-h/--help |
- |
帮助查询,无输入参数。 |
-l/--log-level |
0,1,2,3 |
日志等级,可选参数:0(DEBUG)、1(INFO)、2(WARNING)、3(ERROR),默认为1(INFO)。 |
使用实例
此处以分析porting/resources目录下的sysmig_default.conf并输出csv格式的分析报告为例,请根据实际情况将“porting/resources/sysmig_default.conf”替换成实际需要扫描的配置文件路径。
devkit porting sys-mig -c stmt -cf porting/resources/sysmig_default.conf
返回信息如下,输出的报告为/home/stmt_xx.xx.xx.xx_20240307142402.csv。
[2024-03-07 14:24:02,424] [INFO] Start to execute the command: ./devkit porting sys-mig -c stmt -cf porting/resources/sysmig_default.conf -d /usr/local -o /home -t /home/stmt_template_default.csv -l 0 [2024-03-07 14:24:02,425] [INFO] Creating file indexing... [2024-03-07 14:24:04,580] [INFO] Parsing... [2024-03-07 14:24:04,580] [INFO] Start Scanning stmt information. [2024-03-07 14:24:04,581] [INFO] Middleware binary start analysis. [2024-03-07 14:24:06,513] [INFO] Middleware binary end of analysis. [2024-03-07 14:24:06,513] [INFO] Middleware binary start analysis. [2024-03-07 14:24:06,576] [INFO] Middleware package end of analysis. [2024-03-07 14:24:06,591] [INFO] csv report is created successfully. the file is located in /home/stmt_xx.xx.xx.xx_20240307142402.csv
配置文件使用说明
台账命令行配置文件模板,在命令行配置-cf或--config时生效。默认格式如下所示:
# DESCRIPTION # Configuration file template of the System Migration command line. It takes effect only when -cf or --config is executed. # To use this template, delete the template comments below the help information and set the parameters. Note that parameters in the command line take precedence # over those in the configuration file. If parameters have been set in the command line, the parameters in the configuration file do not take effect. # OPTIONS # command {stmt,sbom} # Type of information to be collected. The options are (default) stmt and sbom. Stmt generates a CSV report, and sbom generates a detailed HTML or JSON report. # directory <path> [<path> ...] # Directory of scanning for collected information. You can enter multiple directories (the current directory by default). # Separate multiple directories with spaces. If the name of the folder to be scanned contains spaces, use single quotation marks(') to mark the parameter. # output <path> # Report output directory. (The default is the report directory where the binary file is located.) # template <file> # This parameter is used in stmt mode. Enter the template path of the CSV report. (By default, the CSV report is generated based on the built-in template.) # For details about the template, see ./resources/stmt_template_default.csv. # Built-in variables used in the template include ${cpuCores}, ${memory}, ${middleware}, ${dbType}, ${osSystem}, ${ip}, and ${hostName}, and they cannot be modified. # format {html,json} [{html,json} ...] # Format of the report generated in sbom mode. The options are HTML and json. You can select multiple report formats. The default value is HTML. # Separate multiple reports with spaces(Example: -f html json). # exclude-fields {version,checkOutPath} [{version,checkOutPath} ...] # Parameters hidden in sbom mode. The optional parameters are version and checkOutPath, and they can be selected at the same time. # Version indicates the component version number and checkOutPath indicates the component checkout path. Separate multiple parameters with spaces. # log-level {0,1,2,3} # Log level. The options are 0(DEBUG), 1(INFO), 2(WARNING), and 3(ERROR). The default value is 1(INFO). # [stmt] # directory= # output= # template= # log-level= # [sbom] # directory= # output= # format= # exclude-fields= # log-level=

stmt模式下模板使用示例
devkit porting sys-mig -c stmt -t template/stmt_tempalte_default.csv

-t/--template参数的默认模板位置为porting/template/stmt_tempalte_default.csv。
其中template是一个csv文件,有两行数据。第一行是待搜索的信息,第二行是搜索信息对应的内部变量,可删除或更换位置,但不可修改。
输出报告说明
报告类型 |
报告详细说明 |
---|---|
csv |
用于展示现网台账信息,信息主要包含现网的服务器规格、中间件、数据库等信息。 |
json |
汇总Java应用、中间件、OS、硬件等系统成分的相关元数据详细信息,如:成分名称、版本号、检出路径、兼容性等,以及成分之间的父子关系。 |
html |
通过树形图的方式分别展示Java应用、中间件、数据库、OS等系统成分的关联关系,以及每个成分的基础信息,如:成分名称、版本号、检出路径、兼容性等。 |