From b80ff6c4a6f9c9838e1812b1c268d2ef56730f50 Mon Sep 17 00:00:00 2001 From: easongao <46415758+easson001@users.noreply.github.com> Date: Thu, 24 Sep 2020 16:45:38 +0800 Subject: [PATCH 1/3] Add files via upload delete data acess checking --- ...77\347\224\250\350\257\264\346\230\216.md" | 750 +++++++++--------- 1 file changed, 356 insertions(+), 394 deletions(-) diff --git "a/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" "b/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" index 2038034f8b..f3cbe58f1a 100644 --- "a/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" +++ "b/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" @@ -1,394 +1,356 @@ -# 脚本使用说明 - -## 一 概述 - -本工具集提供4个工具,功能如下: - -| 工具名称 | 工具功能 | 使用场景 | -| ---------------- | ------------------------------------------ | -------------------- | -| 机器基础信息检测 | 验证机器设置是否满足跑fate任务要求 | 部署完成并启动服务后 | -| fate运行信息检测 | 验证机器当前状态是否适合新建一个fate任务 | 启动fate任务前 | -| 日志搜集 | 搜集该集群下所有session_id的日志到当前目录 | 跑任务出现错误后 | -| 集群配置检测 | 搜集展示集群的配置文件信息 | 部署完成启动服务失败 | - -名词解释: - -| 名词 | 解释 | -| ----------------------- | -------------------------------------------------------- | -| $FATE_HOME | 通常在/data/projects/fate | -| $EGGROLL_HOME | 通常在/data/projects/fate/eggroll | -| ${集群节点个数} | 如果运行脚本的机器所在集群有3个节点,就取3 | -| ${host party_id} | 可选参数,检查data_access服务是否可用,取host方partyid值 | -| ${需要查询的session-id} | 是一个21位左右的长id。如202009031227285073491。 | - - - -## 二 机器基础信息检测 - -### 2.1 使用场景 - ------- - -此脚本在完成部署并正常启动服务后运行,脚本功能检查系统内存 / 虚拟内存 / 磁盘 / 最大用户进程数 / 文件数 / 线程数设置 / rollsite进程堆内存 等机器基础信息,用于验证机器设置是否满足跑fate任务要求。 - -### 2.2 工具功能 - ------- - -此检测检测提供两种版本: - -- 单集群版:基于eggroll服务检测,需要各个节点eggroll服务正常启动后方可使用,用于检测各个nodemanager服务所在节点的集群基础信息,其检测项包含以下所有共7项; - -- 跨集群版:无需依赖eggroll服务,可以跨节点检测指定所有ip的基础信息,其检测项仅包括以下列出前5项,**需支持节点间免密登录**。 - -1)检查系统内存:系统内存总量、系统内存使用量、系统内存使用占比 - -2)检查虚拟内存:虚拟内存总量、虚拟内存使用量、虚拟内存使用占比 - -3)检查磁盘使用情况:磁盘总量、磁盘使用量、磁盘使用占比 - -4)检查系统最大用户进程数 - -5)检查最大文件数 - -6)检查线程数设置:检查egg pair线程数eggroll.rollpair.eggpair.server.executor.pool.max.size设置是否充足 - -7)检查rollsite进程堆内存是否充足: - -### 2.3 使用方法 - ------- - -#### 2.3.1 单集群版 - -```shell -source $FATE_HOME/init_env.sh -cd $EGGROLL_HOME/bin/debug -sh env_check.sh ${集群节点个数} -cat result_env.log -``` - -若对几个$开头的变量有疑问,请参考概述中的名词解释。 - -#### 2.3.2 跨集群版 - -**需支持节点间免密scp、ssh操作,也可以手动输入密码执行** - -1、设置环境变量: - -```shell -source $FATE_HOME/init_env.sh -``` - -2、编辑配置文件: - -``` -cd $EGGROLL_HOME/bin/debug -vi check_iplist.sh -``` - -参数说明: - -```shell -user=app <远程登录用户名> -iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> -``` - -3、执行检测脚本: - -```python -python time_check.py -//查看检测结果,各个ip的检测结果生成于当前目录下以ip命名的文件,直接cat可查看对应ip的返回信息 -cat ./$ip -``` - -//若需定时检测观察内存信息变化则加-t参数,可指定间隔秒数定时输出 - -``` -python time_check.py -t {检测间隔秒数,不填只检测一次} -``` - -### 2.4 检测结果说明 - ------- - -返回示例信息如下: - -*说明:以下信息分为三种提示等级:* - -*[OK\] 表示该检查项正常;* - -*[WARNING\]表示该项需要注意,仅作关键信息展示,需要自行判断;* - -*[ERROR\]表示该项不符合预期结果,需要按提示修改。* - -```properties -//脚本执行时间 - 2020-09-02 15:00:41.424053 -//返回的节点ip - ==============This is node 0:127.0.0.1=========================================== -//系统内存总量、系统内存使用量、系统内存使用占比 - [WARNING] MemTotal:78.51G, MemUsed:11.5G, MemUsedPCT:15% -//虚拟内存总量、虚拟内存使用量、虚拟内存使用占比,若小于128G,则提示ERROR,如下所示: - [ERROR] The swap memory is:32.0G, no less than 128G. <虚拟内存不足 - [WARNING] MemTotal:16.51G, MemUsed:128G, MemUsedPCT:12.3% <虚拟内存正常 -//磁盘总量、磁盘使用量、磁盘使用占比 - [WARNING] DiskTotal:984.18G, DiskUsed:566.53G, DiskUsedPCT:61% - --------------Max user processes and max file count------------------------------ -//最大用户进程数与最大文件数各个文件设置值展示,其中不满足65535的项则报[ERROR提示]: - [OK] /proc/sys/kernel/threads-max = 642956 - [OK] /etc/sysctl.conf = 1048576 - [OK] /proc/sys/kernel/pid_max = 131072 - [ERROR] please check /proc/sys/vm/max_map_count = 65530, no less than 65535. - [OK] /etc/security/limits.conf = 102401 - [OK] /etc/security/limits.d/80-nofile.conf = 131072 - [OK] /etc/sysctl.conf = 1048576 - [OK] /proc/sys/fs/file-max = 1048576 - --------------Thread count check------------------------------------------------- -//判断eggroll.properties中eggroll.rollpair.eggpair.server.executor.pool.max.size配置项设置的线程值是否充足,若不充足,则报[ERROR]提示需要调大线程值 - [OK] The thread count = 1406, the total processes = 16 * 500 = 8000 - ----------Rollsite memory use percent-------------------------------------------- -//展示rollsite进程占用堆内存与rollsite设置内存上限比值,以判断rollsite内存是否充足,若百分比偏大,则需考虑释放rollsite内存或调高rollsite内存上限 - [WARNING] rollsite memory use: 0.69% -``` - - - -## 三 fate运行信息检测 - -### 3.1 使用场景 - ------- - -跑fate任务前,检测fate运行信息。验证机器当前状态是否适合新建一个fate任务 - -### 3.2 工具功能 - ------- - -检测fate运行信息:eggroll路由是不是默认路由、是否已安装data access、fate服务的运行状态、进程数及占用内存情况、当前环境正在运行及等待的job任务数、job任务有多少进程及占用的内存情况。 - -### 3.3 使用方法 - -``` -source $FATE_HOME/init_env.sh //FATE_HOME为用户环境的fate目录 -cd $EGGROLL_HOME/bin/debug -sh server_check.sh ${集群内节点个数} ${host party_id(可选)} -例:sh server_check.sh 1 10000 -``` - -可选参数: - -​ {host party_id} //当需要检查data_assess的服务是否可用时使用。若不提供该参数时不检测。 - -结果保存在result_server.log文件中 - -### 3.4 检测结果说明 - ------- - -#### 3.4.1 default route check(eggroll路由是不是默认路由) - -- 检测通过提示: - - [OK] eggroll route configured! - - "port": 9370, "ip": "127.0.0.1" - -- 检测失败提示: - - [ERROR] eggroll route is not configured, please check /data/projects/fate/eggroll/conf/route_table.json file if it is existed! - -- 检查方法: - - 检测/data/projects/fate/eggroll/conf/route_table.json 是否有配置default参数。如果有,把ip和端口打印出来。如果无,提示ERROR。 - - - -#### 3.4.2 data_access service check(是否已安装data access) - -- 检测通过提示: - - [OK] Installed and running data_access service! - -- 检测失败提示: - - [ERROR] data_access service and directory not found, please check if it is installed! - -- 检查方法: - - 先检查data_access 进程是否存在或者目录是否存在。若存在,会进一步检查data_access 服务是否可用。详细逻辑是: - - ``` - 若返回进程数为0,判断检查服务目录的返回值,若为0,则视为没有安装access,提示ERROR;否则,则视为没有启动access,提示WARNING; - - 若返回进程数大于0,判断路由验证返回码,如果返回 "status":0,或 "status":201,则说明 DataAccess 服务以及路由表配置没有问题,否则提示WARNING检查路由设置 - ``` - -#### 3.4.3 fate service check(fate服务状态、进程数及占用内存) - -- 检测通过提醒: - - [OK] the service is running , number of processes is :; used memory: - -- 检测失败提醒: - - [WARNING] the service not running, please check service status. - -- 检查方法: - - 检查服务列表: - - 'ClusterManagerBootstrap','NodeManagerBootstrap','rollsite','fate_flow_server.py','fateboard','mysql' - - 检查进程数方法: - - ``` - thread = ps -ef |grep service |grep -v grep |wc -l - ``` - - 检查服务占用内存方法: - - ``` - server_mem = ps aux |grep %s |grep -v grep |awk '{sum+=$6};END {print sum}' - ``` - - -#### 3.4.4 fate_flow jobs process and mem info check(job任务数检测、job任务进程及占用内存) -- 检测通过提醒: - - [OK] Number of tasks running is xxx - - [OK] Number of tasks waiting is xxx - - [OK] running task job_id :xxx ,number of egg_pair processes is :xxx; used memory:xxx - -- 检测失败提醒: - - [ERROR] There is no such fate_flow_client.py file, please check fate_flow server if it is running! - -- 检查方法: - - 通过FATE自带的fate_flow_client 命令查看任务相关信息,通过ps命令查看内存相关信息。 - - - -## 四 日志搜集 - -### 4.1 使用场景 - ------- - -适用于跑任务出现错误后,在开发人员指导下进行错误日志搜集脚本,需要从报错日志中提取关键报错信息。 - -### 4.2 工具功能 - ------- - -拉取指定ip:$EGGROLL_HOME/logs目录下带传入关键字的目录到本机当前目录下 - -### 4.3 使用方法 - -**需支持节点间免密scp、ssh操作,也可以手动输入密码执行** - -1、设置环境变量: - -```shell -source $FATE_HOME/init_env.sh -``` - -2、编辑配置文件: - -``` -cd $EGGROLL_HOME/bin/debug -vi check_iplist.sh -``` - -参数说明: - -```shell -user=app <远程登录用户名> -iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> -``` - -3、执行检测脚本: - -```shell -sh grep_logs.sh ${需要查询的session-id} <带上需要搜集的session-id,支持模糊查询> -``` - -执行后该session-id的各个ip的日志便会搜集到当前目录下的$session-id/$ip目录下 - -### 4.4 结果说明 - ------- - -执行完可在当前目录下看到传入的$session_id目录,目录下是各个ip的关于$session_id的日志。 - - - -## 五 集群配置检测 - -### 5.1 使用场景 - ------- - -适用于运维人员部署好项目后,肉眼检查各个机器的eggroll.properties、route_table.json配置是否存在问题。 - -### 5.2 工具功能 - ------- - -拉取指定ip的eggroll.properties、route_table.json配置到本机展示。 - -### 5.3 使用方法 - -**需支持节点间免密scp、ssh操作,或手动输入密码执行也可以** - ------- - -1、设置环境变量: - -```shell -source $FATE_HOME/init_env.sh -``` - -2、编辑配置文件: - -``` -cd $EGGROLL_HOME/bin/debug -vi check_iplist.sh -``` - -参数说明: - -```shell -user=app <远程登录用户名> -iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> -``` - -3、然后执行脚本: - -```shell -sh check_conf.sh -``` - -### 5.4 结果说明 - ------- - -该脚本展示配置所有ip与本机的配置对比,说明如下: - -```properties -//展示本机eggroll.properties配置信息 -----------------------$EGGROLL_HOME/conf/eggroll.properties-------------------- -//展示本机route_table.json配置信息 ------------------------$EGGROLL_HOME/conf/route_table.json--------------------- -//展示ip列表中第一个ip配置与本机的diff结果,若为空则完全相同 -------------------diff $ip1 with ./conf/eggroll.properties------------------------- -//展示ip列表中第二个ip配置与本机的diff结果,若为空则完全相同 -------------------diff $ip2 with ./conf/eggroll.properties------------------------- -//展示ip列表中第三个ip配置与本机的diff结果,若为空则完全相同 -------------------diff $ip3 with ./conf/eggroll.properties------------------------- -``` - +# 脚本使用说明 + +## 一 概述 + +本工具集提供4个工具,功能如下: + +| 工具名称 | 工具功能 | 使用场景 | +| ---------------- | ------------------------------------------ | -------------------- | +| 机器基础信息检测 | 验证机器设置是否满足跑fate任务要求 | 部署完成并启动服务后 | +| fate运行信息检测 | 验证机器当前状态是否适合新建一个fate任务 | 启动fate任务前 | +| 日志搜集 | 搜集该集群下所有session_id的日志到当前目录 | 跑任务出现错误后 | +| 集群配置检测 | 搜集展示集群的配置文件信息 | 部署完成启动服务失败 | + +名词解释: + +| 名词 | 解释 | +| ----------------------- | ----------------------------------------------- | +| $FATE_HOME | 通常在/data/projects/fate | +| $EGGROLL_HOME | 通常在/data/projects/fate/eggroll | +| ${集群节点个数} | 如果运行脚本的机器所在集群有3个节点,就取3 | +| ${需要查询的session-id} | 是一个21位左右的长id。如202009031227285073491。 | + + + +## 二 机器基础信息检测 + +### 2.1 使用场景 + +------ + +此脚本在完成部署并正常启动服务后运行,脚本功能检查系统内存 / 虚拟内存 / 磁盘 / 最大用户进程数 / 文件数 / 线程数设置 / rollsite进程堆内存 等机器基础信息,用于验证机器设置是否满足跑fate任务要求。 + +### 2.2 工具功能 + +------ + +此检测检测提供两种版本: + +- 单集群版:基于eggroll服务检测,需要各个节点eggroll服务正常启动后方可使用,用于检测各个nodemanager服务所在节点的集群基础信息,其检测项包含以下所有共7项; + +- 跨集群版:无需依赖eggroll服务,可以跨节点检测指定所有ip的基础信息,其检测项仅包括以下列出前5项,需支持节点间免密登录。 + +1)检查系统内存:系统内存总量、系统内存使用量、系统内存使用占比 + +2)检查虚拟内存:虚拟内存总量、虚拟内存使用量、虚拟内存使用占比 + +3)检查磁盘使用情况:磁盘总量、磁盘使用量、磁盘使用占比 + +4)检查系统最大用户进程数 + +5)检查最大文件数 + +6)检查线程数设置:检查egg pair线程数eggroll.rollpair.eggpair.server.executor.pool.max.size设置是否充足 + +7)检查rollsite进程堆内存是否充足: + +### 2.3 使用方法 + +------ + +#### 2.3.1 完整版 + +```shell +source $FATE_HOME/init_env.sh +cd $EGGROLL_HOME/bin/debug +sh env_check.sh ${集群节点个数} +cat result_env.log +``` + +若对几个$开头的变量有疑问,请参考概述中的名词解释。 + +#### 2.3.2 简约版 + +1、设置环境变量: + +```shell +source $FATE_HOME/init_env.sh +``` + +2、编辑配置文件: + +``` +cd $EGGROLL_HOME/bin/debug +vi check_iplist.sh +``` + +参数说明: + +​ user=app <远程登录用户名> +​ iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> + +3、执行检测脚本: + +```python +python time_check.py +//查看检测结果,各个ip的检测结果生成于当前目录下以ip命名的文件,直接cat可查看对应ip的返回信息 +cat ./$ip +``` + +//若需定时检测观察内存信息变化则加-t参数,可指定间隔秒数定时输出 + +``` +python time_check.py -t {检测间隔秒数,不填只检测一次} +``` + +### 2.4 检测结果说明 + +------ + +返回示例信息如下: + +*说明:以下信息分为三种提示等级:* + +*[OK\] 表示该检查项正常;* + +*[WARNING\]表示该项需要注意,仅作关键信息展示,需要自行判断;* + +*[ERROR\]表示该项不符合预期结果,需要按提示修改。* + +```properties +//脚本执行时间 + 2020-09-02 15:00:41.424053 +//返回的节点ip + ==============This is node 0:127.0.0.1=========================================== +//系统内存总量、系统内存使用量、系统内存使用占比 + [WARNING] MemTotal:78.51G, MemUsed:11.5G, MemUsedPCT:15% +//虚拟内存总量、虚拟内存使用量、虚拟内存使用占比,若小于128G,则提示ERROR,如下所示: + [ERROR] The swap memory is:32.0G, no less than 128G. <虚拟内存不足 + [WARNING] MemTotal:16.51G, MemUsed:128G, MemUsedPCT:12.3% <虚拟内存正常 +//磁盘总量、磁盘使用量、磁盘使用占比 + [WARNING] DiskTotal:984.18G, DiskUsed:566.53G, DiskUsedPCT:61% + --------------Max user processes and max file count------------------------------ +//最大用户进程数与最大文件数各个文件设置值展示,其中不满足65535的项则报[ERROR提示]: + [OK] /proc/sys/kernel/threads-max = 642956 + [OK] /etc/sysctl.conf = 1048576 + [OK] /proc/sys/kernel/pid_max = 131072 + [ERROR] please check /proc/sys/vm/max_map_count = 65530, no less than 65535. + [OK] /etc/security/limits.conf = 102401 + [OK] /etc/security/limits.d/80-nofile.conf = 131072 + [OK] /etc/sysctl.conf = 1048576 + [OK] /proc/sys/fs/file-max = 1048576 + --------------Thread count check------------------------------------------------- +//判断eggroll.properties中eggroll.rollpair.eggpair.server.executor.pool.max.size配置项设置的线程值是否充足,若不充足,则报[ERROR]提示需要调大线程值 + [OK] The thread count = 1406, the total processes = 16 * 500 = 8000 + ----------Rollsite memory use percent-------------------------------------------- +//展示rollsite进程占用堆内存与rollsite设置内存上限比值,以判断rollsite内存是否充足,若百分比偏大,则需考虑释放rollsite内存或调高rollsite内存上限 + [WARNING] rollsite memory use: 0.69% +``` + + + +## 三 fate运行信息检测 + +### 3.1 使用场景 + +------ + +跑fate任务前,检测fate运行信息。验证机器当前状态是否适合新建一个fate任务 + +### 3.2 工具功能 + +------ + +检测fate运行信息:eggroll路由是不是默认路由、是否已安装data access、fate服务的运行状态、进程数及占用内存情况、当前环境正在运行及等待的job任务数、job任务有多少进程及占用的内存情况。 + +### 3.3 使用方法 + +``` +source $FATE_HOME/init_env.sh //FATE_HOME为用户环境的fate目录 +cd $EGGROLL_HOME/bin/debug +sh server_check.sh ${集群内节点个数} +例:sh server_check.sh 1 +``` + +结果保存在result_server.log文件中 + +### 3.4 检测结果说明 + +------ + +#### 3.4.1 default route check(eggroll路由是不是默认路由) + +- 检测通过提示: + + [OK] eggroll route configured! + + "port": 9801, "ip": "172.16.153.25" + +- 检测失败提示: + + [ERROR] eggroll route is not configured, please check /data/projects/fate/eggroll/conf/route_table.json file if it is existed! + +- 检查方法: + + 检测/data/projects/fate/eggroll/conf/route_table.json 是否有配置default参数。如果有,把ip和端口打印出来。如果无,提示ERROR。 + + +#### 3.4.2 fate service check(fate服务状态、进程数及占用内存) + +- 检测通过提醒: + + [OK] the service is running , number of processes is :; used memory: + +- 检测失败提醒: + + [WARNING] the service not running, please check service status. + +- 检查方法: + + 检查服务列表: + + 'ClusterManagerBootstrap','NodeManagerBootstrap','rollsite','fate_flow_server.py','fateboard','mysql' + + 检查进程数方法: + + ``` + thread = ps -ef |grep service |grep -v grep |wc -l + ``` + + 检查服务占用内存方法: + + ``` + server_mem = ps aux |grep %s |grep -v grep |awk '{sum+=$6};END {print sum}' + ``` + + +#### 3.4.3 fate_flow jobs process and mem info check(job任务数检测、job任务进程及占用内存) +- 检测通过提醒: + + [OK] Number of tasks running is xxx + + [OK] Number of tasks waiting is xxx + + [OK] running task job_id :xxx ,number of egg_pair processes is :xxx; used memory:xxx + +- 检测失败提醒: + + [ERROR] There is no such fate_flow_client.py file, please check fate_flow server if it is running! + +- 检查方法: + + 通过FATE自带的fate_flow_client 命令查看任务相关信息,通过ps命令查看内存相关信息。 + + + +## 四 日志搜集 + +### 4.1 使用场景 + +------ + +适用于跑任务出现错误后,在开发人员指导下进行错误日志搜集脚本,需要从报错日志中提取关键报错信息。 + +### 4.2 工具功能 + +------ + +拉取指定ip:$EGGROLL_HOME/logs目录下带传入关键字的目录到本机当前目录下 + +### 4.3 使用方法 + +1、设置环境变量: + +```shell +source $FATE_HOME/init_env.sh +``` + +2、编辑配置文件: + +``` +cd $EGGROLL_HOME/bin/debug +vi check_iplist.sh +``` + +参数说明: + +​ user=app <远程登录用户名> +​ iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> + +3、执行检测脚本: + +```shell +sh grep_logs.sh ${需要查询的session-id} <带上需要搜集的session-id,支持模糊查询> +``` + +执行后该session-id的各个ip的日志便会搜集到当前目录下的$session-id/$ip目录下 + +### 4.4 结果说明 + +------ + +执行完可在当前目录下看到传入的$session_id目录,目录下是各个ip的关于$session_id的日志。 + + + +## 五 集群配置检测 + +### 5.1 使用场景 + +------ + +适用于运维人员部署好项目后,肉眼检查各个机器的eggroll.properties、route_table.json配置是否存在问题。 + +### 5.2 工具功能 + +------ + +拉取指定ip的eggroll.properties、route_table.json配置到本机展示。 + +### 5.3 使用方法 + +------ + +1、设置环境变量: + +```shell +source $FATE_HOME/init_env.sh +``` + +2、编辑配置文件: + +``` +cd $EGGROLL_HOME/bin/debug +vi check_iplist.sh +``` + +参数说明: + +​ user=app <远程登录用户名> +​ iplist=(127.0.0.1 127.0.0.2 127.0.0.3) <需要拉取日志的ip列表> + +3、然后执行脚本: + +```shell +sh check_conf.sh +``` + +### 5.4 结果说明 + +------ + +该脚本展示配置所有ip与本机的配置对比,说明如下: + +```properties +//展示本机eggroll.properties配置信息 +----------------------$EGGROLL_HOME/conf/eggroll.properties-------------------- +//展示本机route_table.json配置信息 +-----------------------$EGGROLL_HOME/conf/route_table.json--------------------- +//展示ip列表中第一个ip配置与本机的diff结果,若为空则完全相同 +------------------diff $ip1 with ./conf/eggroll.properties------------------------- +//展示ip列表中第二个ip配置与本机的diff结果,若为空则完全相同 +------------------diff $ip2 with ./conf/eggroll.properties------------------------- +//展示ip列表中第三个ip配置与本机的diff结果,若为空则完全相同 +------------------diff $ip3 with ./conf/eggroll.properties------------------------- +``` + From 7ef1d0af29f7b4c13f4b5a4cd580772e4e24984f Mon Sep 17 00:00:00 2001 From: easongao <46415758+easson001@users.noreply.github.com> Date: Thu, 24 Sep 2020 16:48:07 +0800 Subject: [PATCH 2/3] Add files via upload delete data access checking --- tools/debug/server_check.py | 308 +++++++++++++++++------------------- tools/debug/server_check.sh | 7 +- 2 files changed, 145 insertions(+), 170 deletions(-) diff --git a/tools/debug/server_check.py b/tools/debug/server_check.py index d39eda417d..a24abc3b73 100644 --- a/tools/debug/server_check.py +++ b/tools/debug/server_check.py @@ -1,164 +1,144 @@ -# Copyright (c) 2019 - now, Eggroll Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -import re -import os -import sys -import json -import time -import socket -import psutil -import datetime -import threading -import argparse -import subprocess -from eggroll.core.session import ErSession -from eggroll.roll_pair.roll_pair import RollPairContext -from eggroll.utils.log_utils import get_logger - -L = get_logger() - -arg_parser = argparse.ArgumentParser() -arg_parser.add_argument("-t","--time", type=int, help="Sleep time wait, default value 0s", default=0) -arg_parser.add_argument("-n","--nodes", type=int, help="Eggroll session processors per node, default value 1", default=1) -arg_parser.add_argument("-p","--partitions", type=int, help="Total partitions, default value 1", default=1) -arg_parser.add_argument("-d","--partyid", type=int, help="host partyid", default=0) -args = arg_parser.parse_args() - -def str_generator(include_key=True, row_limit=10, key_suffix_size=0, value_suffix_size=0): - for i in range(row_limit): - if include_key: - yield str(i) + "s"*key_suffix_size, str(i) + "s"*value_suffix_size - else: - yield str(i) + "s"*value_suffix_size - -def round2(x): - return str(round(x / 1024 / 1024 / 1024, 2)) - -def print_red(str): - print("\033[1;31;40m\t" + str + "\033[0m") - -def print_green(str): - print("\033[1;32;40m\t" + str + "\033[0m") - -def print_yellow(str): - print("\033[1;33;40m\t" + str + "\033[0m") - -def check_actual_max_threads(): - def getMemInfo(fn): - def query_cmd(cmd): - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0].decode().strip().split('\n') - return p[0] - - def get_host_ip(): - try: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect(('8.8.8.8', 80)) - ip = s.getsockname()[0] - finally: - s.close() - return ip - fate_flow_client = "/data/projects/fate/python/fate_flow/fate_flow_client.py" - mem_info = {} - mem_info["Ip"] = get_host_ip() - eggroll_home = query_cmd("echo $EGGROLL_HOME") - route_file = eggroll_home + "/conf/route_table.json" - f = open(route_file, encoding='utf-8') - mem_info["route_table"] = json.load(f) - mem_info["data_access"] = query_cmd("ps aux |grep data_access_server |grep -v grep |wc -l") - if args.partyid != 0: - mem_info["data_test"] = query_cmd("curl -X POST --header 'Content-Type: application/json' -d '{\"local\": {\"role\": \"host\", \"party_id\": %s}, \"id_type\":\"phone\", \"encrypt_type\":\"md5\"}' 'http://127.0.0.1:9350/v1/data/query_imported_id_library_info'" %(args.partyid)) - mem_info["data_num"] = mem_info["data_test"].split(':')[-1].split('}')[0] - mem_info["directory"] = query_cmd("if [ -d /data/projects/fdn/FDN-DataAcces ];then echo 1; else echo 0; fi") - mem_info["services"] = ['ClusterManagerBootstrap','NodeManagerBootstrap','rollsite','fate_flow_server.py','fateboard','mysql'] - mem_info["job_run"] = query_cmd("if [ -f %s ];then python %s -f query_job -s running | grep f_job_id |wc -l; else echo -1; fi" %(fate_flow_client,fate_flow_client)) - mem_info["job_wait"] = query_cmd("if [ -f %s ];then python %s -f query_job -s waiting | grep f_job_id |wc -l; else echo -1; fi" %(fate_flow_client,fate_flow_client)) - mem_info["job_thread"] = [] - mem_info["jobs"] = query_cmd("array=(`python %s -f query_job -s running | grep f_job_id |awk -F: '{print $2}' |awk -F '\"' '{print $2}'`);echo ${array[@]}" %(fate_flow_client)) - mem_info["job_mem"] = [] - for job_id in mem_info["jobs"]: - mem_info["job_thread"] = query_cmd("ps -ef |grep egg_pair |grep -v grep |grep %s |wc -l" %(job_id)) - mem_info["job_mem"] = query_cmd("ps aux |grep egg_pair |grep %s |awk '{sum+=$6};END {print sum}'" %(job_id)) - mem_info["server_mem"] = {} - mem_info["thread"] = {} - for service in mem_info["services"]: - mem_info["thread"][service] = query_cmd("ps -ef |grep %s |grep -v grep |wc -l" %(service)) - mem_info["server_mem"][service] = str(query_cmd("ps aux |grep %s |grep -v grep |awk '{sum+=$6};END {print sum}'" %(service))) - return mem_info - - session = ErSession(options={"eggroll.session.processors.per.node": args.nodes}) - try: - ctx = RollPairContext(session) - rp = ctx.parallelize(str_generator(row_limit=1000), options={'total_partitions': args.partitions}) - result = rp.with_stores(func=getMemInfo) - print_green(str(datetime.datetime.now())) - for node in result: - print_green("==============This is node " + str(node[0]) + ":" + node[1]["Ip"] + "===========================================") - print_green("-------------default route check-------------------------------------------------------") - route_table_dict = node[1]["route_table"] - if 'default' not in route_table_dict['route_table']: - print_red("[ERROR] eggroll exchange route is not configured, please check data/projects/fate/eggroll/conf/route_table.json file if it is existed!") - else: - try: - ip = route_table_dict['route_table']['default']['default'][0]['ip'] - port = route_table_dict['route_table']['default']['default'][0]['port'] - print_green("[OK] eggroll route configured!") - print_green("exchange ip:{}, exchange port:{}".format(ip, port)) - except KeyError: - print_red("[ERROR] eggroll exchange route is not configured, please check data/projects/fate/eggroll/conf/route_table.json file if it is existed!") - - print_green("--------------data_access service check-------------------------------------------------") - if int(node[1]["data_access"]) == 0: - if int(node[1]["directory"]) == 0: - print_red("[ERROR] data_access service and directory not found, please check if it is installed!") - else: - print_yellow("[WARNING] data_access not running or check /data/projects/fdn/FDN-DataAcces directory") - else: - print_green("[OK] Installed and running data_access service!") - if args.partyid != 0: - if int(node[1]["data_num"]) == 0 or int(node[1]["data_num"]) == 201: - print_green("[OK] Route verification success!") - else: - print_yellow("[WARNING] data_access service not available, please check host and host route!") - - print_green("--------------fate service check-------------------------------------------------------") - for server in node[1]["services"]: - if int(node[1]["thread"][server]) > 0: - print_green("[OK] the " + server.ljust(23) + " service is running , number of processes is : " + str(node[1]["thread"][server]) + "; used memory : " + str(node[1]["server_mem"][server]) + "KB.") - else: - print_yellow("[WARNING] the " + server + " service not running, please check service status.") - - print_green("--------------fate_flow jobs process and mem info check--------------------------------------------------") - if int(node[1]["job_run"]) == -1: - print_red("[ERROR] There is no such fate_flow_client.py file, please check fate_flow server if it is running!") - else: - print_green("[OK] Number of tasks running is " + node[1]["job_run"]) - print_green("[OK] Number of tasks waiting is " + node[1]["job_wait"]) - if int(node[1]["job_run"]) > 0: - for job_id in node[1]["jobs"].split(" "): - print_green("[OK] running task job_id : " + job_id + ", number of egg_pair processes is : " + str(node[1]["job_thread"]) + "; used memory : " + str(node[1]["job_mem"]) + "KB.") - - print("\n") - finally: - session.kill() - - -if __name__ == '__main__': - if args.time == 0: - check_actual_max_threads() - else: - while 1: - check_actual_max_threads() - time.sleep(args.time) +# Copyright (c) 2019 - now, Eggroll Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +import re +import os +import sys +import json +import time +import socket +import psutil +import datetime +import threading +import argparse +import subprocess +from eggroll.core.session import ErSession +from eggroll.roll_pair.roll_pair import RollPairContext +from eggroll.utils.log_utils import get_logger + +L = get_logger() + +arg_parser = argparse.ArgumentParser() +arg_parser.add_argument("-t","--time", type=int, help="Sleep time wait, default value 0s", default=0) +arg_parser.add_argument("-n","--nodes", type=int, help="Eggroll session processors per node, default value 1", default=1) +arg_parser.add_argument("-p","--partitions", type=int, help="Total partitions, default value 1", default=1) +args = arg_parser.parse_args() + +def str_generator(include_key=True, row_limit=10, key_suffix_size=0, value_suffix_size=0): + for i in range(row_limit): + if include_key: + yield str(i) + "s"*key_suffix_size, str(i) + "s"*value_suffix_size + else: + yield str(i) + "s"*value_suffix_size + +def round2(x): + return str(round(x / 1024 / 1024 / 1024, 2)) + +def print_red(str): + print("\033[1;31;40m\t" + str + "\033[0m") + +def print_green(str): + print("\033[1;32;40m\t" + str + "\033[0m") + +def print_yellow(str): + print("\033[1;33;40m\t" + str + "\033[0m") + +def check_actual_max_threads(): + def getMemInfo(fn): + def query_cmd(cmd): + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0].decode().strip().split('\n') + return p[0] + + def get_host_ip(): + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect(('8.8.8.8', 80)) + ip = s.getsockname()[0] + finally: + s.close() + return ip + fate_flow_client = "/data/projects/fate/python/fate_flow/fate_flow_client.py" + mem_info = {} + mem_info["Ip"] = get_host_ip() + eggroll_home = query_cmd("echo $EGGROLL_HOME") + route_file = eggroll_home + "/conf/route_table.json" + f = open(route_file, encoding='utf-8') + mem_info["route_table"] = json.load(f) + mem_info["services"] = ['ClusterManagerBootstrap','NodeManagerBootstrap','rollsite','fate_flow_server.py','fateboard','mysql'] + mem_info["job_run"] = query_cmd("if [ -f %s ];then python %s -f query_job -s running | grep f_job_id |wc -l; else echo -1; fi" %(fate_flow_client,fate_flow_client)) + mem_info["job_wait"] = query_cmd("if [ -f %s ];then python %s -f query_job -s waiting | grep f_job_id |wc -l; else echo -1; fi" %(fate_flow_client,fate_flow_client)) + mem_info["job_thread"] = [] + mem_info["jobs"] = query_cmd("array=(`python %s -f query_job -s running | grep f_job_id |awk -F: '{print $2}' |awk -F '\"' '{print $2}'`);echo ${array[@]}" %(fate_flow_client)) + mem_info["job_mem"] = [] + for job_id in mem_info["jobs"]: + mem_info["job_thread"] = query_cmd("ps -ef |grep egg_pair |grep -v grep |grep %s |wc -l" %(job_id)) + mem_info["job_mem"] = query_cmd("ps aux |grep egg_pair |grep %s |awk '{sum+=$6};END {print sum}'" %(job_id)) + mem_info["server_mem"] = {} + mem_info["thread"] = {} + for service in mem_info["services"]: + mem_info["thread"][service] = query_cmd("ps -ef |grep %s |grep -v grep |wc -l" %(service)) + mem_info["server_mem"][service] = str(query_cmd("ps aux |grep %s |grep -v grep |awk '{sum+=$6};END {print sum}'" %(service))) + return mem_info + + session = ErSession(options={"eggroll.session.processors.per.node": args.nodes}) + try: + ctx = RollPairContext(session) + rp = ctx.parallelize(str_generator(row_limit=1000), options={'total_partitions': args.partitions}) + result = rp.with_stores(func=getMemInfo) + print_green(str(datetime.datetime.now())) + for node in result: + print_green("==============This is node " + str(node[0]) + ":" + node[1]["Ip"] + "===========================================") + print_green("-------------default route check-------------------------------------------------------") + route_table_dict = node[1]["route_table"] + if 'default' not in route_table_dict['route_table']: + print_red("[ERROR] eggroll exchange route is not configured, please check data/projects/fate/eggroll/conf/route_table.json file if it is existed!") + else: + try: + ip = route_table_dict['route_table']['default']['default'][0]['ip'] + port = route_table_dict['route_table']['default']['default'][0]['port'] + print_green("[OK] eggroll route configured!") + print_green("exchange ip:{}, exchange port:{}".format(ip, port)) + except KeyError: + print_red("[ERROR] eggroll exchange route is not configured, please check data/projects/fate/eggroll/conf/route_table.json file if it is existed!") + + print_green("--------------fate service check-------------------------------------------------------") + for server in node[1]["services"]: + if int(node[1]["thread"][server]) > 0: + print_green("[OK] the " + server.ljust(23) + " service is running , number of processes is : " + str(node[1]["thread"][server]) + "; used memory : " + str(node[1]["server_mem"][server]) + "KB.") + else: + print_yellow("[WARNING] the " + server + " service not running, please check service status.") + + print_green("--------------fate_flow jobs process and mem info check--------------------------------------------------") + if int(node[1]["job_run"]) == -1: + print_red("[ERROR] There is no such fate_flow_client.py file, please check fate_flow server if it is running!") + else: + print_green("[OK] Number of tasks running is " + node[1]["job_run"]) + print_green("[OK] Number of tasks waiting is " + node[1]["job_wait"]) + if int(node[1]["job_run"]) > 0: + for job_id in node[1]["jobs"].split(" "): + print_green("[OK] running task job_id : " + job_id + ", number of egg_pair processes is : " + str(node[1]["job_thread"]) + "; used memory : " + str(node[1]["job_mem"]) + "KB.") + + print("\n") + finally: + session.kill() + + +if __name__ == '__main__': + if args.time == 0: + check_actual_max_threads() + else: + while 1: + check_actual_max_threads() + time.sleep(args.time) diff --git a/tools/debug/server_check.sh b/tools/debug/server_check.sh index 56cc20416c..78e7d3734a 100644 --- a/tools/debug/server_check.sh +++ b/tools/debug/server_check.sh @@ -20,13 +20,8 @@ touch result_server.log fi nodes=$1 -party=$2 LogLevel=$EGGROLL_LOG_LEVEL export EGGROLL_LOG_LEVEL=INFO -if [ -n "$party" ];then - python server_check.py -p $nodes -d $party >> result_server.log -else - python server_check.py -p $nodes >> result_server.log -fi +python server_check.py -p $nodes >> result_server.log export EGGROLL_LOG_LEVEL=$LogLevel echo "Check the result in the current directory, Please execute command: cat result_server.log" From 630e9641cf904dc62955fe5e5d196cac2d9a30dc Mon Sep 17 00:00:00 2001 From: easongao <46415758+easson001@users.noreply.github.com> Date: Thu, 24 Sep 2020 17:15:53 +0800 Subject: [PATCH 3/3] Add files via upload fix bug about delete data access checking --- ...\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" "b/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" index f3cbe58f1a..d9384247a8 100644 --- "a/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" +++ "b/tools/debug/\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" @@ -161,7 +161,7 @@ python time_check.py -t {检测间隔秒数,不填只检测一次} ------ -检测fate运行信息:eggroll路由是不是默认路由、是否已安装data access、fate服务的运行状态、进程数及占用内存情况、当前环境正在运行及等待的job任务数、job任务有多少进程及占用的内存情况。 +检测fate运行信息:eggroll路由是不是默认路由、fate服务的运行状态、进程数及占用内存情况、当前环境正在运行及等待的job任务数、job任务有多少进程及占用的内存情况。 ### 3.3 使用方法