Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
chaolihf committed Feb 15, 2024
1 parent 0ff3624 commit b6c2aff
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ logs/agent.log
mock/mock
OneAgent
helloc/hello
**/*.out
10 changes: 1 addition & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
"mode": "local",
"processId": 12302
},
{
"name": "注入命名空间调试",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["--cmd=java","--pid=14835","--p0=threaddump"]
},
{
"name": "独立运行收集器",
"type": "go",
Expand Down Expand Up @@ -80,7 +72,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/jattach.out",
"args": ["18826" ,"threaddump"],
"args": ["106148" ,"threaddump"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# OneAgent
实现操作系统侧主要Promethus采集器的整合
# 1、进展
实现进程、网络链接、脚本采集功能
TODO:实时获取进程启动、退出消息;
1. 实现进程、网络链接、脚本采集功能
2. 可以实现对Java进程(包括其他namespace中的)执行监控等方法
3. 可以通过设置环境变量来进入指定进程的命名空间,并执行指定的命令

4. TODO:实时获取进程启动、退出消息;
实时获取网络链接建立、断开消息、进程级流量的统计;
实时获取Bash执行历史;
实现对Java进程的自动注入;
Expand Down
4 changes: 4 additions & 0 deletions pkg/cgo/setNamespace.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define _GNU_SOURCE
#define __USE_GNU
#include <errno.h>
#include <sched.h>
#include <stdio.h>
Expand All @@ -7,6 +8,9 @@
#include <fcntl.h>
#include <unistd.h>

/**
* 进入命名空间并执行命令
*/
__attribute__((constructor)) void enter_namespace(void) {
char *mydocker_pid;
mydocker_pid = getenv("mydocker_pid");
Expand Down
55 changes: 0 additions & 55 deletions pkg/enterNamespace.go

This file was deleted.

14 changes: 3 additions & 11 deletions pkg/java_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package collector

/*
#include "cgo/jattach.c"
#include "cgo/setNamespace.c"
*/
import "C"

Expand Down Expand Up @@ -79,18 +80,9 @@ func ScanAllProcess() error {
if err != nil {
logger.Log(err.Error())
continue
} else {
logger.Log("INFO", content)
}
// os.Setenv("mydocker_pid", strconv.Itoa(int(pid)))
// os.Setenv("mydocker_cmd", fmt.Sprintf("/OneAgent --cmd=java --p0=threaddump --p1=%d --p2=%d", pid, nsPid))
// //os.Setenv("mydocker_cmd", "ls -l")
// cmd := exec.Command("/proc/self/exe")
// cmd.Stdin = os.Stdin
// cmd.Stdout = os.Stdout
// cmd.Stderr = os.Stderr

// if err := cmd.Run(); err != nil {
// logger.Log(err.Error())
// }
} else {
uids, err := process.Uids()
if err != nil {
Expand Down
Binary file removed setNamespace.out
Binary file not shown.

0 comments on commit b6c2aff

Please sign in to comment.