TSG-23378 TFE移除平台层的FieldStat2,为适配AArch64做准备
This commit is contained in:
@@ -122,7 +122,7 @@ struct tfe_proxy
|
||||
struct event * gcev;
|
||||
|
||||
void * logger;
|
||||
void * fs_handle;
|
||||
struct fieldstat_easy *fs_handle;
|
||||
unsigned int nr_work_threads;
|
||||
struct tfe_thread_ctx * work_threads[TFE_THREAD_MAX];
|
||||
int make_work_thread_sleep;
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
#include <openssl/ssl.h>
|
||||
#include <tfe_stream.h>
|
||||
|
||||
struct sess_cache_stat
|
||||
{
|
||||
long long size;
|
||||
long long query_cnt;
|
||||
long long hit_cnt;
|
||||
long long miss_cnt;
|
||||
long long del_err;
|
||||
};
|
||||
|
||||
struct sess_cache;
|
||||
struct sess_cache * ssl_sess_cache_create(unsigned int slot_size, unsigned int expire_seconds, enum tfe_conn_dir served);
|
||||
void ssl_sess_cache_destroy(struct sess_cache * cache);
|
||||
@@ -14,4 +23,4 @@ SSL_SESSION * up_session_get(struct sess_cache * cache, struct sockaddr * addr,
|
||||
void down_session_set(struct sess_cache * cache, const SSL_SESSION * sess);
|
||||
void down_session_del(struct sess_cache * cache, const SSL_SESSION * sess);
|
||||
SSL_SESSION * down_session_get(struct sess_cache * cache, const unsigned char * id, int idlen);
|
||||
void ssl_sess_cache_stat(struct sess_cache * cache, long long *size, long long* n_query,long long* n_hit);
|
||||
void ssl_sess_cache_stat(struct sess_cache *cache, struct sess_cache_stat *stat);
|
||||
@@ -419,7 +419,7 @@ static void certstore_rpc_on_succ(void* result, void* user)
|
||||
TFE_LOG_DEBUG(ctx->ref_keeper->logger, "Key keeper cache add key: %s", ctx->key);
|
||||
}
|
||||
}
|
||||
ctx->ref_keeper->stat.new_issue++;
|
||||
ATOMIC_INC(&(ctx->ref_keeper->stat.new_issue));
|
||||
promise_success(p, (void*)kyr);
|
||||
key_keeper_free_keyring((struct keyring*)kyr);
|
||||
}
|
||||
@@ -735,7 +735,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
ctx->key_len = len;
|
||||
promise_set_ctx(p, (void*)ctx, key_keeper_promise_free_ctx);
|
||||
long int cb_rtn = 0;
|
||||
keeper->stat.ask_times++;
|
||||
ATOMIC_INC(&(keeper->stat.ask_times));
|
||||
if(!keeper->no_cache)
|
||||
{
|
||||
char *tmp = tfe_strdup((const char *)ctx->key);
|
||||
@@ -821,7 +821,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
}
|
||||
}
|
||||
promise_success(p, (void*)kyr);
|
||||
keeper->stat.new_issue++;
|
||||
ATOMIC_INC(&(keeper->stat.new_issue));
|
||||
key_keeper_free_keyring((struct keyring*)kyr);
|
||||
}
|
||||
else
|
||||
@@ -833,14 +833,13 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
}
|
||||
return;
|
||||
}
|
||||
void key_keeper_statistic(struct key_keeper *keeper, struct key_keeper_stat* result)
|
||||
void key_keeper_statistic(struct key_keeper *keeper, struct key_keeper_stat *result)
|
||||
{
|
||||
if (!keeper->no_cache)
|
||||
{
|
||||
// pthread_rwlock_rdlock(&(keeper->rwlock));
|
||||
keeper->stat.cached_num=MESA_htable_get_elem_num(keeper->cert_cache);
|
||||
// pthread_rwlock_unlock(&(keeper->rwlock));
|
||||
result->cached_num = MESA_htable_get_elem_num(keeper->cert_cache);
|
||||
}
|
||||
*result = keeper->stat;
|
||||
return;
|
||||
|
||||
result->ask_times = ATOMIC_READ(&(keeper->stat.ask_times));
|
||||
result->new_issue = ATOMIC_READ(&(keeper->stat.new_issue));
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
#include <fieldstat/fieldstat_easy.h>
|
||||
|
||||
#include <tfe_utils.h>
|
||||
#include <tfe_future.h>
|
||||
@@ -299,17 +299,16 @@ static void __signal_handler_cb(evutil_socket_t fd, short what, void * arg)
|
||||
|
||||
static void __gc_handler_cb(evutil_socket_t fd, short what, void * arg)
|
||||
{
|
||||
tfe_proxy * ctx = (tfe_proxy *) arg;
|
||||
int i = 0;
|
||||
for (i = 0; i < TFE_STAT_MAX; i++)
|
||||
tfe_proxy *ctx = (tfe_proxy *)arg;
|
||||
for (int i = 0; i < TFE_STAT_MAX; i++)
|
||||
{
|
||||
FS_operate(ctx->fs_handle, ctx->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(ctx->stat_val[i])));
|
||||
long long delta = ATOMIC_EXCHANGE(&(ctx->stat_val[i]), 0);
|
||||
fieldstat_easy_counter_incrby(ctx->fs_handle, 0, ctx->fs_id[i], NULL, 0, delta);
|
||||
}
|
||||
|
||||
if (ctx->kni_v4_acceptor != NULL)
|
||||
packet_io_fs_dump(ctx->kni_v4_acceptor->packet_io_fs);
|
||||
|
||||
FS_passive_output(ctx->fs_handle);
|
||||
timestamp_update();
|
||||
return;
|
||||
}
|
||||
@@ -498,54 +497,21 @@ static const char * __str_stat_spec_map[] =
|
||||
[TFE_STAT_MAX] = NULL
|
||||
};
|
||||
|
||||
int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
|
||||
int tfe_stat_init(struct tfe_proxy *proxy, const char *profile)
|
||||
{
|
||||
static const char * fieldstat_output = "log/tfe.fs2";
|
||||
static const char * app_name = "tfe3a";
|
||||
int output_cycle = 0;
|
||||
char output_file[TFE_STRING_MAX] = {0};
|
||||
MESA_load_profile_string_def(profile, "STAT", "output_file", output_file, sizeof(output_file), "log/tfe.fs4");
|
||||
MESA_load_profile_int_def(profile, "STAT", "output_cycle", &(output_cycle), 5);
|
||||
|
||||
int value = 0, i = 0;
|
||||
screen_stat_handle_t fs_handle = NULL;
|
||||
char statsd_server_ip[TFE_SYMBOL_MAX]={0};
|
||||
char histogram_bins[TFE_SYMBOL_MAX]={0};
|
||||
int statsd_format=0;
|
||||
int statsd_server_port=0;
|
||||
MESA_load_profile_string_def(profile, "STAT", "statsd_server", statsd_server_ip,
|
||||
sizeof(statsd_server_ip), "");
|
||||
MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(statsd_server_port), 0);
|
||||
// FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
|
||||
MESA_load_profile_int_def(profile, "STAT", "statsd_format", &(statsd_format), 1);
|
||||
MESA_load_profile_string_def(profile, "STAT", "histogram_bins",
|
||||
histogram_bins, sizeof(histogram_bins), "0.5,0.8,0.9,0.95");
|
||||
proxy->fs_handle = fieldstat_easy_new(1, "tfe", NULL, 0);
|
||||
fieldstat_easy_enable_auto_output(proxy->fs_handle, output_file, output_cycle);
|
||||
|
||||
if (statsd_format != 1 && statsd_format != 2)
|
||||
for (int i = 0; i < TFE_STAT_MAX; i++)
|
||||
{
|
||||
statsd_format = 1;
|
||||
proxy->fs_id[i] = fieldstat_easy_register_counter(proxy->fs_handle, __str_stat_spec_map[i]);
|
||||
}
|
||||
|
||||
fs_handle = FS_create_handle();
|
||||
FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, (int)strlen(fieldstat_output) + 1);
|
||||
FS_set_para(fs_handle, APP_NAME, app_name, (int)strlen(app_name) + 1);
|
||||
value = 1;
|
||||
FS_set_para(fs_handle, OUTPUT_PROMETHEUS, &value, sizeof(value));
|
||||
value = 1;
|
||||
FS_set_para(fs_handle, PRINT_MODE, &value, sizeof(value));
|
||||
value = 0;
|
||||
FS_set_para(fs_handle, CREATE_THREAD, &value, sizeof(value));
|
||||
if(strlen(statsd_server_ip)>0 && statsd_server_port!=0)
|
||||
{
|
||||
FS_set_para(fs_handle, STATS_SERVER_IP, statsd_server_ip, strlen(statsd_server_ip)+1);
|
||||
FS_set_para(fs_handle, STATS_SERVER_PORT, &(statsd_server_port), sizeof(statsd_server_port));
|
||||
FS_set_para(fs_handle, STATS_FORMAT, &statsd_format, sizeof(statsd_format));
|
||||
}
|
||||
FS_set_para(fs_handle, HISTOGRAM_GLOBAL_BINS, histogram_bins, strlen(histogram_bins)+1);
|
||||
|
||||
for (i = 0; i < TFE_STAT_MAX; i++)
|
||||
{
|
||||
proxy->fs_id[i] = FS_register(fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, __str_stat_spec_map[i]);
|
||||
}
|
||||
|
||||
FS_start(fs_handle);
|
||||
proxy->fs_handle = fs_handle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -651,7 +617,7 @@ int main(int argc, char * argv[])
|
||||
/* PROXY INSTANCE */
|
||||
g_default_proxy = ALLOC(struct tfe_proxy, 1);
|
||||
assert(g_default_proxy);
|
||||
strcpy(g_default_proxy->name, "tfe3a");
|
||||
strcpy(g_default_proxy->name, "tfe");
|
||||
|
||||
g_default_proxy->breakpad = breakpad_init(main_profile, "system", g_default_logger, tfe_version());
|
||||
CHECK_OR_EXIT(g_default_proxy->breakpad, "Failed at starting breakpad. Exit.");
|
||||
@@ -661,14 +627,6 @@ int main(int argc, char * argv[])
|
||||
breakpad_segv_generate();
|
||||
}
|
||||
|
||||
int prometheus_port = 9001;
|
||||
char prometheus_url_path[1024] = {0};
|
||||
MESA_load_profile_int_def(main_profile, "STAT", "statsd_set_prometheus_port", &(prometheus_port), 9001);
|
||||
MESA_load_profile_string_def(main_profile, "STAT", "statsd_set_prometheus_url_path", prometheus_url_path, sizeof(prometheus_url_path), "/tfe_prometheus");
|
||||
FS_library_set_prometheus_port(prometheus_port);
|
||||
FS_library_set_prometheus_url_path(prometheus_url_path);
|
||||
FS_library_init();
|
||||
|
||||
future_promise_library_init(future_profile);
|
||||
/* CONFIG */
|
||||
ret = tfe_proxy_config(g_default_proxy, main_profile);
|
||||
@@ -706,9 +664,7 @@ int main(int argc, char * argv[])
|
||||
CHECK_OR_EXIT(g_default_proxy->sev[i], "Failed at create signal event. Exit.");
|
||||
evsignal_add(g_default_proxy->sev[i], NULL);
|
||||
}
|
||||
int statsd_cycle = 0;
|
||||
MESA_load_profile_int_def(main_profile, "STAT", "statsd_cycle", &(statsd_cycle), 2);
|
||||
struct timeval gc_delay = {statsd_cycle, 0};
|
||||
struct timeval gc_delay = {0, 500 * 1000}; // Microseconds, we set 500 miliseconds here.
|
||||
evtimer_add(g_default_proxy->gcev, &gc_delay);
|
||||
|
||||
timestamp_update();
|
||||
@@ -809,7 +765,7 @@ struct event_base * tfe_proxy_get_gc_evbase(void)
|
||||
return g_default_proxy->evbase;
|
||||
}
|
||||
|
||||
screen_stat_handle_t tfe_proxy_get_fs_handle(void)
|
||||
struct fieldstat_easy *tfe_proxy_get_fs_handle(void)
|
||||
{
|
||||
return g_default_proxy->fs_handle;
|
||||
}
|
||||
|
||||
@@ -43,16 +43,16 @@ static void ssl_svc_free_client_st(void * data)
|
||||
struct ssl_service_cache* svc_cache=p->ref_svc_cache;
|
||||
if(p->is_mutual_auth)
|
||||
{
|
||||
svc_cache->stat.mutual_auth_cli_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.mutual_auth_cli_cnt));
|
||||
}
|
||||
if(p->suspect_pinning_count>=svc_cache->fail_as_cli_pinning_count)
|
||||
{
|
||||
svc_cache->stat.pinning_cli_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.pinning_cli_cnt));
|
||||
}
|
||||
|
||||
if (p->protocol_error_count >= svc_cache->fail_as_proto_err_count)
|
||||
{
|
||||
svc_cache->stat.proto_err_cli_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.proto_err_cli_cnt));
|
||||
}
|
||||
|
||||
free(p);
|
||||
@@ -64,11 +64,11 @@ static void ssl_svc_free_server_st(void * data)
|
||||
struct ssl_service_cache* svc_cache=p->ref_svc_cache;
|
||||
if(p->is_ct)
|
||||
{
|
||||
svc_cache->stat.ct_srv_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.ct_srv_cnt));
|
||||
}
|
||||
if(p->is_ev)
|
||||
{
|
||||
svc_cache->stat.ev_srv_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.ev_srv_cnt));
|
||||
}
|
||||
free(p);
|
||||
return;
|
||||
@@ -79,7 +79,7 @@ static void ssl_svc_free_app_st(void *data)
|
||||
struct ssl_service_cache *svc_cache = p->ref_svc_cache;
|
||||
if (p->down_ssl_success_cnt > svc_cache->succ_as_app_not_pinning_count)
|
||||
{
|
||||
svc_cache->stat.app_not_pinning_cnt--;
|
||||
ATOMIC_DEC(&(svc_cache->stat.app_not_pinning_cnt));
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ static long cli_st_write_cb(void * data, const uchar * key, uint size, void * us
|
||||
}
|
||||
if(cli_st->suspect_pinning_count==cache->fail_as_cli_pinning_count)
|
||||
{
|
||||
cache->stat.pinning_cli_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.pinning_cli_cnt));
|
||||
}
|
||||
}
|
||||
else if(status->cli_pinning_status==PINNING_ST_PINNING)
|
||||
@@ -201,12 +201,12 @@ static long cli_st_write_cb(void * data, const uchar * key, uint size, void * us
|
||||
cli_st->protocol_error_count++;
|
||||
if(cli_st->protocol_error_count==cache->fail_as_proto_err_count)
|
||||
{
|
||||
cache->stat.proto_err_cli_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.proto_err_cli_cnt));
|
||||
}
|
||||
}
|
||||
if(status->is_mutual_auth==1&&cli_st->is_mutual_auth==0)
|
||||
{
|
||||
cache->stat.mutual_auth_cli_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.mutual_auth_cli_cnt));
|
||||
cli_st->is_mutual_auth=1;
|
||||
}
|
||||
cli_st->last_update_time=now;
|
||||
@@ -243,7 +243,7 @@ static long srv_st_write_cb(void * data, const uchar * key, uint size, void * us
|
||||
if(status->is_ev==1&&srv_st->is_ev==0)
|
||||
{
|
||||
srv_st->is_ev=1;
|
||||
cache->stat.ev_srv_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.ev_srv_cnt));
|
||||
}
|
||||
if(status->is_ev!=srv_st->is_ev)
|
||||
{
|
||||
@@ -252,7 +252,7 @@ static long srv_st_write_cb(void * data, const uchar * key, uint size, void * us
|
||||
if(status->is_ct==1&&srv_st->is_ct==0)
|
||||
{
|
||||
srv_st->is_ct=1;
|
||||
cache->stat.ct_srv_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.ct_srv_cnt));
|
||||
}
|
||||
if(status->is_ct!=srv_st->is_ct)
|
||||
{
|
||||
@@ -297,7 +297,7 @@ static long app_st_write_cb(void *data, const uchar *key, uint size, void *user_
|
||||
}
|
||||
if (app_st->down_ssl_success_cnt > cache->succ_as_app_not_pinning_count)
|
||||
{
|
||||
cache->stat.app_not_pinning_cnt++;
|
||||
ATOMIC_INC(&(cache->stat.app_not_pinning_cnt));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -462,8 +462,13 @@ void ssl_service_cache_destroy(struct ssl_service_cache* cache)
|
||||
free(cache);
|
||||
return;
|
||||
}
|
||||
void ssl_service_cache_stat(struct ssl_service_cache* svc_cache, struct ssl_service_cache_statistics* result)
|
||||
void ssl_service_cache_stat(struct ssl_service_cache *svc_cache, struct ssl_service_cache_statistics *result)
|
||||
{
|
||||
*result=svc_cache->stat;
|
||||
return;
|
||||
result->pinning_cli_cnt = ATOMIC_READ(&(svc_cache->stat.pinning_cli_cnt));
|
||||
result->mutual_auth_cli_cnt = ATOMIC_READ(&(svc_cache->stat.mutual_auth_cli_cnt));
|
||||
result->proto_err_cli_cnt = ATOMIC_READ(&(svc_cache->stat.proto_err_cli_cnt));
|
||||
result->ev_srv_cnt = ATOMIC_READ(&(svc_cache->stat.ev_srv_cnt));
|
||||
result->ct_srv_cnt = ATOMIC_READ(&(svc_cache->stat.ct_srv_cnt));
|
||||
result->app_not_pinning_cnt = ATOMIC_READ(&(svc_cache->stat.app_not_pinning_cnt));
|
||||
result->trusted_cert_cnt = ATOMIC_READ(&(svc_cache->stat.trusted_cert_cnt));
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <tfe_utils.h>
|
||||
|
||||
#include <MESA/MESA_htable.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
#include <fieldstat/fieldstat_easy.h>
|
||||
|
||||
#define SESS_CACHE_NOT_FOUND -1
|
||||
#define SESS_CACHE_FOUND 0
|
||||
@@ -35,7 +35,7 @@ struct sess_cache
|
||||
{
|
||||
enum tfe_conn_dir served_for;
|
||||
MESA_htable_handle hash;
|
||||
long long hit_cnt, miss_cnt, del_err;
|
||||
struct sess_cache_stat stat;
|
||||
};
|
||||
|
||||
static void ssl_sess_free_serialized(void * data)
|
||||
@@ -231,12 +231,12 @@ SSL_SESSION * up_session_get(struct sess_cache * cache, struct sockaddr * addr,
|
||||
key = NULL;
|
||||
if (cb_ret == SESS_CACHE_FOUND && args.version>=min_ver && args.version<=max_ver)
|
||||
{
|
||||
ATOMIC_INC(&(cache->hit_cnt));
|
||||
ATOMIC_INC(&(cache->stat.hit_cnt));
|
||||
return args.sess;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_INC(&(cache->miss_cnt));
|
||||
ATOMIC_INC(&(cache->stat.miss_cnt));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -275,12 +275,12 @@ SSL_SESSION * down_session_get(struct sess_cache * cache, const unsigned char *
|
||||
MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_get_cb, &result, &cb_ret);
|
||||
if (cb_ret == SESS_CACHE_FOUND)
|
||||
{
|
||||
ATOMIC_INC(&(cache->hit_cnt));
|
||||
ATOMIC_INC(&(cache->stat.hit_cnt));
|
||||
return result.sess;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_INC(&(cache->miss_cnt));
|
||||
ATOMIC_INC(&(cache->stat.miss_cnt));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ void down_session_del(struct sess_cache * cache, const SSL_SESSION * sess)
|
||||
int ret = MESA_htable_del(cache->hash, id, len, NULL);
|
||||
if (ret != MESA_HTABLE_RET_OK)
|
||||
{
|
||||
ATOMIC_INC(&(cache->del_err));
|
||||
ATOMIC_INC(&(cache->stat.del_err));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -337,11 +337,11 @@ void ssl_sess_cache_destroy(struct sess_cache * cache)
|
||||
free(cache);
|
||||
return;
|
||||
}
|
||||
void ssl_sess_cache_stat(struct sess_cache * cache, long long *size, long long *n_query, long long* n_hit)
|
||||
void ssl_sess_cache_stat(struct sess_cache *cache, struct sess_cache_stat *stat)
|
||||
{
|
||||
*size=MESA_htable_get_elem_num(cache->hash);
|
||||
*n_hit=cache->hit_cnt;
|
||||
*n_query=cache->hit_cnt+cache->miss_cnt;
|
||||
return;
|
||||
stat->size = MESA_htable_get_elem_num(cache->hash);
|
||||
stat->hit_cnt = ATOMIC_READ(&(cache->stat.hit_cnt));
|
||||
stat->miss_cnt = ATOMIC_READ(&(cache->stat.miss_cnt));
|
||||
stat->del_err = ATOMIC_READ(&(cache->stat.del_err));
|
||||
stat->query_cnt = stat->hit_cnt + stat->miss_cnt;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ struct ssl_mgr
|
||||
FILE* fp_master_key;
|
||||
|
||||
void * logger;
|
||||
screen_stat_handle_t fs_handle;
|
||||
struct fieldstat_easy *fs_handle;
|
||||
long long stat_val[SSL_STAT_MAX];
|
||||
int fs_id[SSL_STAT_MAX];
|
||||
};
|
||||
@@ -350,36 +350,54 @@ const char* ssl_stream_get_error_string(enum ssl_stream_error error)
|
||||
/*
|
||||
* Garbage collection handler.
|
||||
*/
|
||||
static void
|
||||
ssl_stream_gc_cb(evutil_socket_t fd, short what, void * arg)
|
||||
static void ssl_stream_gc_cb(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct ssl_mgr *mgr=(struct ssl_mgr *)arg;
|
||||
int i=0;
|
||||
if(!mgr->no_sesscache)
|
||||
struct ssl_mgr *mgr = (struct ssl_mgr *)arg;
|
||||
if (!mgr->no_sesscache)
|
||||
{
|
||||
ssl_sess_cache_stat(mgr->up_sess_cache, &(mgr->stat_val[SSL_UP_CACHE_SZ]), &(mgr->stat_val[SSL_UP_CACHE_QUERY]), &(mgr->stat_val[SSL_UP_CACHE_HIT]));
|
||||
ssl_sess_cache_stat(mgr->down_sess_cache, &(mgr->stat_val[SSL_DOWN_CACHE_SZ]), &(mgr->stat_val[SSL_DOWN_CACHE_QUERY]), &(mgr->stat_val[SSL_DOWN_CACHE_HIT]));
|
||||
}
|
||||
struct key_keeper_stat keeper_stat = { 0 };
|
||||
key_keeper_statistic(mgr->key_keeper, &keeper_stat);
|
||||
mgr->stat_val[KEY_KEEPER_ASK]=keeper_stat.ask_times;
|
||||
mgr->stat_val[KEY_KEEPER_ISSUE]=keeper_stat.new_issue;
|
||||
mgr->stat_val[KEY_KEEPER_CACHE_SIZE]=keeper_stat.cached_num;
|
||||
struct sess_cache_stat usc_curr_stat = {0};
|
||||
struct sess_cache_stat dsc_curr_stat = {0};
|
||||
static struct sess_cache_stat usc_last_stat = {0};
|
||||
static struct sess_cache_stat dsc_last_stat = {0};
|
||||
|
||||
struct ssl_service_cache_statistics svc_stat;
|
||||
memset(&svc_stat, 0, sizeof(svc_stat));
|
||||
ssl_service_cache_stat(mgr->svc_cache, &svc_stat);
|
||||
mgr->stat_val[SSL_SVC_PINNING]=svc_stat.pinning_cli_cnt;
|
||||
mgr->stat_val[SSL_SVC_MAUTH]=svc_stat.mutual_auth_cli_cnt;
|
||||
mgr->stat_val[SSL_SVC_CT_CERT]=svc_stat.ct_srv_cnt;
|
||||
mgr->stat_val[SSL_SVC_EV_CERT]=svc_stat.ev_srv_cnt;
|
||||
mgr->stat_val[SSL_SVC_APP_NOT_PINNING]=svc_stat.app_not_pinning_cnt;
|
||||
mgr->stat_val[SSL_SVC_TRUSTED_CERT]=svc_stat.trusted_cert_cnt;
|
||||
for(i=0;i<SSL_STAT_MAX;i++)
|
||||
{
|
||||
FS_operate(mgr->fs_handle, mgr->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(mgr->stat_val[i])));
|
||||
ssl_sess_cache_stat(mgr->up_sess_cache, &usc_curr_stat);
|
||||
mgr->stat_val[SSL_UP_CACHE_SZ] = usc_curr_stat.size - usc_last_stat.size;
|
||||
mgr->stat_val[SSL_UP_CACHE_QUERY] = usc_curr_stat.query_cnt - usc_last_stat.query_cnt;
|
||||
mgr->stat_val[SSL_UP_CACHE_HIT] = usc_curr_stat.hit_cnt- usc_last_stat.hit_cnt;
|
||||
usc_last_stat = usc_curr_stat;
|
||||
|
||||
ssl_sess_cache_stat(mgr->down_sess_cache, &dsc_curr_stat);
|
||||
mgr->stat_val[SSL_DOWN_CACHE_SZ] = dsc_curr_stat.size - dsc_last_stat.size;
|
||||
mgr->stat_val[SSL_DOWN_CACHE_QUERY] = dsc_curr_stat.query_cnt - dsc_last_stat.query_cnt;
|
||||
mgr->stat_val[SSL_DOWN_CACHE_HIT] = dsc_curr_stat.hit_cnt - dsc_last_stat.hit_cnt;
|
||||
dsc_last_stat = dsc_curr_stat;
|
||||
}
|
||||
if(mgr->log_master_key && mgr->fp_master_key)
|
||||
|
||||
struct key_keeper_stat keeper_curr_stat = {0};
|
||||
static struct key_keeper_stat keeper_last_stat = {0};
|
||||
key_keeper_statistic(mgr->key_keeper, &keeper_curr_stat);
|
||||
mgr->stat_val[KEY_KEEPER_ASK] = keeper_curr_stat.ask_times - keeper_last_stat.ask_times;
|
||||
mgr->stat_val[KEY_KEEPER_ISSUE] = keeper_curr_stat.new_issue - keeper_last_stat.new_issue;
|
||||
mgr->stat_val[KEY_KEEPER_CACHE_SIZE] = keeper_curr_stat.cached_num - keeper_last_stat.cached_num;
|
||||
keeper_last_stat = keeper_curr_stat;
|
||||
|
||||
struct ssl_service_cache_statistics svc_curr_stat = {0};
|
||||
static struct ssl_service_cache_statistics svc_last_stat = {0};
|
||||
ssl_service_cache_stat(mgr->svc_cache, &svc_curr_stat);
|
||||
mgr->stat_val[SSL_SVC_PINNING] = svc_curr_stat.pinning_cli_cnt - svc_last_stat.pinning_cli_cnt;
|
||||
mgr->stat_val[SSL_SVC_MAUTH] = svc_curr_stat.mutual_auth_cli_cnt - svc_last_stat.mutual_auth_cli_cnt;
|
||||
mgr->stat_val[SSL_SVC_CT_CERT] = svc_curr_stat.ct_srv_cnt - svc_last_stat.ct_srv_cnt;
|
||||
mgr->stat_val[SSL_SVC_EV_CERT] = svc_curr_stat.ev_srv_cnt - svc_last_stat.ev_srv_cnt;
|
||||
mgr->stat_val[SSL_SVC_APP_NOT_PINNING] = svc_curr_stat.app_not_pinning_cnt - svc_last_stat.app_not_pinning_cnt;
|
||||
mgr->stat_val[SSL_SVC_TRUSTED_CERT] = svc_curr_stat.trusted_cert_cnt - svc_last_stat.trusted_cert_cnt;
|
||||
svc_last_stat = svc_curr_stat;
|
||||
|
||||
for (int i = 0; i < SSL_STAT_MAX; i++)
|
||||
{
|
||||
long long delta = ATOMIC_EXCHANGE(&(mgr->stat_val[i]), 0);
|
||||
fieldstat_easy_counter_incrby(mgr->fs_handle, 0, mgr->fs_id[i], NULL, 0, delta);
|
||||
}
|
||||
if (mgr->log_master_key && mgr->fp_master_key)
|
||||
{
|
||||
fflush(mgr->fp_master_key);
|
||||
}
|
||||
@@ -434,58 +452,14 @@ void ssl_stat_init(struct ssl_mgr * mgr)
|
||||
|
||||
spec[SSL_SVC_TRUSTED_CERT]="trusted_cert_nums";
|
||||
|
||||
|
||||
for(i=0;i<SSL_STAT_MAX;i++)
|
||||
for (i = 0; i < SSL_STAT_MAX; i++)
|
||||
{
|
||||
if(spec[i]!=NULL)
|
||||
if (spec[i] != NULL)
|
||||
{
|
||||
mgr->fs_id[i]=FS_register(mgr->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT,spec[i]);
|
||||
mgr->fs_id[i] = fieldstat_easy_register_counter(mgr->fs_handle, spec[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int value=mgr->fs_id[SSL_UP_CACHE_HIT];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
value=mgr->fs_id[SSL_UP_CACHE_QUERY];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
|
||||
FS_register_ratio(mgr->fs_handle,
|
||||
mgr->fs_id[SSL_UP_CACHE_HIT],
|
||||
mgr->fs_id[SSL_UP_CACHE_QUERY],
|
||||
1,
|
||||
FS_STYLE_STATUS,
|
||||
FS_CALC_CURRENT,
|
||||
"usess_hit");
|
||||
|
||||
value=mgr->fs_id[SSL_DOWN_CACHE_HIT];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
value=mgr->fs_id[SSL_DOWN_CACHE_QUERY];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
|
||||
FS_register_ratio(mgr->fs_handle,
|
||||
mgr->fs_id[SSL_DOWN_CACHE_HIT],
|
||||
mgr->fs_id[SSL_DOWN_CACHE_QUERY],
|
||||
1,
|
||||
FS_STYLE_STATUS,
|
||||
FS_CALC_CURRENT,
|
||||
"dsess_hit");
|
||||
|
||||
if(!mgr->no_sessticket)
|
||||
{
|
||||
value=mgr->fs_id[SSL_DOWN_TIKCET_QUERY];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
|
||||
value=mgr->fs_id[SSL_DOWN_TICKET_REUSE];
|
||||
FS_set_para(mgr->fs_handle, ID_INVISBLE, &value, sizeof(value));
|
||||
|
||||
FS_register_ratio(mgr->fs_handle,
|
||||
mgr->fs_id[SSL_DOWN_TICKET_REUSE],
|
||||
mgr->fs_id[SSL_DOWN_TIKCET_QUERY],
|
||||
1,
|
||||
FS_STYLE_STATUS,
|
||||
FS_CALC_CURRENT,
|
||||
"dtkt_hit");
|
||||
}
|
||||
|
||||
struct timeval gc_delay = {0, 500*1000}; //Microseconds, we set 500 miliseconds here.
|
||||
mgr->gcev = event_new(mgr->ev_base_gc, -1, EV_PERSIST, ssl_stream_gc_cb, mgr);
|
||||
evtimer_add(mgr->gcev, &gc_delay);
|
||||
|
||||
Reference in New Issue
Block a user