summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/tsg_log_field.conf4
-rw-r--r--src/tsg_send_log.cpp38
-rw-r--r--src/tsg_send_log_internal.h2
3 files changed, 29 insertions, 15 deletions
diff --git a/bin/tsg_log_field.conf b/bin/tsg_log_field.conf
index f0ac338..6fb8559 100644
--- a/bin/tsg_log_field.conf
+++ b/bin/tsg_log_field.conf
@@ -140,4 +140,6 @@ STRING common_protocol_label 126
STRING common_in_src_mac 127
STRING common_in_dest_mac 128
STRING common_out_src_mac 129
-STRING common_out_dest_mac 130 \ No newline at end of file
+STRING common_out_dest_mac 130
+LONG common_start_timestamp_ms 131
+LONG common_end_timestamp_ms 132 \ No newline at end of file
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index bac824d..25dabf9 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -418,34 +418,44 @@ static int set_tuple4(struct tsg_log_instance_t *_instance, struct TLD_handle_t
static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream)
{
- long common_con_duration_ms=0;
int size=sizeof(unsigned long long);
- unsigned long long create_time=0,last_time=0;
+ unsigned long long create_time_ms=0,last_time_ms=0;
if(a_stream->ptcpdetail!=NULL)
{
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);
-
- int ret=MESA_get_stream_opt(a_stream, MSO_STREAM_CREATE_TIMESTAMP_MS, (void *)&create_time, &size);
- if(ret>=0)
- {
- ret=MESA_get_stream_opt(a_stream, MSO_STREAM_LASTUPDATE_TIMESTAMP_MS, (void *)&last_time, &size);
- if(ret>=0 && last_time>create_time)
- {
- common_con_duration_ms=last_time-create_time;
- TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
- }
- }
}
else
{
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_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 *)(0), TLD_TYPE_LONG);
+ }
+
+ int ret=MESA_get_stream_opt(a_stream, MSO_STREAM_CREATE_TIMESTAMP_MS, (void *)&create_time_ms, &size);
+ if(ret<0)
+ {
+ return 0;
}
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME_MS].name, (void *)(create_time_ms), TLD_TYPE_LONG);
+
+ ret=MESA_get_stream_opt(a_stream, MSO_STREAM_LASTUPDATE_TIMESTAMP_MS, (void *)&last_time_ms, &size);
+ if(ret<0)
+ {
+ return 0;
+ }
+
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME_MS].name, (void *)(last_time_ms), TLD_TYPE_LONG);
+
+ if(last_time_ms>=create_time_ms)
+ {
+ unsigned long long common_con_duration_ms=last_time_ms-create_time_ms;
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
+ }
+
return 1;
}
diff --git a/src/tsg_send_log_internal.h b/src/tsg_send_log_internal.h
index 25a9c89..d231ad5 100644
--- a/src/tsg_send_log_internal.h
+++ b/src/tsg_send_log_internal.h
@@ -154,6 +154,8 @@ enum LOG_FIELD_ID
LOG_COMMON_INCOMING_DST_MAC,
LOG_COMMON_OUTCOMING_SRC_MAC,
LOG_COMMON_OUTCOMING_DST_MAC,
+ LOG_COMMON_START_TIME_MS,
+ LOG_COMMON_END_TIME_MS,
LOG_COMMON_MAX
};