diff --git a/main.c b/main.c index edb3100..729dea2 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include "src/init.h" #include "src/server.h" +#include "src/MonitorProcess.h" #include #include #include @@ -11,14 +12,10 @@ int main() { //init //get /data/data/dir //get whitelist - // + //init Proc_List + printf("%ld",Proc_List[0].pid); init(); - //test - char buf[80]; - getcwd(buf, sizeof(buf)); - printf("current working directory: %s\n", buf); - //server rc = pthread_create(&unix_domain_server, NULL, (void *)&server, NULL); if (rc != 0) { diff --git a/src/MonitorProcess.c b/src/MonitorProcess.c index 2d044cf..9a277a5 100644 --- a/src/MonitorProcess.c +++ b/src/MonitorProcess.c @@ -12,6 +12,10 @@ #define STAT_VSZ 22 #define STAT_RSS 23 +extern int Proc_List_Free_ID; +extern int Proc_List_ID; +extern Proc_Info Proc_List[64]; //max monitor 64 process + //update process cpu time and mem info by /proc/PID/stat //example: 1 (systemd) S 0 1 1 0 -1 4194560 16465 675919 50 519 44 100 678 258 20 0 1 0 13 44421120 1253 18446744073709551615 94869015482368 94869016924823 140724538057904 0 0 0 671173123 4096 1260 1 0 0 17 0 0 0 14 0 0 94869019025816 94869019170360 94869036843008 140724538064796 140724538064863 140724538064863 140724538064863 0 /* pid 进程ID 0 diff --git a/src/MonitorProcess.h b/src/MonitorProcess.h index 2751d32..9a52c1f 100644 --- a/src/MonitorProcess.h +++ b/src/MonitorProcess.h @@ -25,14 +25,14 @@ typedef struct Proc_Info_ { Proc_Mem memInfo[30]; } Proc_Info; -int Proc_List_Free_ID = 0; -int Proc_List_ID = 0; -Proc_Info Proc_List[64]; //max monitor 64 process - //kill this process void findProcListByMem(); //kill this process void findProcListByCPU(); +int Proc_List_Free_ID; +int Proc_List_ID; +Proc_Info Proc_List[64]; //max monitor 64 process + #endif //ATOP_MONITORPROCESS_H