-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'linuxkerneltravel:develop' into develop
- Loading branch information
Showing
41 changed files
with
1,573 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
set(MAGIC_EYES_CLI_INSTALL_DIR magic_eyes_cli) | ||
|
||
# 安装 MagicEyesCli 到 <intsall_dir>/sbin/ | ||
|
||
# 安装magic_eyes_cli文件夹到 <install_dir>/sbin/ | ||
|
||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
DESTINATION ${MAGIC_EYES_CLI_INSTALL_DIR} | ||
) | ||
|
||
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/magic_eyes_cli | ||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE | ||
DESTINATION ${MAGIC_EYES_CLI_INSTALL_DIR}) | ||
|
||
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/before_running.sh | ||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE | ||
DESTINATION ${MAGIC_EYES_CLI_INSTALL_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## magic_eyes_cli 命令行前端 | ||
|
||
### 1. 简述 | ||
|
||
将所有的后端工具统一到一个命令行前端,并且具备自动补全功能。 | ||
|
||
Tips:**记得Tab** | ||
|
||
### 2. 使用之前 | ||
|
||
```bash | ||
mkdir build && cd build | ||
cmake .. && make && make install | ||
cd ./install/magic_eyes_cli | ||
# 运行前置条件脚本 | ||
source ./before_running.sh | ||
``` | ||
|
||
### 3. 使用 | ||
|
||
```bash | ||
(venv) $ ./magic_eyes_cli -h | ||
/home/fzy/Downloads/04_bcc_ebpf/MagicEyes | ||
usage: magic_eyes_cli [-h] [-l | -c] {net,memory,system_diagnosis,process} ... | ||
|
||
magic_eyes_cli: command tools for Linux kernel diagnosis and optimization | ||
|
||
positional arguments: | ||
{net,memory,system_diagnosis,process} | ||
net tool for Linux net subsystem | ||
memory tool for Linux memory subsystem | ||
system_diagnosis tool for Linux system_diagnosis subsystem | ||
process tool for Linux process subsystem | ||
|
||
optional arguments: | ||
-h, --help show this help message and exit | ||
|
||
all of common options: | ||
-l list all avaliable tools | ||
-c check all tools dependency, and whether it can be run in current platform | ||
|
||
eg: magic_eyes_cli -l | ||
``` | ||
|
||
**固定命令** | ||
|
||
magic_eyes_cli具有2个固定命令, 即 | ||
|
||
```bash | ||
-l : 即list, 列出所有可用的后端命令 | ||
-c : 即check, 检查所有运行依赖项(暂未实现) | ||
``` | ||
|
||
**动态命令** | ||
|
||
{net,memory,system_diagnosis,process}为动态命令,会根据backend文件夹下的情况动态调整。 | ||
|
||
### 4. 例程 | ||
|
||
```bash | ||
magic_eyes_cli process cpu_watcher -h | ||
# <------------------ 自动补全 | 非自动补全 | ||
``` | ||
|
||
### 5.其他 | ||
|
||
```bash | ||
# 生成requirements.txt | ||
pip3 freeze > requirements.txt | ||
# 安装 | ||
pip3 install -r requiredments.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 后端工具描述脚本存放文件夹 | ||
|
||
1. 每个后端工具均有一个后端工具描述脚本 | ||
1. 描述后端工具名称 | ||
2. 描述后端工具依赖项,如内核配置选项,某些需要下载的依赖等 | ||
3. 原始文件请存放在各自工具文件夹的scripts中,在此文件夹创建软链接 | ||
|
19 changes: 19 additions & 0 deletions
19
MagicEyes/src/magic_eyes_cli/backend_tool_modules/cpu_watcher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
方案2: 采用后端工具描述文件,后续读取该文件,尤其是其中的依赖项, | ||
并使用 magic_eyes_cli check 进行运行环境检查 | ||
描述: | ||
1. 工具名,所属子系统 | ||
2. 工具的简要描述 | ||
3. 是否具有运行依赖项,依赖项是什么? | ||
""" | ||
|
||
class CpuWatcher(): | ||
def __init__(self): | ||
self.tool_name = "cpu_watcher" | ||
self.belong_to_subsystem = "process" | ||
self.description = "A tool for analyzing CPU running status" | ||
self.dependencies = { | ||
""" 工具运行的依赖项 """ | ||
} | ||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
MAGIC_EYES_CLI_INSTALL_DIR=$(dirname $(realpath $0)) | ||
|
||
check_conditions() { | ||
# 判断python3是否存在 | ||
if /usr/bin/env python3 -V > /dev/null; then | ||
echo "python 已安装" | ||
else | ||
echo "python 未安装" | ||
return 1 | ||
fi | ||
# 进入python venv环境 | ||
if . ./venv/bin/activate; then | ||
echo "成功进入venv环境" | ||
else | ||
echo "进入venv环境失败" | ||
return 1 | ||
fi | ||
# 使用pip列出所有已安装的包,并搜索argcomplete,判断是否argcomplete是否存在 | ||
if pip list --verbose | grep -q "argcomplete"; then | ||
echo "argcomplete 已经安装." | ||
else | ||
echo "argcomplete 未安装." | ||
echo "尝试安装argcomplete" | ||
pip3 install -r ./requirements.txt | ||
if pip list --verbose | grep -q "argcomplete"; then | ||
echo "argcomplete安装完成" | ||
else | ||
return 1 | ||
fi | ||
fi | ||
# 注册 magic_eyes_cli | ||
if eval "$(register-python-argcomplete ./magic_eyes_cli)"; then | ||
echo "magic_eyes_cli注册成功" | ||
else | ||
echo "magic_eyes_cli注册失败" | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
# 调用函数并获取返回值 | ||
check_conditions | ||
exit_status=$? | ||
# 根据返回值输出最终结果 | ||
if [ $exit_status -eq 0 ]; then | ||
echo "OK" | ||
else | ||
echo "条件不满足" | ||
fi | ||
|
||
|
||
|
||
|
||
|
Empty file.
Oops, something went wrong.