summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2020-01-07 13:04:00 +0800
committerliuxueli <[email protected]>2020-01-07 13:04:00 +0800
commit2546578fd51b658cfe75c7b7b0dfeae80a66c298 (patch)
tree267746890cc5cfd59c27675c9f8276ea072ca673
parent03109fb27ef3595fd90cf17cdb9a2aa2b81908df (diff)
完成链接统计信息功能v1.0.0
monitor日志等到CLOSE状态发送日志
-rw-r--r--inc/tsg_rule.h8
-rw-r--r--src/tsg_entry.cpp121
-rw-r--r--src/tsg_entry.h19
-rw-r--r--src/tsg_statistic.cpp166
4 files changed, 167 insertions, 147 deletions
diff --git a/inc/tsg_rule.h b/inc/tsg_rule.h
index d3a8039..37a6cbf 100644
--- a/inc/tsg_rule.h
+++ b/inc/tsg_rule.h
@@ -3,6 +3,14 @@
#include <MESA/Maat_rule.h>
+#define TSG_ACTION_NONE 0x00
+#define TSG_ACTION_MONITOR 0x01
+#define TSG_ACTION_INTERCEPT 0x02
+#define TSG_ACTION_DENY 0x10
+#define TSG_ACTION_MANIPULATE 0x30
+#define TSG_ACTION_BYPASS 0x80
+#define TSG_ACTION_MAX 0x80
+
enum TSG_ETHOD_TYPE
{
TSG_METHOD_TYPE_UNKNOWN=0,
diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp
index a29c255..418044a 100644
--- a/src/tsg_entry.cpp
+++ b/src/tsg_entry.cpp
@@ -10,6 +10,7 @@
#include "tsg_rule.h"
#include "tsg_entry.h"
#include "tsg_send_log.h"
+#include "tsg_statistic.h"
#include "tsg_send_log_internal.h"
#ifdef __cplusplus
@@ -52,54 +53,32 @@ static void free_policy_label(int thread_seq, void *project_req_value)
project_req_value=NULL;
}
-#if 0
-static int is_ip_policy(Maat_rule_t *p_result, char *protocol, int len, int thread_seq)
+static int master_send_log(struct streaminfo *a_stream, struct Maat_rule_t *p_result, int result_num, struct _identify_info *identify_info, int thread_seq)
{
- int ret=0;
- cJSON *item=NULL;
- char *service_defined=NULL;
- cJSON *user_define_object=NULL;
+ tsg_log_t log_msg;
+ char *domain_field_name=NULL;
+ char *schema_field_name=NULL;
+ struct TLD_handle_t *TLD_handle=NULL;
- if(p_result->serv_def_len>MAX_SERVICE_DEFINE_LEN)
+ TLD_handle=TLD_create(thread_seq);
+ if(identify_info!=NULL)
{
- service_defined=dictator_malloc(thread_seq, p_result->serv_def_len+1);
- ret=Maat_read_rule(g_tsg_maat_feather, p_result, MAAT_RULE_SERV_DEFINE, service_defined, p_result->serv_def_len+1);
- assert(ret==p_result->serv_def_len+1);
+ schema_field_name=log_field_id2name(g_tsg_log_instance, LOG_COMMON_SCHAME_TYPE);
+ TLD_append(TLD_handle, schema_field_name, (void *)((identify_info->proto==PROTO_HTTP) ? "HTTP" : "SSL"), TLD_TYPE_STRING);
- user_define_object=cJSON_Parse(service_defined);
- }
- else
- {
- user_define_object=cJSON_Parse(p_result->service_defined);
- }
-
- if(user_define_object!=NULL)
- {
- item=cJSON_GetObjectItem(user_define_object, "protocol");
- if(item!=NULL && item->valuestring!=NULL)
- {
- memcpy(protocol, item->valuestring, (len>strlen(item->valuestring)) ? strlen(item->valuestring): len);
- }
-
- item=cJSON_GetObjectItem(user_define_object, "method");
- if((item==NULL) || ((strncasecmp(item->valuestring, "http", strlen(item->valuestring)))!=0 && (strncasecmp(item->valuestring, "ssl", strlen(item->valuestring)))!=0))
- {
- ret=1;
- }
-
- cJSON_Delete(user_define_object);
- user_define_object=NULL;
- }
-
- if(service_defined!=NULL)
- {
- dictator_free(thread_seq, service_defined);
- service_defined=NULL;
+ domain_field_name=log_field_id2name(g_tsg_log_instance, ((identify_info->proto==PROTO_HTTP) ? LOG_HTTP_HOST : LOG_SSL_SNI));
+ TLD_append(TLD_handle, domain_field_name, (void *)identify_info->domain, TLD_TYPE_STRING);
}
- return ret;
+ log_msg.a_stream=a_stream;
+ log_msg.result=p_result;
+ log_msg.result_num=result_num;
+ tsg_send_log(g_tsg_log_instance, TLD_handle, &log_msg, thread_seq);
+ tsg_set_policy_flow(a_stream, p_result, thread_seq);
+
+ return 1;
}
-#endif
+
static struct Maat_rule_t *tsg_policy_decision_criteria(Maat_rule_t *result, int result_num)
{
int i=0;
@@ -133,19 +112,16 @@ static struct Maat_rule_t *tsg_policy_decision_criteria(Maat_rule_t *result, int
extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
{
- int send_log=0,identify_flag=0;
+ int identify_flag=0;
int ret=0,hit_num=0;
int state=APP_STATE_DROPME;
scan_status_t mid=NULL;
- char *domain_field_name=NULL;
- char *schema_field_name=NULL;
Maat_rule_t *p_result=NULL;
Maat_rule_t *q_result=NULL;
- tsg_log_t log_msg;
- struct TLD_handle_t *TLD_handle=NULL;
struct _identify_info identify_info;
Maat_rule_t all_result[MAX_RESULT_NUM];
policy_priority_label_t *priority_label=NULL;
+ struct _master_context *_context=(struct _master_context *)*pme;
switch(a_tcp->opstate)
{
@@ -226,27 +202,41 @@ printaddr(&a_tcp->addr, thread_seq), ret);
switch((unsigned char)p_result->action)
{
case TSG_ACTION_DENY:
- send_log=1;
MESA_kill_tcp(a_tcp, a_packet);
- state|=APP_STATE_DROPPKT|APP_STATE_KILL_OTHER;
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_DENY], 0, FS_OP_ADD, 1);
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "DENY", "Hit deny policy, policy_id: %d action: %d addr: %s",
-
p_result[0].config_id, p_result[0].action, printaddr(&a_tcp->addr, thread_seq));
+
+ master_send_log(a_tcp, p_result, 1, ((identify_flag==1) ? &identify_info : NULL), thread_seq);
+ state|=APP_STATE_DROPPKT|APP_STATE_KILL_OTHER;
break;
case TSG_ACTION_MONITOR:
if(q_result!=NULL && (p_result==q_result))
{
- send_log=1;
+ *pme=dictator_malloc(thread_seq, sizeof(struct _master_context));
+ _context=(struct _master_context *)*pme;
+ _context->hit_cnt=1;
+ _context->result=(struct Maat_rule_t *)dictator_malloc(thread_seq, sizeof(struct Maat_rule_t));
+ memcpy(_context->result, p_result, sizeof(struct Maat_rule_t));
+
+ state=APP_STATE_GIVEME;
}
break;
case TSG_ACTION_BYPASS:
- send_log=1;
- state|=APP_STATE_KILL_OTHER; //TODO
+ *pme=dictator_malloc(thread_seq, sizeof(struct _master_context));
+ _context=(struct _master_context *)*pme;
+ _context->hit_cnt=1;
+ _context->result=(struct Maat_rule_t *)dictator_malloc(thread_seq, sizeof(struct Maat_rule_t));
+ memcpy(_context->result, p_result, sizeof(struct Maat_rule_t));
+
+ state=APP_STATE_GIVEME|APP_STATE_KILL_OTHER;
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_BYPASS], 0, FS_OP_ADD, 1);
break;
case TSG_ACTION_INTERCEPT:
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_INTERCEPT], 0, FS_OP_ADD, 1);
+
+ tsg_set_policy_flow(a_tcp, p_result, thread_seq);
+
priority_label=(policy_priority_label_t *)dictator_malloc(thread_seq, sizeof(policy_priority_label_t));
priority_label->result_num=1;
@@ -272,28 +262,19 @@ printaddr(&a_tcp->addr, thread_seq), ret);
assert(0);
break;
}
-
- if(send_log==1 && p_result->do_log>0)
- {
- TLD_handle=TLD_create(thread_seq);
- if(identify_flag==1)
- {
- schema_field_name=log_field_id2name(g_tsg_log_instance, LOG_COMMON_SCHAME_TYPE);
- TLD_append(TLD_handle, schema_field_name, (void *)((identify_info.proto==PROTO_HTTP) ? "HTTP" : "SSL"), TLD_TYPE_STRING);
-
- domain_field_name=log_field_id2name(g_tsg_log_instance, ((identify_info.proto==PROTO_HTTP) ? LOG_HTTP_HOST : LOG_SSL_SNI));
- TLD_append(TLD_handle, domain_field_name, (void *)identify_info.domain, TLD_TYPE_STRING);
- }
-
- log_msg.a_stream=a_tcp;
- log_msg.result=p_result;
- log_msg.result_num=1;
- tsg_send_log(g_tsg_log_instance, TLD_handle, &log_msg, thread_seq);
- }
}
break;
case OP_STATE_DATA:
case OP_STATE_CLOSE:
+ if(_context!=NULL)
+ {
+ if(_context->hit_cnt>0 && _context->result!=NULL)
+ {
+ master_send_log(a_tcp, _context->result, _context->hit_cnt, NULL, thread_seq);
+ dictator_free(thread_seq, (void *)_context->result);
+ _context->result=NULL;
+ }
+ }
default:
break;
}
diff --git a/src/tsg_entry.h b/src/tsg_entry.h
index eb104fc..628076c 100644
--- a/src/tsg_entry.h
+++ b/src/tsg_entry.h
@@ -5,15 +5,6 @@
#include <MESA/field_stat2.h>
#include "tsg_rule.h"
-#define TSG_ACTION_NONE 0x00
-#define TSG_ACTION_MONITOR 0x01
-#define TSG_ACTION_INTERCEPT 0x02
-#define TSG_ACTION_DENY 0x10
-#define TSG_ACTION_MANIPULATE 0x30
-#define TSG_ACTION_BYPASS 0x80
-#define TSG_ACTION_MAX 0x80
-
-
enum TSG_FS2_TYPE{
TSG_FS2_LINKS=0,
TSG_FS2_BYPASS,
@@ -43,6 +34,11 @@ typedef struct _policy_priority_label
Maat_rule_t result[MAX_RESULT_NUM];
}policy_priority_label_t;
+struct _master_context
+{
+ int hit_cnt;
+ struct Maat_rule_t *result;
+};
typedef struct _tsg_para
{
@@ -66,7 +62,7 @@ typedef enum _tsg_statis_field_id
STATIS_ENTRANCE_ID=1,
STATIS_TOTAL_CON_NUM,
STATIS_NEW_CON_NUM,
- STATIS_LIVE_CON_NUM,
+ STATIS_ESTABLISHED_CON_NUM,
STATIS_CLOSE_CON_NUM,
STATIS_TOTAL_IN_BYTES,
STATIS_TOTAL_OUT_BYTES,
@@ -121,8 +117,9 @@ struct _traffic_info
typedef struct _tsg_statistic
{
int cycle;
+ int fs_line_id;
int fs_field_id[STATIS_MAX];
- struct _traffic_info *traffic_info[TSG_ACTION_MAX];
+ struct _traffic_info *traffic_info[TSG_ACTION_MAX+1];
screen_stat_handle_t fs2_handle;
}tsg_statis_para_t;
diff --git a/src/tsg_statistic.cpp b/src/tsg_statistic.cpp
index dccd4d6..f835776 100644
--- a/src/tsg_statistic.cpp
+++ b/src/tsg_statistic.cpp
@@ -14,6 +14,8 @@ tsg_statis_para_t g_tsg_statis_para;
int tsg_set_policy_flow(struct streaminfo *a_stream, Maat_rule_t *p_result, int thread_seq)
{
+ unsigned long long value=0;
+ int value_len=sizeof(unsigned long long);
struct _traffic_info *traffic_info=NULL;
if(g_tsg_statis_para.cycle<=0)
@@ -26,18 +28,42 @@ int tsg_set_policy_flow(struct streaminfo *a_stream, Maat_rule_t *p_result, int
return -1;
}
- traffic_info=&(g_tsg_statis_para.traffic_info[(int)p_result->action][thread_seq]);
+ traffic_info=&(g_tsg_statis_para.traffic_info[(unsigned char)p_result->action][thread_seq]);
traffic_info->con_num++;
- traffic_info->in_bytes+=a_stream->ptcpdetail->clientbytes;
- traffic_info->in_packets+=a_stream->ptcpdetail->clientpktnum;
+
+ value=0;
+ MESA_get_stream_opt(a_stream, MSO_TOTAL_INBOUND_BYTE, (void *)&value, &value_len);
+ traffic_info->in_bytes+=value;
+
+ value=0;
+ MESA_get_stream_opt(a_stream, MSO_TOTAL_INBOUND_PKT, (void *)&value, &value_len);
+ traffic_info->in_packets+=value;
+
+ value=0;
+ MESA_get_stream_opt(a_stream, MSO_TOTAL_OUTBOUND_BYTE, (void *)&value, &value_len);
+ traffic_info->out_bytes+=value;
- traffic_info->out_bytes+=a_stream->ptcpdetail->serverbytes;
- traffic_info->out_packets+=a_stream->ptcpdetail->serverpktnum;
+ value=0;
+ MESA_get_stream_opt(a_stream, MSO_TOTAL_OUTBOUND_PKT, (void *)&value, &value_len);
+ traffic_info->out_packets+=value;
return 0;
}
+static int _get_traffic_info(struct _traffic_info *total, struct _traffic_info *policy, struct _traffic_info *out)
+{
+ if(total!=NULL && policy!=NULL && out!=NULL)
+ {
+ out->con_num=total->con_num-policy->con_num;
+ out->in_bytes=total->in_bytes-policy->in_bytes;
+ out->in_packets=total->in_packets-policy->in_packets;
+ out->out_bytes=total->out_bytes-policy->out_bytes;
+ out->out_packets=total->out_packets-policy->out_packets;
+ }
+ return 0;
+}
+
static int _set_traffic_info(struct _traffic_info *from, struct _traffic_info *to, int action, int thread_num)
{
tsg_statis_field_id_t con_num_id=STATIS_UNKNOWN;
@@ -129,24 +155,24 @@ static int _set_traffic_info(struct _traffic_info *from, struct _traffic_info *t
break;
}
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[con_num_id], 0, FS_OP_SET, con_num_sum);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[in_bytes_id], 0, FS_OP_SET, in_bytes_sum);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[in_packets_id], 0, FS_OP_SET, in_packets_sum);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[out_bytes_id], 0, FS_OP_SET, out_bytes_sum);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[out_packets_id], 0, FS_OP_SET, out_packets_sum);
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[con_num_id], FS_OP_SET, con_num_sum);
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[in_bytes_id], FS_OP_SET, in_bytes_sum);
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[in_packets_id], FS_OP_SET, in_packets_sum);
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[out_bytes_id], FS_OP_SET, out_bytes_sum);
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[out_packets_id], FS_OP_SET, out_packets_sum);
return 0;
}
static void *tsg_statistic_thread(void *arg)
{
long long value=0;
- int value_len=sizeof(value);
+ int value_len=sizeof(long long);
int thread_num=get_thread_count();
struct _traffic_info policy_traffic_info;
struct _traffic_info total_traffic_info;
struct _traffic_info default_traffic_info;
- FS_start(g_tsg_para.fs2_handle);
+ FS_start(g_tsg_statis_para.fs2_handle);
while(1)
{
@@ -155,38 +181,42 @@ static void *tsg_statistic_thread(void *arg)
memset(&default_traffic_info, 0, sizeof(default_traffic_info));
value=0;
- value_len=sizeof(value);
sapp_get_platform_opt(SPO_TCP_STREAM_NEW, (void *)&value, &value_len);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[STATIS_NEW_CON_NUM], 0, FS_OP_SET, value);
total_traffic_info.con_num+=value;
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[STATIS_NEW_CON_NUM], FS_OP_SET, value);
value=0;
- value_len=sizeof(value);
- sapp_get_platform_opt(SPO_TCP_STREAM_LIVE, (void *)&value, &value_len);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[STATIS_LIVE_CON_NUM], 0, FS_OP_SET, value);
+ sapp_get_platform_opt(SPO_TCP_STREAM_ESTAB, (void *)&value, &value_len);
total_traffic_info.con_num+=value;
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[STATIS_ESTABLISHED_CON_NUM], FS_OP_SET, value);
value=0;
- value_len=sizeof(value);
sapp_get_platform_opt(SPO_TCP_STREAM_CLOSE, (void *)&value, &value_len);
- FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_field_id[STATIS_CLOSE_CON_NUM], 0, FS_OP_SET, value);
total_traffic_info.con_num+=value;
+ FS_operate(g_tsg_statis_para.fs2_handle, g_tsg_statis_para.fs_line_id, g_tsg_statis_para.fs_field_id[STATIS_CLOSE_CON_NUM], FS_OP_SET, value);
- value_len=sizeof(total_traffic_info.out_bytes);
- sapp_get_platform_opt(SPO_TOTAL_EGRESS_BYTE, (void *)&total_traffic_info.out_bytes, &value_len);
+ value_len=sizeof(total_traffic_info.in_bytes);
+ sapp_get_platform_opt(SPO_TOTAL_INBOUND_BYTE, (void *)&total_traffic_info.in_bytes, &value_len);
+ value_len=sizeof(total_traffic_info.in_packets);
+ sapp_get_platform_opt(SPO_TOTAL_INBOUND_PKT, (void *)&total_traffic_info.in_packets, &value_len);
value_len=sizeof(total_traffic_info.out_bytes);
- sapp_get_platform_opt(SPO_TOTAL_EGRESS_BYTE, (void *)&total_traffic_info.out_bytes, &value_len);
+ sapp_get_platform_opt(SPO_TOTAL_OUTBOUND_BYTE, (void *)&total_traffic_info.out_bytes, &value_len);
+ value_len=sizeof(total_traffic_info.out_packets);
+ sapp_get_platform_opt(SPO_TOTAL_OUTBOUND_PKT, (void *)&total_traffic_info.out_packets, &value_len);
_set_traffic_info(g_tsg_statis_para.traffic_info[TSG_ACTION_BYPASS], &policy_traffic_info, TSG_ACTION_BYPASS, thread_num);
_set_traffic_info(g_tsg_statis_para.traffic_info[TSG_ACTION_DENY], &policy_traffic_info, TSG_ACTION_DENY, thread_num);
_set_traffic_info(g_tsg_statis_para.traffic_info[TSG_ACTION_MONITOR], &policy_traffic_info, TSG_ACTION_MONITOR, thread_num);
_set_traffic_info(g_tsg_statis_para.traffic_info[TSG_ACTION_INTERCEPT], &policy_traffic_info, TSG_ACTION_INTERCEPT, thread_num);
-
_set_traffic_info(&total_traffic_info, NULL, -1, 0);
+
+ _get_traffic_info(&total_traffic_info, &policy_traffic_info, &default_traffic_info);
_set_traffic_info(&default_traffic_info, NULL, TSG_ACTION_NONE, 0);
+ FS_passive_output(g_tsg_statis_para.fs2_handle);
+
sleep(g_tsg_statis_para.cycle);
}
@@ -205,7 +235,7 @@ int tsg_statistic_init(const char *conffile, void *logger)
memset(&g_tsg_statis_para, 0, sizeof(g_tsg_statis_para));
thread_num=get_thread_count();
- for(i=0; i<TSG_ACTION_MAX; i++)
+ for(i=0; i<TSG_ACTION_MAX+1; i++)
{
g_tsg_statis_para.traffic_info[i]=(struct _traffic_info *)calloc(1, sizeof(struct _traffic_info)*thread_num);
}
@@ -226,10 +256,10 @@ int tsg_statistic_init(const char *conffile, void *logger)
value=1;//Rewrite
FS_set_para(g_tsg_statis_para.fs2_handle, PRINT_MODE, &value, sizeof(value));
- value=1;//Do not create stat thread
+ value=0;//Do not create stat thread
FS_set_para(g_tsg_statis_para.fs2_handle, CREATE_THREAD, &value, sizeof(value));
-
- FS_set_para(g_tsg_statis_para.fs2_handle, STAT_CYCLE, &g_tsg_statis_para.cycle, sizeof(g_tsg_statis_para.cycle));
+
+ FS_set_para(g_tsg_statis_para.fs2_handle, STAT_CYCLE, &g_tsg_statis_para.cycle, sizeof(g_tsg_statis_para.cycle));
FS_set_para(g_tsg_statis_para.fs2_handle, APP_NAME, app_name, strlen(app_name)+1);
FS_set_para(g_tsg_statis_para.fs2_handle, OUTPUT_DEVICE, fs_output_path, strlen(fs_output_path)+1);
@@ -239,45 +269,49 @@ int tsg_statistic_init(const char *conffile, void *logger)
FS_set_para(g_tsg_statis_para.fs2_handle, STATS_SERVER_PORT,&(fs_server_port), sizeof(fs_server_port));
}
- g_tsg_statis_para.fs_field_id[STATIS_ENTRANCE_ID]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"entrance_id");
- g_tsg_statis_para.fs_field_id[STATIS_TOTAL_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"total_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_NEW_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"new_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_LIVE_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"live_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_CLOSE_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"close_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_TOTAL_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"total_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_TOTAL_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"total_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_TOTAL_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"total_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_TOTAL_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"total_out_packets");
-
- g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"default_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"default_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"default_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"default_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"default_out_packets");
-
- g_tsg_statis_para.fs_field_id[STATIS_ALLOW_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"allow_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_ALLOW_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"allow_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_ALLOW_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"allow_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_ALLOW_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"allow_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_ALLOW_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"allow_out_packets");
-
- g_tsg_statis_para.fs_field_id[STATIS_DENY_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"deny_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_DENY_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"deny_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_DENY_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"deny_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_DENY_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"deny_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_DENY_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"deny_out_packets");
-
- g_tsg_statis_para.fs_field_id[STATIS_MONITOR_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"monitor_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_MONITOR_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"monitor_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_MONITOR_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"monitor_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_MONITOR_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"monitor_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_MONITOR_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"monitor_out_packets");
-
- g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_CON_NUM]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"intercept_conn_num");
- g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_IN_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"intercept_in_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_OUT_BYTES]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"intercept_out_bytes");
- g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_IN_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"intercept_in_packets");
- g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_OUT_PACKETS]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, (char *)"intercept_out_packets");
+ value=FS_OUTPUT_INFLUX_LINE;
+ FS_set_para(g_tsg_statis_para.fs2_handle, STATS_FORMAT, &value, sizeof(value));
+
+ g_tsg_statis_para.fs_field_id[STATIS_NEW_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"new_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_ESTABLISHED_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT, (char *)"established_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_CLOSE_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"close_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_TOTAL_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"total_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_TOTAL_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"total_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_TOTAL_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"total_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_TOTAL_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"total_out_packets");
+
+ g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"default_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"default_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"default_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"default_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_DEFAULT_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"default_out_packets");
+
+ g_tsg_statis_para.fs_field_id[STATIS_ALLOW_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"allow_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_ALLOW_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"allow_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_ALLOW_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"allow_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_ALLOW_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"allow_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_ALLOW_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"allow_out_packets");
+
+ g_tsg_statis_para.fs_field_id[STATIS_DENY_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"deny_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_DENY_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"deny_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_DENY_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"deny_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_DENY_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"deny_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_DENY_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"deny_out_packets");
+
+ g_tsg_statis_para.fs_field_id[STATIS_MONITOR_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"monitor_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_MONITOR_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"monitor_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_MONITOR_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"monitor_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_MONITOR_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"monitor_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_MONITOR_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"monitor_out_packets");
+
+ g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_CON_NUM]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"intercept_conn_num");
+ g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_IN_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"intercept_in_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_OUT_BYTES]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"intercept_out_bytes");
+ g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_IN_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"intercept_in_packets");
+ g_tsg_statis_para.fs_field_id[STATIS_INTERCEPT_OUT_PACKETS]=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_COLUMN, FS_CALC_SPEED, (char *)"intercept_out_packets");
+
+
+ g_tsg_statis_para.fs_line_id=FS_register(g_tsg_statis_para.fs2_handle, FS_STYLE_LINE, FS_CALC_CURRENT, (const char *)"TRAFFIC");
pthread_t stat_thread_t;
pthread_create(&stat_thread_t, NULL, tsg_statistic_thread, NULL);