Skip to content

Commit

Permalink
MagicEyes下面增加可视化软连接
Browse files Browse the repository at this point in the history
  • Loading branch information
albertxu216 committed Jan 17, 2025
1 parent f522a54 commit 0d473ae
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 2,025 deletions.
1 change: 1 addition & 0 deletions MagicEyes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ endif ()
add_subdirectory(src/backend)
add_subdirectory(src/bridge)
add_subdirectory(src/magic_eyes_cli)
add_subdirectory(src/visualization)
57 changes: 37 additions & 20 deletions MagicEyes/src/visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ cmake_minimum_required(VERSION 3.10)

# 定义项目名称
project(DataVisual LANGUAGES NONE)
#目标目录,install/visualization
set(VISUALIZATION_INSTALL_DIR visualization)
# 定义变量 A
set(EBPF_PROMETHEUS ${CMAKE_CURRENT_SOURCE_DIR}/eBPF_prometheus)

# 定义工作目录变量
set(WORK_DIR "${CMAKE_BINARY_DIR}/src/visualization")

# 确保工作目录存在
file(MAKE_DIRECTORY ${WORK_DIR})

# 直接执行命令:go mod tidy
execute_process(
COMMAND go mod tidy
WORKING_DIRECTORY ${WORK_DIR} # 设置工作目录为 ${CMAKE_BINARY_DIR}/data-visual
WORKING_DIRECTORY ${EBPF_PROMETHEUS}
RESULT_VARIABLE GO_MOD_TIDY_RESULT
OUTPUT_VARIABLE GO_MOD_TIDY_OUTPUT
ERROR_VARIABLE GO_MOD_TIDY_ERROR
Expand All @@ -24,34 +23,52 @@ endif()

# 直接执行命令:go build
execute_process(
COMMAND go build -o ${WORK_DIR}/data-visual main.go
WORKING_DIRECTORY ${WORK_DIR}
COMMAND go build -o ${EBPF_PROMETHEUS}/data-visual main.go
WORKING_DIRECTORY ${EBPF_PROMETHEUS}
RESULT_VARIABLE GO_BUILD_RESULT
OUTPUT_VARIABLE GO_BUILD_OUTPUT
ERROR_VARIABLE GO_BUILD_ERROR
)
if(NOT GO_BUILD_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to build 'data-visual': ${GO_BUILD_ERROR}")
endif()

#将生成的data-visual可执行文件 安装到install/visualization目录下
install(PROGRAMS ${EBPF_PROMETHEUS}/data-visual
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION ${VISUALIZATION_INSTALL_DIR}
)
#将checker,collector,dao,prom_core安装到安装到install/visualization目录下
install(DIRECTORY ${EBPF_PROMETHEUS}/checker
${EBPF_PROMETHEUS}/dao
${EBPF_PROMETHEUS}/prom_core
DESTINATION ${VISUALIZATION_INSTALL_DIR}
)
# 创建目录并生成文件
file(MAKE_DIRECTORY ${WORK_DIR}/.output/data)
file(WRITE ${WORK_DIR}/.output/data/offcpu_stack.txt "")
file(MAKE_DIRECTORY ${VISUALIZATION_INSTALL_DIR}/.output/data)
file(WRITE ${VISUALIZATION_INSTALL_DIR}/.output/data/offcpu_stack.txt "")

# 直接执行脚本:runimages.sh

# 安装脚本文件 runimages.sh 到指定目录,并设置安装后的权限
install(PROGRAMS ${EBPF_PROMETHEUS}/runimages.sh
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION ${VISUALIZATION_INSTALL_DIR}
)
# 执行脚本:runimages.sh
execute_process(
COMMAND ./runimages.sh
WORKING_DIRECTORY ${WORK_DIR}
RESULT_VARIABLE RUN_IMAGES_RESULT
OUTPUT_VARIABLE RUN_IMAGES_OUTPUT
ERROR_VARIABLE RUN_IMAGES_ERROR
WORKING_DIRECTORY ${VISUALIZATION_INSTALL_DIR}
RESULT_VARIABLE RUNIMAGES_RESULT
OUTPUT_VARIABLE RUNIMAGES_OUTPUT
ERROR_VARIABLE RUNIMAGES_ERROR
)
# 将vis.sh安装到目标目录
install(PROGRAMS ${EBPF_PROMETHEUS}/vis.sh
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION ${VISUALIZATION_INSTALL_DIR}
)
if(NOT RUN_IMAGES_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to run 'runimages.sh': ${RUN_IMAGES_ERROR}")
endif()

# 清理目标:可选
add_custom_target(clean_data
COMMAND ${CMAKE_COMMAND} -E rm -rf ${WORK_DIR}/dao/data.db ${WORK_DIR}/.output/data
COMMAND ${CMAKE_COMMAND} -E rm -rf ${EBPF_PROMETHEUS}/dao/data.db ${EBPF_PROMETHEUS}/r/.output/data
COMMENT "Cleaning up generated data and files"
)
12 changes: 0 additions & 12 deletions MagicEyes/src/visualization/Makefile

This file was deleted.

166 changes: 0 additions & 166 deletions MagicEyes/src/visualization/checker/check.go

This file was deleted.

Loading

0 comments on commit 0d473ae

Please sign in to comment.