#include "field_stat2.h" #include #include #include #include #include #define TEST_STATUS_NUM 4 #define TEST_FIELD_NUM 9 #define TEST_LINE_NUM 7 #define TEST_COLUMN_NUM 8 #define TEST_HISTOGRAM_NUM 4 #define TEST_RUNTIME_REG_NUM 32 #define TEST_RUNTIME_REG_LINE_NUM 6 int main(int argc,char* argv[]) { screen_stat_handle_t handle=NULL; const char* stat_path="./fs2_test.status"; const char* app_name="fs2_test"; char buff[128]; int value=0,i=0,j=0,runtime_reg_num=0,runtime_reg_line_num=0,ret=0; int loops=10; unsigned short port=9001; FS_library_set_prometheus_port(port); char *url_path=(char *)"/prometheus"; FS_library_set_prometheus_url_path(url_path); FS_library_init(); handle=FS_create_handle(); FS_set_para(handle, APP_NAME, app_name, strlen(app_name)+1); value=0; FS_set_para(handle, FLUSH_BY_DATE, &value, sizeof(value)); FS_set_para(handle, OUTPUT_DEVICE, stat_path, strlen(stat_path)+1); value=1; FS_set_para(handle, PRINT_MODE, &value, sizeof(value)); value=1; FS_set_para(handle, CREATE_THREAD, &value, sizeof(value)); value=0; FS_set_para(handle, METRIS_FORMAT, &value, sizeof(value)); value=2; FS_set_para(handle, STAT_CYCLE, &value, sizeof(value)); value=4096; FS_set_para(handle, MAX_STAT_FIELD_NUM, &value, sizeof(value)); FS_set_para(handle, STATS_SERVER_IP, "127.0.0.1", strlen("127.0.0.1")); value=8100; FS_set_para(handle, STATS_SERVER_PORT, &value, sizeof(value)); //value=FS_OUTPUT_INFLUX_LINE; value=FS_OUTPUT_STATSD; FS_set_para(handle, STATS_FORMAT, &value, sizeof(value)); value=1; FS_set_para(handle, OUTPUT_PROMETHEUS, &value, sizeof(value)); const char* histogram_format="0.1,0.5,0.8,0.9,0.95,0.99"; FS_set_para(handle, HISTOGRAM_GLOBAL_BINS, histogram_format, strlen(histogram_format)+1); int status_ids[TEST_STATUS_NUM], field_ids[TEST_FIELD_NUM], line_ids[TEST_LINE_NUM+TEST_RUNTIME_REG_LINE_NUM], column_ids[TEST_COLUMN_NUM]; int histogram_ids[TEST_HISTOGRAM_NUM]; int runtime_status_ids[TEST_RUNTIME_REG_NUM]; for(i=0;i0) { loops--; for(i=0;i=0); runtime_status_ids[runtime_reg_num]=ret; runtime_reg_num++; ret=FS_register(handle,FS_STYLE_COLUMN, FS_CALC_SPEED, buff); assert(ret==-1);//always failed } if(runtime_reg_line_num=0); line_ids[TEST_LINE_NUM+runtime_reg_line_num]=ret; runtime_reg_line_num++; } long long preset[]={1,10,20,30,40,200,300,400,600,1000,2000,4000,5000,8000,100000}; for(i=0;i