summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/business/doh/src/doh.cpp9
-rw-r--r--plugin/business/doh/src/pub.h2
-rw-r--r--plugin/business/traffic-mirror/include/traffic_mirror.h2
-rw-r--r--plugin/business/traffic-mirror/src/entry.cpp7
-rw-r--r--plugin/business/traffic-mirror/src/rebuild.cpp2
-rw-r--r--plugin/business/tsg-http/src/tsg_http.cpp16
6 files changed, 19 insertions, 19 deletions
diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp
index a8d32e8..49f8ad5 100644
--- a/plugin/business/doh/src/doh.cpp
+++ b/plugin/business/doh/src/doh.cpp
@@ -391,11 +391,10 @@ static void doh_maat_scan(const struct tfe_stream *stream, const struct tfe_http
static void doh_gc_cb(evutil_socket_t fd, short what, void *arg)
{
- int i = 0;
-
- for (i = 0; i < DOH_STAT_MAX; i++)
+ for (int i = 0; i < DOH_STAT_MAX; i++)
{
- FS_operate(g_doh_conf->fs_handle, g_doh_conf->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(g_doh_conf->stat_val[i])));
+ long long delta = ATOMIC_EXCHANGE(&(g_doh_conf->stat_val[i]), 0);
+ fieldstat_easy_counter_incrby(g_doh_conf->fs_handle, 0, g_doh_conf->fs_id[i], NULL, 0, delta);
}
}
@@ -413,7 +412,7 @@ static int doh_field_init()
{
if (spec[i] != NULL)
{
- g_doh_conf->fs_id[i] = FS_register(g_doh_conf->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, spec[i]);
+ g_doh_conf->fs_id[i] = fieldstat_easy_register_counter(g_doh_conf->fs_handle, spec[i]);
}
}
g_doh_conf->gcev = event_new(g_doh_conf->gc_evbase, -1, EV_PERSIST, doh_gc_cb, NULL);
diff --git a/plugin/business/doh/src/pub.h b/plugin/business/doh/src/pub.h
index 1b19dbf..54cc160 100644
--- a/plugin/business/doh/src/pub.h
+++ b/plugin/business/doh/src/pub.h
@@ -56,7 +56,7 @@ struct doh_conf
long long stat_val[DOH_STAT_MAX];
struct event *gcev;
struct event_base *gc_evbase;
- screen_stat_handle_t fs_handle;
+ struct fieldstat_easy *fs_handle;
struct maat *maat;
};
diff --git a/plugin/business/traffic-mirror/include/traffic_mirror.h b/plugin/business/traffic-mirror/include/traffic_mirror.h
index 4313c04..496d136 100644
--- a/plugin/business/traffic-mirror/include/traffic_mirror.h
+++ b/plugin/business/traffic-mirror/include/traffic_mirror.h
@@ -32,7 +32,7 @@ enum
struct traffic_mirror_stat
{
- screen_stat_handle_t fs_handle;
+ struct fieldstat_easy *fs_handle;
uint64_t stat_idx[TRAFFIC_MIRR_STAT_MAX];
uint64_t stat_val[TRAFFIC_MIRR_STAT_MAX];
diff --git a/plugin/business/traffic-mirror/src/entry.cpp b/plugin/business/traffic-mirror/src/entry.cpp
index 65a65d8..29805a4 100644
--- a/plugin/business/traffic-mirror/src/entry.cpp
+++ b/plugin/business/traffic-mirror/src/entry.cpp
@@ -28,7 +28,8 @@ static void stat_output_cb(evutil_socket_t fd, short what, void *arg)
struct traffic_mirror_stat *handle = (struct traffic_mirror_stat *)arg;
for (int i = 0; i < TRAFFIC_MIRR_STAT_MAX; i++)
{
- FS_operate(handle->fs_handle, handle->stat_idx[i], 0, FS_OP_SET, ATOMIC_READ(&(handle->stat_val[i])));
+ long long delta = ATOMIC_EXCHANGE(&(handle->stat_val[i]), 0);
+ fieldstat_easy_counter_incrby(handle->fs_handle, 0, handle->stat_idx[i], NULL, 0, delta);
}
}
@@ -40,7 +41,6 @@ struct traffic_mirror_stat *traffic_mirror_stat_new()
return NULL;
}
- struct timeval gc_delay = {5, 0};
const char *stat_name[TRAFFIC_MIRR_STAT_MAX] = { 0 };
stat_name[TRAFFIC_MIRR_STAT_SUCC_BYTES] = "mirr_succ_B";
stat_name[TRAFFIC_MIRR_STAT_SUCC_PKTS] = "mirr_succ_P";
@@ -50,9 +50,10 @@ struct traffic_mirror_stat *traffic_mirror_stat_new()
handle->evbase = tfe_proxy_get_gc_evbase();
for (int i = 0; i < TRAFFIC_MIRR_STAT_MAX; i++)
{
- handle->stat_idx[i] = FS_register(handle->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, stat_name[i]);
+ handle->stat_idx[i] = fieldstat_easy_register_counter(handle->fs_handle, stat_name[i]);
}
handle->ev = event_new(handle->evbase, -1, EV_PERSIST, stat_output_cb, handle);
+ struct timeval gc_delay = {0, 500 * 1000}; // Microseconds, we set 500 miliseconds here.
evtimer_add(handle->ev, &gc_delay);
return handle;
diff --git a/plugin/business/traffic-mirror/src/rebuild.cpp b/plugin/business/traffic-mirror/src/rebuild.cpp
index b595256..8558350 100644
--- a/plugin/business/traffic-mirror/src/rebuild.cpp
+++ b/plugin/business/traffic-mirror/src/rebuild.cpp
@@ -6,6 +6,8 @@
#include <marsio.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
+#define __FAVOR_BSD 1
+#include <netinet/tcp.h>
struct traffic_mirror_rebuild
{
diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp
index d3443e5..26cc7ac 100644
--- a/plugin/business/tsg-http/src/tsg_http.cpp
+++ b/plugin/business/tsg-http/src/tsg_http.cpp
@@ -152,7 +152,7 @@ struct tsg_proxy_rt
int plolicy_table_id[POLICY_PROFILE_TABLE_MAX];
ctemplate::Template * tpl_403, * tpl_404, * tpl_451;
- screen_stat_handle_t fs_handle;
+ struct fieldstat_easy *fs_handle;
long long stat_val[__PX_STAT_MAX];
int fs_id[__PX_STAT_MAX];
struct event_base* gc_evbase;
@@ -167,15 +167,13 @@ struct tsg_proxy_rt
};
struct tsg_proxy_rt * g_proxy_rt;
-static void proxy_http_gc_cb(evutil_socket_t fd, short what, void * arg)
+static void proxy_http_gc_cb(evutil_socket_t fd, short what, void *arg)
{
- int i=0;
-
- for(i=0;i<__PX_STAT_MAX;i++)
+ for (int i = 0; i < __PX_STAT_MAX; i++)
{
- FS_operate(g_proxy_rt->fs_handle, g_proxy_rt->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(g_proxy_rt->stat_val[i])));
+ long long delta = ATOMIC_EXCHANGE(&(g_proxy_rt->stat_val[i]), 0);
+ fieldstat_easy_counter_incrby(g_proxy_rt->fs_handle, 0, g_proxy_rt->fs_id[i], NULL, 0, delta);
}
- return;
}
static void proxy_http_stat_init(struct tsg_proxy_rt * pangu_runtime)
@@ -200,9 +198,9 @@ static void proxy_http_stat_init(struct tsg_proxy_rt * pangu_runtime)
for(i=0;i<__PX_STAT_MAX;i++)
{
- if(spec[i]!=NULL)
+ if (spec[i] != NULL)
{
- pangu_runtime->fs_id[i]=FS_register(pangu_runtime->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, spec[i]);
+ pangu_runtime->fs_id[i] = fieldstat_easy_register_counter(pangu_runtime->fs_handle, spec[i]);
}
}
g_proxy_rt->gcev = event_new(pangu_runtime->gc_evbase, -1, EV_PERSIST, proxy_http_gc_cb, NULL);