TSG-14945: 输出Application and Protocol Metrics

This commit is contained in:
刘学利
2023-06-02 08:19:50 +00:00
parent 2adf35914f
commit 380733e78b
15 changed files with 751 additions and 244 deletions

View File

@@ -42,18 +42,19 @@ set(TSG_MASTER_SRC ${PROJECT_SOURCE_DIR}/src/tsg_entry.cpp
${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp
${PROJECT_SOURCE_DIR}/src/tsg_protocol.cpp
${PROJECT_SOURCE_DIR}/src/tsg_proxy.cpp
${PROJECT_SOURCE_DIR}/src/mpack.c
)
add_executable(gtest_master ${TSG_MASTER_SRC} ${PROJECT_SOURCE_DIR}/src/mpack.c gtest_kafka.cpp gtest_common.cpp gtest_master.cpp)
add_executable(gtest_master ${TSG_MASTER_SRC} gtest_kafka.cpp gtest_common.cpp gtest_master.cpp)
target_link_libraries(gtest_master gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maat4 MESA_htable fieldstat3)
add_executable(gtest_sync_state ${PROJECT_SOURCE_DIR}/src/tsg_sync_state.cpp ${PROJECT_SOURCE_DIR}/src/mpack.c gtest_common.cpp gtest_sync_state.cpp)
target_link_libraries(gtest_sync_state gtest-static cjson ctemplate-static MESA_handle_logger)
add_executable(gtest_fieldstat3 ${PROJECT_SOURCE_DIR}/src/tsg_statistic.cpp gtest_common.cpp gtest_fieldstat3.cpp)
target_link_libraries(gtest_fieldstat3 gtest-static ctemplate-static MESA_field_stat2 fieldstat3 MESA_prof_load MESA_handle_logger)
add_executable(gtest_fieldstat3 ${TSG_MASTER_SRC} gtest_common.cpp gtest_kafka.cpp gtest_fieldstat3.cpp)
target_link_libraries(gtest_fieldstat3 gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maat4 MESA_htable fieldstat3)
add_executable(gtest_proxy ${TSG_MASTER_SRC} ${PROJECT_SOURCE_DIR}/src/mpack.c gtest_common.cpp gtest_proxy.cpp)
add_executable(gtest_proxy ${TSG_MASTER_SRC} gtest_common.cpp gtest_proxy.cpp)
target_link_libraries(gtest_proxy gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maat4 rdkafka MESA_htable fieldstat3 pcap)
file(COPY ../pcap/ DESTINATION ./pcap/)

View File

@@ -7,7 +7,7 @@ struct gtest_ctrl_pkt
{
char buf[1024];
int len;
}ctrl_pkt;
};
void dictator_free(int thread_seq, void * pbuf)
{
@@ -40,9 +40,11 @@ int sapp_inject_pkt(struct streaminfo * stream, enum sapp_inject_opt sio, const
return 0;
}
struct gtest_ctrl_pkt ctrl_pkt;
int sapp_inject_ctrl_pkt(struct streaminfo * stream, enum sapp_inject_opt sio, const void * payload, int payload_len, unsigned char snd_routedir)
{
memset(&ctrl_pkt, 0, 1050);
memset(&ctrl_pkt, 0, sizeof(ctrl_pkt));
memcpy(ctrl_pkt.buf, payload, payload_len);
ctrl_pkt.len = payload_len;

View File

@@ -17,7 +17,7 @@ pthread_t g_pid[8];
TEST(FIELDSATA3, InterceptIllegalParameter)
{
struct _traffic_info _info;
struct traffic_info _info;
struct maat_rule p_result;
int ret = tsg_set_intercept_flow(NULL, &_info, 0);
@@ -47,7 +47,7 @@ TEST(FIELDSATA3, PolicyIllegalParameter)
TEST(FIELDSATA3, Intercept)
{
struct _traffic_info _info;
struct traffic_info _info;
struct maat_rule p_result;
_info.con_num = 10;
@@ -97,7 +97,7 @@ void *run_time_funtion(void *arg)
struct maat_rule p_result;
struct streaminfo a_stream;
struct _traffic_info _info;
struct traffic_info _info;
while (1)
{
@@ -155,7 +155,7 @@ TEST(FIELDSATA3, MultiThreading)
int main(int argc, char *argv[])
{
void *logger = MESA_create_runtime_log_handle("log/gtest_fieldstat3.log", RLOG_LV_FATAL);
tsg_statistic_init(tsg_gtest_conffile, logger);
tsg_metric_init(tsg_gtest_conffile, logger);
testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
// sleep(30);
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
// pthread_cancel(g_pid[i]);
// }
tsg_statistic_destroy();
tsg_metric_destroy();
return ret;
}

View File

@@ -148,6 +148,11 @@ int tsg_set_policy_flow(const struct streaminfo * a_stream, struct maat_rule * p
return 0;
}
int session_application_full_path_update(const struct streaminfo * a_stream, char * app_full_path, int app_full_path_len)
{
return 0;
}
TEST(Master, SendInterimRecord)
{
struct streaminfo a_stream={0};