diff options
Diffstat (limited to 'plugin/business/traffic-mirror/src/entry.cpp')
| -rw-r--r-- | plugin/business/traffic-mirror/src/entry.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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; |
