fieldstat增加sigpipe计数。
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
add_library(common src/tfe_stat.cpp src/tfe_utils.cpp src/tfe_future.cpp src/tfe_http.cpp src/tfe_plugin.cpp src/tfe_rpc.cpp)
|
add_library(common src/tfe_utils.cpp src/tfe_future.cpp src/tfe_http.cpp src/tfe_plugin.cpp src/tfe_rpc.cpp)
|
||||||
target_include_directories(common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
target_include_directories(common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||||
target_link_libraries(common MESA_handle_logger libevent-static libevent-static-openssl libevent-static-pthreads)
|
target_link_libraries(common MESA_handle_logger libevent-static libevent-static-openssl libevent-static-pthreads)
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
#include "tfe_types.h"
|
|
||||||
enum TFE_STAT_FIELD
|
|
||||||
{
|
|
||||||
STREAM_NUM=0,
|
|
||||||
STREAM_OPEN,
|
|
||||||
STREAM_CLOSE,
|
|
||||||
STREAM_ERROR,
|
|
||||||
SSL_NUM,
|
|
||||||
SSL_OPEN,
|
|
||||||
SSL_CLOSE,
|
|
||||||
SSL_ERROR,
|
|
||||||
SNI_PEAK_FAIL,
|
|
||||||
IN_BYTES,
|
|
||||||
OUT_BYTES,
|
|
||||||
TFE_STAT_MAX
|
|
||||||
};
|
|
||||||
struct tfe_stats
|
|
||||||
{
|
|
||||||
long long value[TFE_STAT_MAX];
|
|
||||||
void * fs_handle;
|
|
||||||
|
|
||||||
int fs_ids[TFE_STAT_MAX];
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
void* tfe_stat_init(void* fs_handle)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
void tfe_stat_flush(void* handle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
|
|
||||||
#include <tfe_stream.h>
|
#include <tfe_stream.h>
|
||||||
#include <tfe_stat.h>
|
|
||||||
#include <tfe_future.h>
|
#include <tfe_future.h>
|
||||||
#include <proxy.h>
|
#include <proxy.h>
|
||||||
|
|
||||||
@@ -17,7 +16,6 @@ struct tfe_thread_ctx
|
|||||||
struct event_base * evbase;
|
struct event_base * evbase;
|
||||||
unsigned char running;
|
unsigned char running;
|
||||||
|
|
||||||
struct tfe_stats stat;
|
|
||||||
struct cert_mgr * cert_mgr;
|
struct cert_mgr * cert_mgr;
|
||||||
|
|
||||||
unsigned int nr_modules;
|
unsigned int nr_modules;
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
struct ssl_mgr;
|
struct ssl_mgr;
|
||||||
struct key_keeper;
|
struct key_keeper;
|
||||||
struct kni_acceptor;
|
struct kni_acceptor;
|
||||||
|
enum TFE_STAT_FIELD
|
||||||
|
{
|
||||||
|
STAT_SIGPIPE,
|
||||||
|
TFE_STAT_MAX
|
||||||
|
};
|
||||||
|
|
||||||
struct tfe_proxy_tcp_options
|
struct tfe_proxy_tcp_options
|
||||||
{
|
{
|
||||||
@@ -53,6 +58,11 @@ struct tfe_proxy
|
|||||||
/* DEBUG OPTIONS */
|
/* DEBUG OPTIONS */
|
||||||
unsigned int tcp_all_passthrough;
|
unsigned int tcp_all_passthrough;
|
||||||
struct tfe_proxy_tcp_options tcp_options;
|
struct tfe_proxy_tcp_options tcp_options;
|
||||||
|
|
||||||
|
/* PERFOMANCE MONIOTR VARIABLES*/
|
||||||
|
long long stat_val[TFE_STAT_MAX];
|
||||||
|
int fs_id[TFE_STAT_MAX];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <kni_acceptor.h>
|
#include <kni_acceptor.h>
|
||||||
#include <tcp_stream.h>
|
#include <tcp_stream.h>
|
||||||
#include <MESA/MESA_prof_load.h>
|
#include <MESA/MESA_prof_load.h>
|
||||||
|
#include <MESA/field_stat2.h>
|
||||||
#include <tfe_plugin.h>
|
#include <tfe_plugin.h>
|
||||||
|
|
||||||
static int signals[] = {SIGTERM, SIGQUIT, SIGHUP, SIGPIPE, SIGUSR1};
|
static int signals[] = {SIGTERM, SIGQUIT, SIGHUP, SIGPIPE, SIGUSR1};
|
||||||
@@ -127,6 +128,7 @@ static void __signal_handler_cb(evutil_socket_t fd, short what, void * arg)
|
|||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
break;
|
break;
|
||||||
case SIGPIPE:
|
case SIGPIPE:
|
||||||
|
ATOMIC_INC(&(ctx->stat_val[STAT_SIGPIPE]));
|
||||||
TFE_LOG_ERROR(ctx->logger, "Warning: Received SIGPIPE; ignoring.\n");
|
TFE_LOG_ERROR(ctx->logger, "Warning: Received SIGPIPE; ignoring.\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -138,6 +140,12 @@ 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)
|
static void __gc_handler_cb(evutil_socket_t fd, short what, void * arg)
|
||||||
{
|
{
|
||||||
tfe_proxy * ctx = (tfe_proxy *) arg;
|
tfe_proxy * ctx = (tfe_proxy *) arg;
|
||||||
|
int i=0;
|
||||||
|
for(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])));
|
||||||
|
}
|
||||||
|
|
||||||
FS_passive_output(ctx->fs_handle);
|
FS_passive_output(ctx->fs_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,6 +213,31 @@ int tfe_proxy_config(struct tfe_proxy * proxy, const char * profile)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
|
||||||
|
{
|
||||||
|
const char* fieldstat_output="./tfe.fieldstat";
|
||||||
|
const char* app_name="tfe3a";
|
||||||
|
int value=0, i=0;
|
||||||
|
screen_stat_handle_t fs_handle=NULL;
|
||||||
|
fs_handle=FS_create_handle();
|
||||||
|
FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, strlen(fieldstat_output)+1);
|
||||||
|
value=1;
|
||||||
|
FS_set_para(fs_handle, PRINT_MODE, &value, sizeof(value));
|
||||||
|
value=0;
|
||||||
|
FS_set_para(fs_handle, CREATE_THREAD, &value, sizeof(value));
|
||||||
|
FS_set_para(fs_handle, APP_NAME, app_name, strlen(app_name)+1);
|
||||||
|
|
||||||
|
const char* spec[TFE_STAT_MAX];
|
||||||
|
spec[STAT_SIGPIPE]="sigpipe";
|
||||||
|
|
||||||
|
for(i=0;i<TFE_STAT_MAX; i++)
|
||||||
|
{
|
||||||
|
proxy->fs_id[i]=FS_register(fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT,spec[i]);
|
||||||
|
}
|
||||||
|
FS_start(fs_handle);
|
||||||
|
proxy->fs_handle=fs_handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CHECK_OR_EXIT(condition, fmt, ...) \
|
#define CHECK_OR_EXIT(condition, fmt, ...) \
|
||||||
@@ -213,7 +246,6 @@ do { if(!(condition)) { TFE_LOG_ERROR(g_default_logger, fmt, ##__VA_ARGS__); exi
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char* main_profile="./conf/tfe.conf";
|
const char* main_profile="./conf/tfe.conf";
|
||||||
const char* fieldstat_output="./tfe.fieldstat";
|
|
||||||
|
|
||||||
g_default_logger = MESA_create_runtime_log_handle("log/tfe.log", RLOG_LV_DEBUG);
|
g_default_logger = MESA_create_runtime_log_handle("log/tfe.log", RLOG_LV_DEBUG);
|
||||||
if (unlikely(g_default_logger == NULL))
|
if (unlikely(g_default_logger == NULL))
|
||||||
@@ -234,14 +266,7 @@ int main(int argc, char *argv[])
|
|||||||
CHECK_OR_EXIT(ret == 0, "Failed at loading profile %s, Exit.", main_profile);
|
CHECK_OR_EXIT(ret == 0, "Failed at loading profile %s, Exit.", main_profile);
|
||||||
|
|
||||||
/* PERFOMANCE MONITOR */
|
/* PERFOMANCE MONITOR */
|
||||||
g_default_proxy->fs_handle=FS_create_handle();
|
tfe_stat_init(g_default_proxy, main_profile);
|
||||||
FS_set_para(g_default_proxy->fs_handle, OUTPUT_DEVICE, fieldstat_output, strlen(fieldstat_output)+1);
|
|
||||||
int value=1;
|
|
||||||
FS_set_para(g_default_proxy->fs_handle, PRINT_MODE, &value, sizeof(value));
|
|
||||||
value=0;
|
|
||||||
FS_set_para(g_default_proxy->fs_handle, CREATE_THREAD, &value, sizeof(value));
|
|
||||||
FS_set_para(g_default_proxy->fs_handle, APP_NAME, g_default_proxy->name, strlen(g_default_proxy->name)+1);
|
|
||||||
FS_start(g_default_proxy->fs_handle);
|
|
||||||
|
|
||||||
/* LOGGER */
|
/* LOGGER */
|
||||||
g_default_proxy->logger = g_default_logger;
|
g_default_proxy->logger = g_default_logger;
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ ssl_stream_gc_cb(evutil_socket_t fd, short what, void * arg)
|
|||||||
int i=0;
|
int i=0;
|
||||||
for(i=0;i<SSL_STAT_MAX;i++)
|
for(i=0;i<SSL_STAT_MAX;i++)
|
||||||
{
|
{
|
||||||
FS_operate(mgr->fs_handle, i, 0, FS_OP_SET, ATOMIC_READ(&(mgr->stat_val[i])));
|
FS_operate(mgr->fs_handle, mgr->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(mgr->stat_val[i])));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user