提高时间精度(common_establish_latency_ms、common_con_duration_ms)
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
#define MAX_CATEGORY_ID_NUM 8
|
#define MAX_CATEGORY_ID_NUM 8
|
||||||
#define MAX_STR_FIELD_LEN 64
|
#define MAX_STR_FIELD_LEN 64
|
||||||
|
|
||||||
|
#define MAX_RESULT_NUM 8
|
||||||
|
#define MAX_DOAMIN_LEN 2048
|
||||||
|
|
||||||
typedef enum _tsg_protocol
|
typedef enum _tsg_protocol
|
||||||
{
|
{
|
||||||
PROTO_UNKONWN=0,
|
PROTO_UNKONWN=0,
|
||||||
@@ -83,4 +86,14 @@ struct _session_attribute_label_t
|
|||||||
unsigned int fqdn_category_id[MAX_CATEGORY_ID_NUM];
|
unsigned int fqdn_category_id[MAX_CATEGORY_ID_NUM];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _policy_priority_label
|
||||||
|
{
|
||||||
|
tsg_protocol_t proto; //enum _tsg_protocol (tsg_types.h)
|
||||||
|
int domain_len;
|
||||||
|
int result_type; //enum _PULL_RESULT_TYPE (tsg_rule.h)
|
||||||
|
int result_num;
|
||||||
|
char domain[MAX_DOAMIN_LEN];
|
||||||
|
Maat_rule_t result[MAX_RESULT_NUM];
|
||||||
|
}policy_priority_label_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ enum TSG_ETHOD_TYPE
|
|||||||
TSG_METHOD_TYPE_MAX
|
TSG_METHOD_TYPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_RESULT_NUM 8
|
|
||||||
#define MAX_DOAMIN_LEN 2048
|
|
||||||
|
|
||||||
struct _identify_info
|
struct _identify_info
|
||||||
{
|
{
|
||||||
tsg_protocol_t proto; //enum _tsg_protocol (tsg_types.h)
|
tsg_protocol_t proto; //enum _tsg_protocol (tsg_types.h)
|
||||||
|
|||||||
@@ -708,6 +708,8 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
|
|||||||
policy_priority_label_t *priority_label=NULL;
|
policy_priority_label_t *priority_label=NULL;
|
||||||
struct _master_context *_context=(struct _master_context *)*pme;
|
struct _master_context *_context=(struct _master_context *)*pme;
|
||||||
struct _session_attribute_label_t *internal_label=NULL;
|
struct _session_attribute_label_t *internal_label=NULL;
|
||||||
|
unsigned long long create_time=0;
|
||||||
|
int size=sizeof(create_time);
|
||||||
switch(a_tcp->opstate)
|
switch(a_tcp->opstate)
|
||||||
{
|
{
|
||||||
case OP_STATE_PENDING:
|
case OP_STATE_PENDING:
|
||||||
@@ -720,10 +722,11 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
|
|||||||
identify_application_protocol(a_tcp, &identify_info, internal_label, a_packet);
|
identify_application_protocol(a_tcp, &identify_info, internal_label, a_packet);
|
||||||
internal_label->proto=identify_info.proto;
|
internal_label->proto=identify_info.proto;
|
||||||
|
|
||||||
if(identify_info.proto==PROTO_HTTP)
|
ret=MESA_get_stream_opt(a_tcp, MSO_STREAM_CREATE_TIMESTAMP_MS, (void *)&create_time, &size);
|
||||||
|
if(ret>=0)
|
||||||
{
|
{
|
||||||
clock_gettime(CLOCK_REALTIME, &tv);
|
clock_gettime(CLOCK_REALTIME, &tv);
|
||||||
internal_label->establish_latency_ms=(tv.tv_sec-a_tcp->ptcpdetail->createtime)*1000+tv.tv_nsec/1000/1000;
|
internal_label->establish_latency_ms=tv.tv_sec*1000+tv.tv_nsec/1000/1000 - create_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret=project_req_add_struct(a_tcp, g_tsg_para.internal_project_id, (const void *)internal_label);
|
ret=project_req_add_struct(a_tcp, g_tsg_para.internal_project_id, (const void *)internal_label);
|
||||||
|
|||||||
@@ -80,17 +80,6 @@ struct _fqdn_category_t
|
|||||||
char fqdn[MAX_DOAMIN_LEN/8];
|
char fqdn[MAX_DOAMIN_LEN/8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _policy_priority_label
|
|
||||||
{
|
|
||||||
tsg_protocol_t proto; //enum _tsg_protocol (tsg_types.h)
|
|
||||||
int domain_len;
|
|
||||||
int result_type; //enum _PULL_RESULT_TYPE (tsg_rule.h)
|
|
||||||
int result_num;
|
|
||||||
char domain[MAX_DOAMIN_LEN];
|
|
||||||
Maat_rule_t result[MAX_RESULT_NUM];
|
|
||||||
}policy_priority_label_t;
|
|
||||||
|
|
||||||
struct _master_context
|
struct _master_context
|
||||||
{
|
{
|
||||||
tsg_protocol_t proto;
|
tsg_protocol_t proto;
|
||||||
|
|||||||
@@ -317,8 +317,10 @@ int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle
|
|||||||
unsigned short tunnel_type=0;
|
unsigned short tunnel_type=0;
|
||||||
char nest_addr_buf[1024];
|
char nest_addr_buf[1024];
|
||||||
char *addr_proto=NULL;
|
char *addr_proto=NULL;
|
||||||
time_t cur_time;
|
struct timespec tv;
|
||||||
|
int size=sizeof(unsigned long long);
|
||||||
long common_con_duration_ms=0;
|
long common_con_duration_ms=0;
|
||||||
|
unsigned long long create_time=0;
|
||||||
unsigned long long stream_id=0;
|
unsigned long long stream_id=0;
|
||||||
unsigned short c_port=0, s_port=0;
|
unsigned short c_port=0, s_port=0;
|
||||||
int tunnel_type_size=sizeof(tunnel_type);
|
int tunnel_type_size=sizeof(tunnel_type);
|
||||||
@@ -408,12 +410,21 @@ int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle
|
|||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME].name, (void *)(a_stream->ptcpdetail->createtime), TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME].name, (void *)(a_stream->ptcpdetail->createtime), TLD_TYPE_LONG);
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)(a_stream->ptcpdetail->lastmtime), TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)(a_stream->ptcpdetail->lastmtime), TLD_TYPE_LONG);
|
||||||
|
|
||||||
common_con_duration_ms=(a_stream->ptcpdetail->lastmtime-a_stream->ptcpdetail->createtime)*1000;
|
ret=MESA_get_stream_opt(a_stream, MSO_STREAM_CREATE_TIMESTAMP_MS, (void *)&create_time, &size);
|
||||||
|
if(ret>=0)
|
||||||
|
{
|
||||||
|
clock_gettime(CLOCK_REALTIME, &tv);
|
||||||
|
common_con_duration_ms=tv.tv_sec*1000+tv.tv_nsec/1000/1000 - create_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(common_con_duration_ms>0)
|
||||||
|
{
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cur_time=time(NULL);
|
time_t cur_time=time(NULL);
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
|
||||||
|
|||||||
Reference in New Issue
Block a user