diff --git a/source/sysak.c b/source/sysak.c index 79df78882871bb163e01fd897a399cda35da6856..f0dc3fc3f8b7f931160f32dd5f0229b5ef0391e4 100644 --- a/source/sysak.c +++ b/source/sysak.c @@ -9,8 +9,9 @@ #define KVERSION 64 #define MAX_SUBCMD_ARGS 512 +#define MAX_DEPEND_LEN 128 #define MAX_NAME_LEM 64 -#define MAX_WORK_PATH_LEN 256 +#define MAX_WORK_PATH_LEN 512 #define ERR_NOSUBTOOL 2 #define ERR_MISSARG 3 @@ -24,9 +25,11 @@ char *system_modules = "/proc/modules"; char *bin_path = "/usr/local/sbin"; char kern_version[KVERSION]; -char modin[MAX_SUBCMD_ARGS]; -char modun[MAX_SUBCMD_ARGS]; +char modin[MAX_DEPEND_LEN]; +char modun[MAX_DEPEND_LEN]; +char run_depend[MAX_DEPEND_LEN]= {0}; char tools_path[MAX_WORK_PATH_LEN]; +char tools_exec[MAX_WORK_PATH_LEN] = {0}; char sysak_rule[MAX_WORK_PATH_LEN]; char module_path[MAX_WORK_PATH_LEN]; char sysak_work_path[MAX_WORK_PATH_LEN]; @@ -49,7 +52,7 @@ static void kern_release(void) struct utsname name; if (uname (&name) == -1){ - printf("cannot get system name\n"); + printf("cannot get system version\n"); return; } strncpy(kern_version, name.release, sizeof(name.release)); @@ -90,6 +93,16 @@ static void mod_ctrl(bool enable) system(exec_mod); } } +static void add_python_depend(char *depend,char *cmd) +{ + if (!strcmp(depend, "all")){ + snprintf(tools_exec, sizeof(tools_exec), "python2 %s", cmd); + }else if (!strcmp(depend, "python3")){ + snprintf(tools_exec, sizeof(tools_exec), "python3 %s", cmd); + }else if(!strcmp(depend, "python2")){ + snprintf(tools_exec, sizeof(tools_exec), "python2 %s", cmd); + } +} static int exectue(int argc, char *argv[]) { @@ -111,7 +124,13 @@ static int exectue(int argc, char *argv[]) snprintf(subcmd_args, sizeof(subcmd_args), " \"%s\"", argv[i]); strcat(subcmd_name,subcmd_args); } - snprintf(subcmd_exec_final, sizeof(subcmd_exec_final), "%s;%s", sysak_work_path, subcmd_name); + + if (run_depend[0]) + add_python_depend(run_depend, subcmd_name); + else + strncpy(tools_exec,subcmd_name,strlen(subcmd_name)); + + snprintf(subcmd_exec_final, sizeof(subcmd_exec_final), "%s;%s", sysak_work_path, tools_exec); ret = system(subcmd_exec_final); if (post_module) @@ -170,9 +189,9 @@ static bool tool_lookup(char *path, char *tool) if (strcmp(tools_name, tool)){ continue; } - - sscanf(buf,"%*[^:]:prev{%[^}]};post{%[^}]}", modin, modun); - fclose(fp); + sscanf(buf,"%*[^:]:prev{%[^}]};post{%[^}]};python-dep{%[^}]}", modin, modun, run_depend); + if (!run_depend[0]) + sscanf(buf,"%*[^:]:python-dep{%[^}]}", run_depend); return true; } fclose(fp); diff --git a/source/tools/detect/fcachetop/Makefile b/source/tools/detect/fcachetop/Makefile index 8307f4c6399549dfc926bc90d31b6a7c4ca264e1..96d8a30e70e4a446b32658e0dc730239568fcc45 100644 --- a/source/tools/detect/fcachetop/Makefile +++ b/source/tools/detect/fcachetop/Makefile @@ -1,3 +1,3 @@ target := fcachetop - +DEPEND := "python-dep{python2}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/iofsstat/Makefile b/source/tools/detect/iofsstat/Makefile index 2594a7036a507dab5d4104c62710c50dcfd427a9..a3b36ba7a9551bba01b95e5e5d8d85d6a33c5a2c 100644 --- a/source/tools/detect/iofsstat/Makefile +++ b/source/tools/detect/iofsstat/Makefile @@ -1,3 +1,3 @@ target := iofsstat - +DEPEND := "python-dep{all}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/memgraph/Makefile b/source/tools/detect/memgraph/Makefile index f7742f316a96a956b8e371a8c08ce5e04f0697b8..44583c5e3143ffbac289c2b8bea55e099d64337e 100644 --- a/source/tools/detect/memgraph/Makefile +++ b/source/tools/detect/memgraph/Makefile @@ -1,4 +1,5 @@ target := memgraph mods := memgraph +DEPEND := "python-dep{python3}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/netinfo/Makefile b/source/tools/detect/netinfo/Makefile index 70f265f8969bfa98ea513654973da4c130bc9714..75b8727c80a08f1faa34238a60cb63b8da3a035c 100644 --- a/source/tools/detect/netinfo/Makefile +++ b/source/tools/detect/netinfo/Makefile @@ -1,3 +1,3 @@ target := netinfo -DEPEND := "prev{default python};" +DEPEND := "python-dep{python3}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/oomcheck/Makefile b/source/tools/detect/oomcheck/Makefile index 198f550618be15305150b83fda34bc2eccc07c8d..7dda4b7845887d3cf14eed7789fed4aa1672f23f 100644 --- a/source/tools/detect/oomcheck/Makefile +++ b/source/tools/detect/oomcheck/Makefile @@ -1,4 +1,5 @@ target := oomcheck mods := oomcheck +DEPEND := "python-dep{python2}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/runqlen/Makefile b/source/tools/detect/runqlen/Makefile index 17b0b8425a8c0d8a22871b12fd2488537f2482a8..35726a4b797b803347f2df630396cad2a3de995a 100644 --- a/source/tools/detect/runqlen/Makefile +++ b/source/tools/detect/runqlen/Makefile @@ -1,4 +1,4 @@ target := runqlen -DEPEND := "prev{default python};" +DEPEND := "prev{default};python-dep{all}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/skcheck/Makefile b/source/tools/detect/skcheck/Makefile index fa19a290b1515db138ce81fb819c37b008dc6af1..1761a98a1b8dbd234ac61d03c44a3d9b7cbc39f4 100644 --- a/source/tools/detect/skcheck/Makefile +++ b/source/tools/detect/skcheck/Makefile @@ -1,4 +1,5 @@ target := skcheck mods := skcheck +DEPEND := "python-dep{python2}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/surftrace/Makefile b/source/tools/detect/surftrace/Makefile index acd7346152803efd15878c2d9bf538e803e594e8..6134cf0937b5fb56029abcbf2f1d041cfc615b95 100644 --- a/source/tools/detect/surftrace/Makefile +++ b/source/tools/detect/surftrace/Makefile @@ -1,3 +1,3 @@ target := surftrace -DEPEND := "prev{default python};" +DEPEND := "prev{default};python-dep{all}" include $(SRC)/mk/py.mk diff --git a/source/tools/detect/sysconf/confcheck/Makefile b/source/tools/detect/sysconf/confcheck/Makefile index 859ba9aab33506d0bf65fe0aaa42e178c20aed03..f19deb9b3386bd4474a6bf7206d3079b2a34edbd 100644 --- a/source/tools/detect/sysconf/confcheck/Makefile +++ b/source/tools/detect/sysconf/confcheck/Makefile @@ -1,5 +1,4 @@ target := confcheck - mods += $(target) - +DEPEND := "python-dep{python2}" include $(SRC)/mk/py.mk diff --git a/source/tools/monitor/mmaptrace/Makefile b/source/tools/monitor/mmaptrace/Makefile index 2a5e73c59a89d1621a53c1feb57bc4f09e1baca2..55ffddc2a24a095c4c63b81c93788afd4ed7deeb 100644 --- a/source/tools/monitor/mmaptrace/Makefile +++ b/source/tools/monitor/mmaptrace/Makefile @@ -1,5 +1,5 @@ mods := mmaptrace target := mmaptrace -DEPEND := "prev{-p modin};post{-d modun}" +DEPEND := "prev{-p modin};post{-d modun};python-dep{python2}" include $(SRC)/mk/py.mk diff --git a/source/tools/monitor/mon_connect/Makefile b/source/tools/monitor/mon_connect/Makefile index 5f59b00554dbabde4c95ebf635e5999a36396e2d..2f267f4ebbb5e320f6be99b47965d98cbdb4d94f 100644 --- a/source/tools/monitor/mon_connect/Makefile +++ b/source/tools/monitor/mon_connect/Makefile @@ -1,5 +1,4 @@ mods := mon_connect target := mon_connect -DEPEND := "prev{default python};" - +DEPEND := "python-dep{python3}" include $(SRC)/mk/py.mk diff --git a/source/tools/monitor/sched/schedtrace/Makefile b/source/tools/monitor/sched/schedtrace/Makefile index 5a3aff5aa647679dfa6e07e6dbaa2ad98666ebb9..703b511eb40bb1bbd560939bbad3c208326d9822 100644 --- a/source/tools/monitor/sched/schedtrace/Makefile +++ b/source/tools/monitor/sched/schedtrace/Makefile @@ -1,5 +1,4 @@ mods := schedtrace -DEPEND := "prev{-e modin};post{-d modun}" target := schedtrace - +DEPEND := "prev{-e modin};post{-d modun};python-dep{python2}" include $(SRC)/mk/py.mk