diff options
| author | 童宗振 <[email protected]> | 2024-04-15 11:13:08 +0000 |
|---|---|---|
| committer | 童宗振 <[email protected]> | 2024-04-15 11:13:08 +0000 |
| commit | 8232dd5a3da45c324f898abf1ef609cf0cda668b (patch) | |
| tree | 7d6e4055bbdd3caf3536fe6e2ffff07be62960a4 | |
| parent | 8842fa8bdfcb3a96b5b1074e4d4ceefdb4199dfc (diff) | |
Add maat test
| -rw-r--r-- | conf/dp_trace.conf | 11 | ||||
| -rw-r--r-- | etc/dp_trace.conf | 21 | ||||
| -rw-r--r-- | etc/dp_trace_dy.conf (renamed from conf/dp_trace_dy.conf) | 2 | ||||
| -rw-r--r-- | etc/dp_trace_zlog.conf (renamed from conf/dp_trace_zlog.conf) | 0 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 19 | ||||
| -rw-r--r-- | src/common.h | 3 | ||||
| -rw-r--r-- | src/config.c | 45 | ||||
| -rw-r--r-- | src/config.h | 10 | ||||
| -rw-r--r-- | src/job_ctx.c | 41 | ||||
| -rw-r--r-- | src/job_ctx.h | 13 | ||||
| -rw-r--r-- | src/maat.c | 186 | ||||
| -rw-r--r-- | src/maat.h | 6 | ||||
| -rw-r--r-- | src/main.c | 7 | ||||
| -rw-r--r-- | src/trace_output.c | 2 | ||||
| -rw-r--r-- | support/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | support/cJSON-1.7.7.tar.gz | bin | 0 -> 345681 bytes | |||
| -rw-r--r-- | test/dp_telemetry_rules.json | 10 | ||||
| -rw-r--r-- | test/table_schema.json | 13 |
18 files changed, 316 insertions, 91 deletions
diff --git a/conf/dp_trace.conf b/conf/dp_trace.conf deleted file mode 100644 index 19d1bda..0000000 --- a/conf/dp_trace.conf +++ /dev/null @@ -1,11 +0,0 @@ -[global] -iocore=4,5,6,7 -zlog_config_path=../conf/dp_trace_zlog.conf -dp_trace_dir=./ -device_group=group-xxg-tsgx - -[kafka] -borker_list="" -topic_name="" -sasl_username="" -sasl_password=""
\ No newline at end of file diff --git a/etc/dp_trace.conf b/etc/dp_trace.conf new file mode 100644 index 0000000..edec63f --- /dev/null +++ b/etc/dp_trace.conf @@ -0,0 +1,21 @@ +[global] +iocore=4,5,6,7 +zlog_config_path=../etc/dp_trace_zlog.conf +dp_trace_dir=./ +device_group= + +[kafka] +borker_list="" +topic_name="" +sasl_username="" +sasl_password="" + +[maat] +# 0:json 1:redis +maat_log_level=0 +maat_input_mode=0 +table_schema=../test/table_schema.json +json_cfg_file=../test/dp_telemetry_rules.json +maat_redis_server= +maat_redis_port_range= +maat_redis_db_index=
\ No newline at end of file diff --git a/conf/dp_trace_dy.conf b/etc/dp_trace_dy.conf index f7d0b67..eb91022 100644 --- a/conf/dp_trace_dy.conf +++ b/etc/dp_trace_dy.conf @@ -13,5 +13,5 @@ snaplen=0 #invalid expr bpf_expr=net 192.168.65.59/0 -[dp_trace_rule:10] +[dp_trace_rule:2] bpf_expr=ip host 172.19.199.171
\ No newline at end of file diff --git a/conf/dp_trace_zlog.conf b/etc/dp_trace_zlog.conf index 25f5047..25f5047 100644 --- a/conf/dp_trace_zlog.conf +++ b/etc/dp_trace_zlog.conf diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72c0038..32f64a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,23 +8,34 @@ set(DP_TELEMETRY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/job_ctx.c ${CMAKE_CURRENT_SOURCE_DIR}/trace_output.c ${CMAKE_CURRENT_SOURCE_DIR}/kafka.c + ${CMAKE_CURRENT_SOURCE_DIR}/maat.c ${CMAKE_CURRENT_SOURCE_DIR}/mocking.c ${CMAKE_SOURCE_DIR}/support/mpack/mpack.c) add_executable(${PROJECT_NAME} ${DP_TELEMETRY_SRC}) -target_link_libraries(${PROJECT_NAME} libmarsio maatframe MESA_prof_load libevent-static rdkafka libcmocka libzlog uuid pthread) +target_link_libraries(${PROJECT_NAME} libmarsio maatframe MESA_prof_load libevent-static rdkafka libcmocka libzlog libcjson uuid pthread) if(ENABLE_DEVELOP_MOCKING) target_link_options(${PROJECT_NAME} PRIVATE -Wl,--wrap=kafka_handle_create,--wrap=kafka_topic_new,--wrap=kafka_produce) endif() add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/conf - ${CMAKE_BINARY_DIR}/conf + ${CMAKE_SOURCE_DIR}/etc + ${CMAKE_BINARY_DIR}/etc COMMENT "copy config file to build directory" ) +add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/test/table_schema.json + ${CMAKE_BINARY_DIR}/test/table_schema.json + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/test/dp_telemetry_rules.json + ${CMAKE_BINARY_DIR}/test/dp_telemetry_rules.json + COMMENT "copy maat config file to build directory" +) + install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT Program) -file(GLOB CONFIG_FILES ${CMAKE_SOURCE_DIR}/conf/*) +file(GLOB CONFIG_FILES ${CMAKE_SOURCE_DIR}/etc/*) install(FILES ${CONFIG_FILES} DESTINATION ${INSTALL_ETC_DIR} COMPONENT Profile)
\ No newline at end of file diff --git a/src/common.h b/src/common.h index 56a5fbf..93e0366 100644 --- a/src/common.h +++ b/src/common.h @@ -5,6 +5,7 @@ #include <assert.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> @@ -23,7 +24,7 @@ #define TELEMETRY_DIM(a) (sizeof(a) / sizeof((a)[0])) -#define CHECK_OR_EXIT(condition, fmt, ...) \ +#define DP_TRACE_VERIFY(condition, fmt, ...) \ do \ { \ if (!(condition)) \ diff --git a/src/config.c b/src/config.c index 1834353..78a9aa8 100644 --- a/src/config.c +++ b/src/config.c @@ -1,7 +1,7 @@ #include "config.h" #include "job_ctx.h" #include <MESA/MESA_prof_load.h> - +#include <MESA/maat.h> #include <errno.h> #include <pthread.h> #include <sched.h> @@ -17,7 +17,7 @@ static struct config * g_conf = NULL; const struct config * config_create(const char * config_path, const char * dy_config_path) { struct config * conf = calloc(1, sizeof(struct config)); - CHECK_OR_EXIT(conf, "calloc failed: %s", strerror(errno)); + DP_TRACE_VERIFY(conf, "calloc failed: %s", strerror(errno)); snprintf(conf->config_path, sizeof(conf->config_path), "%s", config_path); snprintf(conf->dy_config_path, sizeof(conf->dy_config_path), "%s", dy_config_path); @@ -28,7 +28,7 @@ const struct config * config_create(const char * config_path, const char * dy_co const struct config * global_config_get() { - CHECK_OR_EXIT(g_conf, "global config is null."); + DP_TRACE_VERIFY(g_conf, "global config is null."); return g_conf; } @@ -39,27 +39,28 @@ void global_config_destroy() void config_load() { - if (access(g_conf->config_path, R_OK) != 0) + const char * config_path = g_conf->config_path; + if (access(config_path, R_OK) != 0) { - dzlog_error("Configure File %s is not existed. Failed. ", g_conf->config_path); + printf("Configure File(%s) load failed:%s ", config_path, strerror(errno)); exit(EXIT_FAILURE); } CPU_ZERO(&g_conf->cpu_set_io); unsigned int io_cores[MAX_LCORE] = {}; int nr_io_cores = 0; - nr_io_cores = MESA_load_profile_uint_range(g_conf->config_path, "global", "iocore", - sizeof(io_cores) / sizeof(io_cores[0]), io_cores); + nr_io_cores = + MESA_load_profile_uint_range(config_path, "global", "iocore", sizeof(io_cores) / sizeof(io_cores[0]), io_cores); for (unsigned int i = 0; i < nr_io_cores; i++) { CPU_SET(io_cores[i], &g_conf->cpu_set_io); } - MESA_load_profile_string_nodef(g_conf->config_path, "global", "zlog_config_path", g_conf->zlog_config_path, + MESA_load_profile_string_nodef(config_path, "global", "zlog_config_path", g_conf->zlog_config_path, sizeof(g_conf->zlog_config_path)); char dp_trace_dir[PATH_MAX] = "/tmp"; - MESA_load_profile_string_nodef(g_conf->config_path, "global", "dp_trace_dir", dp_trace_dir, sizeof(dp_trace_dir)); + MESA_load_profile_string_nodef(config_path, "global", "dp_trace_dir", dp_trace_dir, sizeof(dp_trace_dir)); if (dp_trace_dir[strlen(dp_trace_dir) - 1] == '/') { dp_trace_dir[strlen(dp_trace_dir) - 1] = '\0'; @@ -72,17 +73,29 @@ void config_load() g_conf->sled_ip = getenv("SLED_IP"); if (g_conf->sled_ip == NULL) { - dzlog_warn("SLED_IP environment variable does not exist."); + printf("SLED_IP environment variable does not exist."); } - MESA_load_profile_string_def(g_conf->config_path, "kafka", "borker_list", g_conf->broker_list, - sizeof(g_conf->broker_list), ""); - MESA_load_profile_string_def(g_conf->config_path, "kafka", "topic_name", g_conf->topic_name, - sizeof(g_conf->topic_name), ""); - MESA_load_profile_string_def(g_conf->config_path, "kafka", "sasl_username", g_conf->sasl_username, + MESA_load_profile_string_def(config_path, "kafka", "borker_list", g_conf->broker_list, sizeof(g_conf->broker_list), + ""); + MESA_load_profile_string_def(config_path, "kafka", "topic_name", g_conf->topic_name, sizeof(g_conf->topic_name), + ""); + MESA_load_profile_string_def(config_path, "kafka", "sasl_username", g_conf->sasl_username, sizeof(g_conf->sasl_username), ""); - MESA_load_profile_string_def(g_conf->config_path, "kafka", "sasl_password", g_conf->sasl_password, + MESA_load_profile_string_def(config_path, "kafka", "sasl_password", g_conf->sasl_password, sizeof(g_conf->sasl_password), ""); + + MESA_load_profile_int_def(config_path, "maat", "maat_log_level", &(g_conf->maat_log_level), LOG_LEVEL_FATAL); + MESA_load_profile_int_def(config_path, "maat", "maat_input_mode", &(g_conf->maat_input_mode), 0); + MESA_load_profile_string_def(config_path, "maat", "table_schema", g_conf->table_schema, + sizeof(g_conf->table_schema), ""); + MESA_load_profile_string_def(config_path, "maat", "json_cfg_file", g_conf->json_cfg_file, + sizeof(g_conf->json_cfg_file), ""); + MESA_load_profile_string_def(config_path, "maat", "maat_redis_server", g_conf->redis_server, + sizeof(g_conf->redis_server), ""); + MESA_load_profile_string_def(config_path, "maat", "maat_redis_port_range", g_conf->redis_port_range, + sizeof(g_conf->redis_server), "6379"); + MESA_load_profile_int_def(config_path, "maat", "maat_redis_db_index", &(g_conf->redis_db_idx), 0); } void dynamic_config_load() diff --git a/src/config.h b/src/config.h index e69bba9..8f81e59 100644 --- a/src/config.h +++ b/src/config.h @@ -26,6 +26,16 @@ struct config char sasl_username[MR_SYMBOL_MAX]; char sasl_password[MR_SYMBOL_MAX]; + // maat + unsigned int maat_log_level; + unsigned int maat_input_mode; + char table_schema[PATH_MAX]; + char json_cfg_file[PATH_MAX]; + + char redis_server[MR_SYMBOL_MAX]; + char redis_port_range[MR_SYMBOL_MAX]; + int redis_db_idx; + // dp trace char dp_trace_dir[PATH_MAX]; unsigned int dp_trace_file_max_size_in_KB; diff --git a/src/job_ctx.c b/src/job_ctx.c index f42afc2..99ded9e 100644 --- a/src/job_ctx.c +++ b/src/job_ctx.c @@ -2,7 +2,6 @@ #include "common.h" #include "trace_output.h" -#include <MESA/maat.h> #include <stdlib.h> #include <string.h> @@ -14,38 +13,6 @@ struct dp_trace_job_occupy static struct dp_trace_job_occupy dp_trace_job_occupy[DP_TRACE_JOB_NUM_MAX] = {}; -#if 0 -static void telemetry_job_add_cb(const char * table_name, int table_id, const char * key, const char * table_line, - void ** ad, long argl, void * argp) -{ - return; -} - -static void telemetry_job_del_cb(const char * table_name, int table_id, const char * key, const char * table_line, - void ** ad, long argl, void * argp) -{ - return; -} - -int maat_register() -{ - struct maat_options * opts = maat_options_new(); - struct maat * maat_instance = maat_new(opts, ""); - maat_get_table_id(maat_instance, DP_TRACE_TELEMETRY_TABLE); - - int ret = maat_plugin_table_ex_schema_register(maat_instance, DP_TRACE_TELEMETRY_TABLE, telemetry_job_add_cb, - telemetry_job_del_cb, NULL, 0, NULL); - - if (ret != 0) - { - MR_ERROR("failed at register callback of DP_TRACE_TELEMETRY_TABLE, ret = %d", ret); - return -1; - } - - return 1; -} -#endif - void job_rule_apply(struct dp_trace_job_desc desc[], unsigned int nr_desc, uint8_t role) { job_bitmap_t jobs_id_used; @@ -68,14 +35,6 @@ void job_rule_apply(struct dp_trace_job_desc desc[], unsigned int nr_desc, uint8 marsio_dp_trace_job_add(mr_instance, &desc[i]); dp_trace_job_occupy[rule_index].uesd = 1; dp_trace_job_occupy[rule_index].role = role; - -#if 1 - // just for test - if (rule_index == 10) - { - dp_trace_job_occupy[rule_index].role = DP_TELEMETRY_ROLE; - } -#endif continue; } diff --git a/src/job_ctx.h b/src/job_ctx.h index df8ea00..c1732fd 100644 --- a/src/job_ctx.h +++ b/src/job_ctx.h @@ -1,18 +1,5 @@ #pragma once #include "marsio.h" -#include <uuid/uuid.h> - -#define DP_TRACE_TELEMETRY_TABLE "DP_TRACE_TELEMETRY_TABLE" -#define DP_TRACE_TELEMETRY_NUM 8 - -struct dp_trace_telemetry_desc -{ - uint8_t used; - uuid_t uuid; - char job_name[128]; - job_bitmap_t job_id; - struct dp_trace_job_desc job_desc; -}; void job_rule_apply(struct dp_trace_job_desc desc[], unsigned int nr_desc, uint8_t role); int job_id_to_index(job_bitmap_t job_id); diff --git a/src/maat.c b/src/maat.c new file mode 100644 index 0000000..9062321 --- /dev/null +++ b/src/maat.c @@ -0,0 +1,186 @@ +#include "maat.h" +#include "config.h" +#include "job_ctx.h" + +#include <MESA/maat.h> +#include <cjson/cJSON.h> +#include <uuid/uuid.h> + +struct dp_trace_telemetry_desc +{ + uuid_t uuid; + char job_name[128]; + struct dp_trace_job_desc job_desc; +}; + +static struct dp_trace_telemetry_desc telemetry_descs[DP_TRACE_JOB_NUM_MAX]; + +static int dp_trace_telemetry_unused_job_index_get() +{ +#define TELEMETRY_INDEX_START 8 +#define TELEMETRY_INDEX_END DP_TRACE_JOB_NUM_MAX + + int ret = -1; + for (unsigned int i = TELEMETRY_INDEX_START; i < TELEMETRY_INDEX_END; i++) + { + job_bitmap_t job_id = index_to_job_id(i); + if (is_job_id_used(job_id)) + { + continue; + } + ret = i; + break; + } + + return ret; +} + +static struct maat * dp_trace_maat_instance_create() +{ + int ret = 0; + int redis_port_begin = 0; + int redis_port_end = 0; + int redis_port_select = 0; + struct maat * target = NULL; + + const struct config * conf = global_config_get(); + + struct maat_options * opts = maat_options_new(); + maat_options_set_logger(opts, "log/maat.log", (enum log_level)conf->maat_log_level); + maat_options_set_instance_name(opts, "dp_trace_telemetry"); + maat_options_set_caller_thread_number(opts, 0); + + switch (conf->maat_input_mode) + { + case MAAT_INPUT_JSON: + ret = maat_options_set_json_file(opts, conf->json_cfg_file); + if (ret != 0) + { + dzlog_error("maat_options_set_json_file function execution failed."); + goto error_out; + } + break; + case MAAT_INPUT_REDIS: + ret = sscanf(conf->redis_port_range, "%d-%d", &redis_port_begin, &redis_port_end); + if (ret == 1) + { + redis_port_select = redis_port_begin; + } + else if (ret == 2) + { + srand(time(NULL)); + redis_port_select = redis_port_begin + rand() % (redis_port_end - redis_port_begin); + } + else + { + dzlog_error("Invalid redis port range %s, MAAT init failed.", conf->redis_port_range); + goto error_out; + } + maat_options_set_redis(opts, conf->redis_server, redis_port_select, conf->redis_db_idx); + break; + default: + dzlog_error("Invalid MAAT Input Mode: %d.", conf->maat_input_mode); + goto error_out; + break; + } + + target = maat_new(opts, conf->table_schema); + if (!target) + { + dzlog_error("maat_new function execution failed."); + goto error_out; + } + + maat_options_free(opts); + return target; + +error_out: + maat_options_free(opts); + return NULL; +} + +static void telemetry_job_add_cb(const char * table_name, int table_id, const char * key, const char * table_line, + void ** ad, long argl, void * argp) +{ + int ret = 0; + size_t offset = 0; + size_t len = 0; + char * json_str = NULL; + cJSON * json = NULL; + + ret = maat_helper_read_column(table_line, 2, &offset, &len); + if (ret < 0) + { + dzlog_error("fail to get data path rule in maat."); + goto out; + } + + json_str = calloc(sizeof(char), len + 1); + memcpy(json_str, table_line + offset, len); + json = cJSON_Parse(json_str); + if (json == NULL) + { + dzlog_error("Invalid decryption parameter: %s", table_line); + goto out; + } + + struct dp_trace_telemetry_desc telemetry_desc; + struct dp_trace_job_desc * job_desc = &telemetry_desc.job_desc; + + cJSON * uuid_obj = cJSON_GetObjectItem(json, "job_id"); + DP_TRACE_VERIFY(cJSON_IsString(uuid_obj), "uuid is not string"); + ret = uuid_parse(uuid_obj->valuestring, telemetry_desc.uuid); + if (ret != 0) + { + dzlog_error("uuid parsing failed: %s", uuid_obj->valuestring); + goto out; + } + + cJSON * bpf_obj = cJSON_GetObjectItem(json, "bpf_expr"); + DP_TRACE_VERIFY(cJSON_IsString(bpf_obj), "bpf expr is not string"); + snprintf(job_desc->bpf_expr, sizeof(job_desc->bpf_expr), "%s", bpf_obj->valuestring); + + int index = dp_trace_telemetry_unused_job_index_get(); + if (index < 0) + { + dzlog_warn("no enough job for bpf_expr:", job_desc->bpf_expr); + goto out; + } + + job_desc->rule_index = index; + job_desc->enable = true; + + memcpy(&telemetry_descs[index], &telemetry_desc, sizeof(struct dp_trace_telemetry_desc)); + + job_rule_apply(&telemetry_descs[index].job_desc, 1, DP_TELEMETRY_ROLE); + + *ad = &telemetry_descs[index]; + +out: + if (json_str) + cJSON_Delete(json); + if (json_str) + free(json_str); + return; +} + +static void telemetry_job_del_cb(int table_id, void ** ad, long argl, void * argp) +{ + struct dp_trace_telemetry_desc * telemetry_desc = *ad; + struct dp_trace_job_desc * job_desc = &telemetry_desc->job_desc; + job_desc->enable = false; + job_rule_apply(job_desc, 1, DP_TELEMETRY_ROLE); + return; +} + +void dp_trace_maat_init() +{ + dzlog_info("data path trace maat init start..."); + struct maat * target = dp_trace_maat_instance_create(); + DP_TRACE_VERIFY(target, "create maat instance failed."); + + int ret = maat_plugin_table_ex_schema_register(target, "DP_TRACE_TELEMETRY_TABLE", telemetry_job_add_cb, + telemetry_job_del_cb, NULL, 0, NULL); + DP_TRACE_VERIFY(ret == 0, "failed at register callback of DP_TRACE_TELEMETRY_TABLE."); + dzlog_info("data path trace maat init end"); +}
\ No newline at end of file diff --git a/src/maat.h b/src/maat.h new file mode 100644 index 0000000..ca9ea7d --- /dev/null +++ b/src/maat.h @@ -0,0 +1,6 @@ +#pragma once + +#define MAAT_INPUT_JSON 0 +#define MAAT_INPUT_REDIS 1 + +void dp_trace_maat_init();
\ No newline at end of file @@ -1,6 +1,7 @@ #include "common.h" #include "config.h" #include "job_ctx.h" +#include "maat.h" #include "trace_output.h" #include <getopt.h> @@ -42,12 +43,12 @@ void signal_event_init() evbase = event_base_new(); - CHECK_OR_EXIT(evbase, "event_base_new failed"); + DP_TRACE_VERIFY(evbase, "event_base_new failed"); for (unsigned int i = 0; i < TELEMETRY_DIM(signals); i++) { evsignal[i] = evsignal_new(evbase, signals[i], signal_handler, NULL); - CHECK_OR_EXIT(evsignal[i], "create signal event failed. signal is:%d", signals[i]); + DP_TRACE_VERIFY(evsignal[i], "create signal event failed. signal is:%d", signals[i]); evsignal_add(evsignal[i], NULL); } @@ -139,6 +140,8 @@ int main(int argc, char * argv[]) dynamic_config_load_and_apply(); + dp_trace_maat_init(); + signal_event_init(); unsigned int nr_thread = CPU_COUNT(&conf->cpu_set_io); diff --git a/src/trace_output.c b/src/trace_output.c index a135d59..96288ae 100644 --- a/src/trace_output.c +++ b/src/trace_output.c @@ -220,7 +220,7 @@ void cli_job_mbufs_write_process(marsio_buff_t * mbufs[], int nr_mbufs, job_bitm // todo: optimization unsigned int comment_max_size = 8192; comment = malloc(comment_max_size); - CHECK_OR_EXIT(comment, "malloc fail, insufficient memory"); + DP_TRACE_VERIFY(comment, "malloc fail, insufficient memory"); for (unsigned int i = 0; i < nr_mbufs; i++) { diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 7f46d52..c26370f 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -100,4 +100,20 @@ set_target_properties(libzlog PROPERTIES INTERFACE_LINK_DIRECTORIES ${INSTALL_DIR}/lib INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include INTERFACE_LINK_LIBRARIES pthread -)
\ No newline at end of file +) + +### cJSON +ExternalProject_Add(cJSON PREFIX cJSON + URL ${CMAKE_CURRENT_SOURCE_DIR}/cJSON-1.7.7.tar.gz + URL_MD5 715009c99728bf81d6c97352718650ff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_AND_STATIC_LIBS=1) + +ExternalProject_Get_Property(cJSON INSTALL_DIR) +file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + +add_library(libcjson SHARED IMPORTED GLOBAL) +add_dependencies(libcjson cJSON) +set_property(TARGET libcjson PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libcjson.a) +set_property(TARGET libcjson PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
\ No newline at end of file diff --git a/support/cJSON-1.7.7.tar.gz b/support/cJSON-1.7.7.tar.gz Binary files differnew file mode 100644 index 0000000..c2350cf --- /dev/null +++ b/support/cJSON-1.7.7.tar.gz diff --git a/test/dp_telemetry_rules.json b/test/dp_telemetry_rules.json new file mode 100644 index 0000000..a5c9972 --- /dev/null +++ b/test/dp_telemetry_rules.json @@ -0,0 +1,10 @@ +{ + "plugin_table": [ + { + "table_name": "DP_TRACE_TELEMETRY_TABLE", + "table_content": [ + "0\t{\"job_id\":\"72694b1c-6833-4c46-acde-52e2d6409314\",\"bpf_expr\":\"ip host 172.19.199.171\"}\t1" + ] + } + ] +}
\ No newline at end of file diff --git a/test/table_schema.json b/test/table_schema.json new file mode 100644 index 0000000..31067a6 --- /dev/null +++ b/test/table_schema.json @@ -0,0 +1,13 @@ +[ + { + "table_id": 1, + "table_name": "DP_TRACE_TELEMETRY_TABLE", + "table_type": "plugin", + "valid_column": 3, + "custom": { + "key": 1, + "key_type": "integer", + "key_len": 8 + } + } +]
\ No newline at end of file |
