From 78de56b9f2d862bbdac8a02a72dd95500b7ef83e Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Mon, 5 Aug 2024 16:59:51 +0800 Subject: Try t use coroutine, but starvation --- src/global.go | 59 ++++++++++++----------------------------------------------- 1 file changed, 12 insertions(+), 47 deletions(-) (limited to 'src/global.go') diff --git a/src/global.go b/src/global.go index a266b1b..b6635c9 100644 --- a/src/global.go +++ b/src/global.go @@ -1,11 +1,8 @@ package main import ( - "fmt" "sync" "time" - - "go.mongodb.org/mongo-driver/bson/primitive" ) type eventType int @@ -29,50 +26,18 @@ func (et eventType) String() string { } type Event struct { - tag eventType - timestamp time.Time - pid, ppid int - syscall int - syscallParam [4]uint64 - pathName string - argc int - argv []string - cwd string - exit_code uint64 - exit_signal int -} - -func (event Event) String() string { - var res string - res = fmt.Sprintf("tag: %v\ntimestamp: %v\nppid: %d\npid: %d\n", event.tag, event.timestamp.Local(), event.ppid, event.pid) - res += fmt.Sprintf("syscall: %s\nexit_code: %d\nargs: \n", syscallTable[event.syscall], event.exit_code) - for i := 0; i < len(event.argv); i++ { - res += fmt.Sprintf("\t\"%s\"\n", event.argv[i]) - } - res += "syscallParam: " - for i := 0; i < len(event.syscallParam); i++ { - res += fmt.Sprintf("\t\"%d\"\n", event.syscallParam[i]) - } - res += "pathName: \"" + event.pathName + "\"\n------\n" - return res -} - -type pidExec struct { - timestamp time.Time `bson:"timestamp"` - execArgs []string `bson:"execArgs"` -} - -type pid struct { - ID primitive.ObjectID `bson:"_id,ometempty"` - start_timestamp time.Time `bson:"start_timestamp"` - ppid int `bson:"ppid"` - pid int `bson:"pid"` - cwd string `bson:"cwd"` - args []string `bson:"args"` - execve []pidExec `bson:"execve"` - children []int `bson:"children"` - exit_timestamp time.Time `bson:"exit_timestamp"` - exit_code uint64 `bson:"exit_code"` + tag eventType + timestamp time.Time + pid, tgid int + ppid, parentTgid int + syscall int + syscallParam [4]uint64 + pathName string + argc int + argv []string + cwd string + exit_code uint64 + exit_signal int } var wg sync.WaitGroup // 掌管协程 -- cgit v1.2.3-70-g09d2