[FEATURE]fieldstat3 -> fieldstat4
This commit is contained in:
@@ -3,7 +3,7 @@ variables:
|
||||
BUILD_IMAGE_CENTOS7: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
|
||||
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||
INSTALL_DEPENDENCY_LIBRARY: framework_env openssl-devel libasan libfieldstat3-devel
|
||||
INSTALL_DEPENDENCY_LIBRARY: framework_env openssl-devel libasan libfieldstat4-devel
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
@@ -15,7 +15,7 @@ include_directories(/opt/MESA/include/)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_FLAGS "-fPIC -Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
|
||||
set(MAAT_DEPEND_DYN_LIB pthread m crypto z fieldstat3)
|
||||
set(MAAT_DEPEND_DYN_LIB pthread m crypto z fieldstat4)
|
||||
include_directories(include)
|
||||
|
||||
#for ASAN
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C"
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#include "log/log.h"
|
||||
#include "fieldstat.h"
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
#include "maat_command.h"
|
||||
#include "maat_limits.h"
|
||||
#include "maat.h"
|
||||
@@ -140,17 +140,17 @@ struct maat_options {
|
||||
|
||||
struct maat_stat {
|
||||
char stat_file[PATH_MAX];
|
||||
struct fieldstat_instance *fs_handle;
|
||||
int total_stat_id[MAX_MAAT_STAT_NUM];
|
||||
int fs_status_id[MAX_MAAT_STAT_NUM];
|
||||
int fs_column_id[MAX_TABLE_NUM][MAX_MAAT_STAT_NUM];
|
||||
struct fieldstat_easy *fs_handle;
|
||||
int g_metric_id[MAX_MAAT_STAT_NUM];
|
||||
int fs_column_id[MAX_MAAT_STAT_NUM];
|
||||
char tag_value[MAX_TABLE_NUM][MAX_NAME_STR_LEN];
|
||||
char sum_tag[MAX_NAME_STR_LEN];
|
||||
struct log_handle *logger;
|
||||
struct table_manager *ref_tbl_mgr;
|
||||
struct maat_garbage_bin *ref_garbage_bin;
|
||||
size_t nr_worker_thread;
|
||||
int cmd_q_cnt;
|
||||
|
||||
|
||||
long long *thread_call_cnt;
|
||||
long long *stream_cnt;
|
||||
long long *hit_compile_cnt;
|
||||
|
||||
@@ -23,10 +23,11 @@ struct maat_stat *maat_stat_new(const char *stat_file, size_t max_thread_num,
|
||||
|
||||
void maat_stat_free(struct maat_stat *stat);
|
||||
|
||||
int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
struct maat_garbage_bin *garbage_bin);
|
||||
int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
struct maat_garbage_bin *garbage_bin);
|
||||
|
||||
void maat_stat_output(struct maat_stat *stat, long long maat_version, int perf_on);
|
||||
void maat_stat_output(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
long long maat_version, int perf_on);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ long long table_manager_runtime_rule_count(struct table_manager *tbl_mgr, int ta
|
||||
|
||||
long long table_manager_runtime_scan_times(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
long long table_manager_runtime_hit_times(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
long long table_manager_runtime_scan_cpu_time(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
long long table_manager_runtime_hit_item_num(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
@@ -378,7 +378,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
|
||||
system_cmd_mkdir(maat_inst->opts.foreign_cont_dir);
|
||||
|
||||
if (0 == strlen(maat_inst->opts.stat_file)) {
|
||||
snprintf(maat_inst->opts.stat_file, sizeof(maat_inst->opts.stat_file), "maat.fs3");
|
||||
snprintf(maat_inst->opts.stat_file, sizeof(maat_inst->opts.stat_file), "maat_stat.fs");
|
||||
}
|
||||
|
||||
snprintf(maat_inst->opts.decrypt_algo, sizeof(maat_inst->opts.decrypt_algo), "aes-256-cbc");
|
||||
|
||||
@@ -582,7 +582,6 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
|
||||
ipv6_ntoh(scan_data.ipv6);
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
size_t real_hit_item_cnt = 0;
|
||||
struct maat_item hit_maat_items[MAX_HIT_ITEM_NUM];
|
||||
|
||||
|
||||
@@ -545,8 +545,8 @@ void *rule_monitor_loop(void *arg)
|
||||
maat_plugin_table_garbage_collect_routine(maat_inst->tbl_mgr);
|
||||
|
||||
if ((1 == maat_inst->opts.stat_on) && (time(NULL) % 2 == 0)) {
|
||||
maat_stat_output(maat_inst->stat, maat_inst->maat_version,
|
||||
maat_inst->opts.perf_on);
|
||||
maat_stat_output(maat_inst->stat, maat_inst->tbl_mgr,
|
||||
maat_inst->maat_version, maat_inst->opts.perf_on);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
551
src/maat_stat.c
551
src/maat_stat.c
@@ -9,10 +9,11 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "maat_utils.h"
|
||||
#include "maat_stat.h"
|
||||
#include "fieldstat.h"
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
#include "alignment.h"
|
||||
#include "maat_ip.h"
|
||||
#include "maat_compile.h"
|
||||
@@ -24,7 +25,7 @@
|
||||
|
||||
enum MAAT_FS_STATUS {
|
||||
STATUS_VERSION = 0,
|
||||
STATUS_THRED_NUM,
|
||||
STATUS_THREAD_NUM,
|
||||
STATUS_TABLE_NUM,
|
||||
STATUS_PLUGIN_CACHE_NUM,
|
||||
STATUS_PLUGIN_ACC_NUM,
|
||||
@@ -34,7 +35,7 @@ enum MAAT_FS_STATUS {
|
||||
STATUS_MAAT_STATE_NUM,
|
||||
STATUS_MAAT_PER_STATE_MEM,
|
||||
STATUS_COMPILE_STATE_NUM,
|
||||
STATUS_GARBAGE_QSIZE,
|
||||
STATUS_GARBAGE_QUEUE_LEN,
|
||||
STATUS_UPDATE_ERR_CNT,
|
||||
STATUS_SCAN_ERR_CNT,
|
||||
STATUS_STREAM_NUM,
|
||||
@@ -45,161 +46,101 @@ enum MAAT_FS_STATUS {
|
||||
enum MAAT_FS_COLUMN {
|
||||
COLUMN_RULE_NUM = 0,
|
||||
COLUMN_REGEX_NUM,
|
||||
COLUMN_SCAN_TIMES, //the times of scan
|
||||
COLUMN_HIT_TIMES, //the times of hit compile
|
||||
COLUMN_SCAN_TIMES, //the times of scan
|
||||
COLUMN_HIT_TIMES, //the times of hit item
|
||||
COLUMN_SCAN_BYTES,
|
||||
COLUMN_SCAN_CPU_TIME, //microseconds
|
||||
COLUMN_SCAN_CPU_TIME, //microseconds
|
||||
COLUMN_HIT_ITEM_NUM,
|
||||
COLUMN_HIT_PAT_NUM, //hit pattern num(only valid for expr/expr_plus table)
|
||||
COLUMN_SCAN_BPS, //scan bytes per second
|
||||
COLUMN_SCAN_TPS, //scan times per second
|
||||
COLUMN_HIT_RATE //scan hit rate(hit_times/scan_times)
|
||||
COLUMN_HIT_PAT_NUM //the number of hit pattern(only valid for expr/expr_plus table)
|
||||
};
|
||||
|
||||
const char *common_column_name[] = {"rule", "reg/v6", "scan_times", "hit_times", "scan_bytes", "scan_cpu_time",
|
||||
"hit_item_num", "hit_pat_num", "IN_Bps", "IN_Tps", "hit_rate"};
|
||||
const char *column_name[] = {
|
||||
"rule", "reg/v6", "scan_times", "hit_times",
|
||||
"scan_bytes", "scan_cpu_time(ns)", "hit_item_num", "hit_pat_num"};
|
||||
|
||||
enum field_type common_column_type[] = {
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE,
|
||||
FIELD_TYPE_GAUGE
|
||||
};
|
||||
|
||||
#define MAX_CONJ_NAME_LEN 22
|
||||
static void maat_fieldstat_register(struct maat_stat *stat)
|
||||
static void fs_global_metric_register(struct maat_stat *stat)
|
||||
{
|
||||
stat->fs_status_id[STATUS_VERSION] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"version", NULL, 0);
|
||||
stat->fs_status_id[STATUS_THRED_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"threads", NULL, 0);
|
||||
stat->fs_status_id[STATUS_TABLE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"tables", NULL, 0);
|
||||
stat->fs_status_id[STATUS_PLUGIN_CACHE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"plug_cached", NULL, 0);
|
||||
stat->fs_status_id[STATUS_PLUGIN_ACC_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"plug_acc", NULL, 0);
|
||||
stat->fs_status_id[STATUS_CLAUSE_REF_NOT_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"not_clause", NULL, 0);
|
||||
stat->fs_status_id[STATUS_GROUP_REF_EXCL_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"excl_grp", NULL, 0);
|
||||
stat->fs_status_id[STATUS_GARBAGE_QSIZE] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"garbage_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_HIT_COMPILE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"hit_compile_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_MAAT_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"state_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_MAAT_PER_STATE_MEM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"per_state_mem(B)", NULL, 0);
|
||||
stat->fs_status_id[STATUS_COMPILE_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"compile_state_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_STREAM_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"stream_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_ZOMBIE_STREAM_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"z_stream_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_UPDATE_ERR_CNT] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"update_error", NULL, 0);
|
||||
stat->fs_status_id[STATUS_SCAN_ERR_CNT] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"scan_error", NULL, 0);
|
||||
stat->fs_status_id[STATUS_CMD_LINE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"line_cmd/s", NULL, 0);
|
||||
stat->g_metric_id[STATUS_VERSION] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "version");
|
||||
|
||||
stat->g_metric_id[STATUS_THREAD_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "thread_num");
|
||||
|
||||
stat->g_metric_id[STATUS_TABLE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "table_num");
|
||||
|
||||
stat->g_metric_id[STATUS_PLUGIN_CACHE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "plug_cached_num");
|
||||
|
||||
stat->g_metric_id[STATUS_PLUGIN_ACC_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "plug_acc_num");
|
||||
|
||||
stat->g_metric_id[STATUS_CLAUSE_REF_NOT_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "NOT_clause_num");
|
||||
|
||||
stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "excl_grp");
|
||||
|
||||
stat->g_metric_id[STATUS_GARBAGE_QUEUE_LEN] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "garbage_queue_len");
|
||||
|
||||
stat->g_metric_id[STATUS_HIT_COMPILE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "hit_compile_num");
|
||||
|
||||
stat->g_metric_id[STATUS_MAAT_STATE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "state_num");
|
||||
|
||||
stat->g_metric_id[STATUS_MAAT_PER_STATE_MEM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "per_state_mem(B)");
|
||||
|
||||
stat->g_metric_id[STATUS_COMPILE_STATE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "compile_state_num");
|
||||
|
||||
stat->g_metric_id[STATUS_STREAM_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "stream_num");
|
||||
|
||||
stat->g_metric_id[STATUS_ZOMBIE_STREAM_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "z_stream_num");
|
||||
|
||||
stat->g_metric_id[STATUS_UPDATE_ERR_CNT] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "update_error");
|
||||
|
||||
stat->g_metric_id[STATUS_SCAN_ERR_CNT] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "scan_error");
|
||||
|
||||
stat->g_metric_id[STATUS_CMD_LINE_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "line_cmd/s");
|
||||
}
|
||||
|
||||
static int maat_fieldstat_table_row_register(struct maat_stat *stat,
|
||||
struct table_manager *tbl_mgr,
|
||||
int table_id)
|
||||
static void fs_table_column_register(struct maat_stat *stat)
|
||||
{
|
||||
size_t max_table_cnt = table_manager_table_size(tbl_mgr);
|
||||
int ret = fieldstat_register_table_row(stat->fs_handle, table_id, "Sum", NULL, 0,
|
||||
stat->total_stat_id);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table_row Sum failed.");
|
||||
return -1;
|
||||
}
|
||||
size_t column_num = sizeof(column_name) / sizeof(column_name[0]);
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->total_stat_id[COLUMN_SCAN_BPS],
|
||||
stat->total_stat_id[COLUMN_SCAN_BYTES],
|
||||
stat->total_stat_id[COLUMN_SCAN_CPU_TIME], 1000000000);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Bps for Sum failed.");
|
||||
return -1;
|
||||
}
|
||||
assert(column_num <= MAX_MAAT_STAT_NUM);
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->total_stat_id[COLUMN_SCAN_TPS],
|
||||
stat->total_stat_id[COLUMN_SCAN_TIMES],
|
||||
stat->total_stat_id[COLUMN_SCAN_CPU_TIME], 1000000000);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Tps for Sum failed.");
|
||||
return -1;
|
||||
for (size_t i = 0; i < column_num; i++) {
|
||||
stat->fs_column_id[i] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, column_name[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->total_stat_id[COLUMN_HIT_RATE],
|
||||
stat->total_stat_id[COLUMN_HIT_TIMES],
|
||||
stat->total_stat_id[COLUMN_SCAN_TIMES], 1);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
|
||||
return -1;
|
||||
}
|
||||
static void fs_table_row_register(struct maat_stat *stat)
|
||||
{
|
||||
//In fieldstat4, row is the tag
|
||||
size_t max_table_cnt = table_manager_table_size(stat->ref_tbl_mgr);
|
||||
memcpy(stat->sum_tag, "Sum", strlen("Sum"));
|
||||
|
||||
size_t counter = 0;
|
||||
for (size_t i = 0; i < max_table_cnt; i++) {
|
||||
void *schema = table_manager_get_schema(tbl_mgr, i);
|
||||
if (NULL == schema) {
|
||||
const char *table_name =
|
||||
table_manager_get_table_name(stat->ref_tbl_mgr, i);
|
||||
if (NULL == table_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enum table_type table_type = table_manager_get_table_type(tbl_mgr, i);
|
||||
if (table_type == TABLE_TYPE_VIRTUAL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *table_name = table_manager_get_table_name(tbl_mgr, i);
|
||||
assert(table_name != NULL);
|
||||
|
||||
ret = fieldstat_register_table_row(stat->fs_handle, table_id, table_name, NULL, 0,
|
||||
stat->fs_column_id[i]);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT,
|
||||
"fieldstat_register_table_row %s failed.", table_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->fs_column_id[i][COLUMN_SCAN_BPS],
|
||||
stat->fs_column_id[i][COLUMN_SCAN_BYTES],
|
||||
stat->fs_column_id[i][COLUMN_SCAN_CPU_TIME], 1000000000);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT,
|
||||
"fieldstat set IN_Bps for %s failed.", table_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->fs_column_id[i][COLUMN_SCAN_TPS],
|
||||
stat->fs_column_id[i][COLUMN_SCAN_TIMES],
|
||||
stat->fs_column_id[i][COLUMN_SCAN_CPU_TIME], 1000000000);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT,
|
||||
"fieldstat set IN_Tps for %s failed.", table_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->fs_column_id[i][COLUMN_HIT_RATE],
|
||||
stat->fs_column_id[i][COLUMN_HIT_TIMES],
|
||||
stat->fs_column_id[i][COLUMN_SCAN_TIMES], 1);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT,
|
||||
"fieldstat set hit_rate for %s failed.", table_name);
|
||||
return -1;
|
||||
}
|
||||
memcpy(stat->tag_value[counter], table_name,
|
||||
MIN(strlen(table_name), sizeof(stat->tag_value[counter])));
|
||||
counter++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct maat_stat *maat_stat_new(const char *stat_file, size_t max_thread_num,
|
||||
@@ -265,81 +206,64 @@ void maat_stat_free(struct maat_stat *stat)
|
||||
}
|
||||
|
||||
if (stat->fs_handle != NULL) {
|
||||
fieldstat_instance_free(stat->fs_handle);
|
||||
fieldstat_easy_free(stat->fs_handle);
|
||||
stat->fs_handle = NULL;
|
||||
}
|
||||
|
||||
FREE(stat);
|
||||
}
|
||||
|
||||
int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
struct maat_garbage_bin *garbage_bin)
|
||||
int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
struct maat_garbage_bin *garbage_bin)
|
||||
{
|
||||
if (NULL == stat || NULL == tbl_mgr || NULL == garbage_bin) {
|
||||
if (NULL == stat || NULL == tbl_mgr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *instance_name = "maat_stat";
|
||||
stat->fs_handle = fieldstat_instance_new(instance_name);
|
||||
stat->fs_handle = fieldstat_easy_new(1, instance_name, NULL, 0);
|
||||
if (NULL == stat->fs_handle) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_instance_new failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = fieldstat_set_local_output(stat->fs_handle, stat->stat_file, "default");
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_set_local_output failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fieldstat_disable_background_thread(stat->fs_handle);
|
||||
if (ret < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT,
|
||||
"fieldstat_disable_background_thread failed.");
|
||||
"fieldstat_easy_new failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
maat_fieldstat_register(stat);
|
||||
|
||||
stat->ref_tbl_mgr = tbl_mgr;
|
||||
stat->ref_garbage_bin = garbage_bin;
|
||||
size_t n_column = sizeof(common_column_name) / sizeof(common_column_name[0]);
|
||||
int fs_table_id = fieldstat_register_table(stat->fs_handle, instance_name,
|
||||
common_column_name, common_column_type,
|
||||
n_column);
|
||||
if (fs_table_id < 0) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = maat_fieldstat_table_row_register(stat, tbl_mgr, fs_table_id);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_instance_start(stat->fs_handle);
|
||||
fs_global_metric_register(stat);
|
||||
fs_table_column_register(stat);
|
||||
fs_table_row_register(stat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void maat_fieldstat_table_row_output(struct maat_stat *stat, int perf_on)
|
||||
static void fs_table_row_output(FILE *fp, struct maat_stat *stat, int perf_on)
|
||||
{
|
||||
long long plugin_cache_num = 0, plugin_rule_num = 0;
|
||||
long long total_rule_num = 0, total_input_bytes = 0, total_update_err = 0;
|
||||
long long total_scan_times = 0, total_scan_cpu_time = 0, total_regex_num = 0;
|
||||
long long total_ipv6_num = 0, total_hit_item_num = 0, total_hit_pattern_num = 0;
|
||||
long long total_scan_times = 0, total_hit_times = 0, total_scan_cpu_time = 0;
|
||||
long long total_regex_num = 0, total_ipv6_num = 0;
|
||||
long long total_hit_item_num = 0, total_hit_pattern_num = 0;
|
||||
long long g2c_not_clause_num = 0, g2g_excl_rule_num = 0;
|
||||
struct fieldstat_tag cell_tag = {
|
||||
.key = "TBL",
|
||||
.type = TAG_CSTRING
|
||||
};
|
||||
|
||||
size_t max_table_count = table_manager_table_size(stat->ref_tbl_mgr);
|
||||
|
||||
for (size_t i = 0; i < max_table_count; i++) {
|
||||
long long regex_rule_num = 0;
|
||||
long long ipv6_rule_num = 0;
|
||||
|
||||
void *schema = table_manager_get_schema(stat->ref_tbl_mgr, i);
|
||||
if (NULL == schema) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enum table_type table_type = table_manager_get_table_type(stat->ref_tbl_mgr, i);
|
||||
enum table_type table_type =
|
||||
table_manager_get_table_type(stat->ref_tbl_mgr, i);
|
||||
assert(table_type != TABLE_TYPE_INVALID);
|
||||
|
||||
void *runtime = table_manager_get_runtime(stat->ref_tbl_mgr, i);
|
||||
@@ -373,106 +297,183 @@ static void maat_fieldstat_table_row_output(struct maat_stat *stat, int perf_on)
|
||||
total_regex_num += regex_rule_num;
|
||||
total_ipv6_num += ipv6_rule_num;
|
||||
|
||||
long long rule_num = table_manager_runtime_rule_count(stat->ref_tbl_mgr, i);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_RULE_NUM], rule_num);
|
||||
long long rule_num =
|
||||
table_manager_runtime_rule_count(stat->ref_tbl_mgr, i);
|
||||
|
||||
cell_tag.value_str = stat->tag_value[i];
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_RULE_NUM],
|
||||
&cell_tag, 1, rule_num);
|
||||
total_rule_num += rule_num;
|
||||
|
||||
long long scan_times = table_manager_runtime_scan_times(stat->ref_tbl_mgr, i);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_SCAN_TIMES], scan_times);
|
||||
long long scan_times =
|
||||
table_manager_runtime_scan_times(stat->ref_tbl_mgr, i);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_TIMES],
|
||||
&cell_tag, 1, scan_times);
|
||||
total_scan_times += scan_times;
|
||||
|
||||
if (table_type == TABLE_TYPE_PLUGIN || table_type == TABLE_TYPE_IP_PLUGIN ||
|
||||
table_type == TABLE_TYPE_IPPORT_PLUGIN || table_type == TABLE_TYPE_BOOL_PLUGIN ||
|
||||
long long hit_times =
|
||||
table_manager_runtime_hit_times(stat->ref_tbl_mgr, i);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_TIMES],
|
||||
&cell_tag, 1, hit_times);
|
||||
total_hit_times += hit_times;
|
||||
|
||||
if (table_type == TABLE_TYPE_PLUGIN ||
|
||||
table_type == TABLE_TYPE_IP_PLUGIN ||
|
||||
table_type == TABLE_TYPE_IPPORT_PLUGIN ||
|
||||
table_type == TABLE_TYPE_BOOL_PLUGIN ||
|
||||
table_type == TABLE_TYPE_FQDN_PLUGIN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (table_type == TABLE_TYPE_EXPR || table_type == TABLE_TYPE_EXPR_PLUS) {
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_REGEX_NUM],
|
||||
regex_rule_num);
|
||||
long long input_bytes = expr_runtime_scan_bytes(runtime);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_SCAN_BYTES],
|
||||
input_bytes);
|
||||
long long input_bytes = 0;
|
||||
if (table_type == TABLE_TYPE_EXPR ||
|
||||
table_type == TABLE_TYPE_EXPR_PLUS) {
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_REGEX_NUM],
|
||||
&cell_tag, 1, regex_rule_num);
|
||||
|
||||
input_bytes = expr_runtime_scan_bytes(runtime);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_BYTES],
|
||||
&cell_tag, 1, input_bytes);
|
||||
total_input_bytes += input_bytes;
|
||||
|
||||
long long hit_pattern_num = expr_runtime_hit_pattern_num(runtime);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_HIT_PAT_NUM],
|
||||
hit_pattern_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_PAT_NUM],
|
||||
&cell_tag, 1, hit_pattern_num);
|
||||
total_hit_pattern_num += hit_pattern_num;
|
||||
}
|
||||
|
||||
if (table_type == TABLE_TYPE_IP_PLUS) {
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_REGEX_NUM],
|
||||
ipv6_rule_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_REGEX_NUM],
|
||||
&cell_tag, 1, ipv6_rule_num);
|
||||
}
|
||||
|
||||
if (1 == perf_on) {
|
||||
long long scan_cpu_time = table_manager_runtime_scan_cpu_time(stat->ref_tbl_mgr, i);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_SCAN_CPU_TIME],
|
||||
scan_cpu_time);
|
||||
total_scan_cpu_time += scan_cpu_time;
|
||||
long long scan_cpu_time =
|
||||
table_manager_runtime_scan_cpu_time(stat->ref_tbl_mgr, i);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_CPU_TIME],
|
||||
&cell_tag, 1, scan_cpu_time);
|
||||
}
|
||||
|
||||
long long hit_item_num = table_manager_runtime_hit_item_num(stat->ref_tbl_mgr, i);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_column_id[i][COLUMN_HIT_ITEM_NUM], hit_item_num);
|
||||
long long hit_item_num =
|
||||
table_manager_runtime_hit_item_num(stat->ref_tbl_mgr, i);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_ITEM_NUM],
|
||||
&cell_tag, 1, hit_item_num);
|
||||
total_hit_item_num += hit_item_num;
|
||||
|
||||
total_update_err += table_manager_runtime_update_err_count(stat->ref_tbl_mgr, i);
|
||||
total_update_err +=
|
||||
table_manager_runtime_update_err_count(stat->ref_tbl_mgr, i);
|
||||
}
|
||||
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_RULE_NUM],
|
||||
total_rule_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_REGEX_NUM],
|
||||
total_regex_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_SCAN_TIMES],
|
||||
total_scan_times);
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_HIT_ITEM_NUM],
|
||||
total_hit_item_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_HIT_PAT_NUM],
|
||||
total_hit_pattern_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_SCAN_BYTES],
|
||||
total_input_bytes);
|
||||
|
||||
cell_tag.value_str = stat->sum_tag;
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_RULE_NUM],
|
||||
&cell_tag, 1, total_rule_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_REGEX_NUM],
|
||||
&cell_tag, 1, total_regex_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_TIMES],
|
||||
&cell_tag, 1, total_scan_times);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_TIMES],
|
||||
&cell_tag, 1, total_hit_times);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_ITEM_NUM],
|
||||
&cell_tag, 1, total_hit_item_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_HIT_PAT_NUM],
|
||||
&cell_tag, 1, total_hit_pattern_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_BYTES],
|
||||
&cell_tag, 1, total_input_bytes);
|
||||
if (1 == perf_on) {
|
||||
fieldstat_value_set(stat->fs_handle, stat->total_stat_id[COLUMN_SCAN_CPU_TIME],
|
||||
total_scan_cpu_time);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->fs_column_id[COLUMN_SCAN_CPU_TIME],
|
||||
&cell_tag, 1, total_scan_cpu_time);
|
||||
}
|
||||
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_UPDATE_ERR_CNT],
|
||||
total_update_err);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_SCAN_ERR_CNT],
|
||||
stat->scan_err_cnt);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_PLUGIN_CACHE_NUM],
|
||||
plugin_cache_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_PLUGIN_ACC_NUM],
|
||||
plugin_rule_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_CLAUSE_REF_NOT_NUM],
|
||||
g2c_not_clause_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_GROUP_REF_EXCL_NUM],
|
||||
g2g_excl_rule_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_UPDATE_ERR_CNT],
|
||||
NULL, 0, total_update_err);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_SCAN_ERR_CNT],
|
||||
NULL, 0, stat->scan_err_cnt);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_PLUGIN_CACHE_NUM],
|
||||
NULL, 0, plugin_cache_num);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_PLUGIN_ACC_NUM],
|
||||
NULL, 0, plugin_rule_num);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_CLAUSE_REF_NOT_NUM],
|
||||
NULL, 0, g2c_not_clause_num);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM],
|
||||
NULL, 0, g2g_excl_rule_num);
|
||||
|
||||
char *buff = NULL;
|
||||
size_t buff_len = 0;
|
||||
|
||||
fieldstat_easy_output(stat->fs_handle, &buff, &buff_len);
|
||||
fwrite(buff, buff_len, 1, fp);
|
||||
fflush(fp);
|
||||
|
||||
FREE(buff);
|
||||
}
|
||||
|
||||
void maat_stat_output(struct maat_stat *stat, long long maat_version, int perf_on)
|
||||
void maat_stat_output(struct maat_stat *stat, struct table_manager *tbl_mgr,
|
||||
long long maat_version, int perf_on)
|
||||
{
|
||||
if (NULL == stat) {
|
||||
return;
|
||||
}
|
||||
|
||||
long long active_thread_num = alignment_int64_array_cnt(stat->thread_call_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long stream_num = alignment_int64_array_sum(stat->stream_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long hit_compile_num = alignment_int64_array_sum(stat->hit_compile_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long maat_state_num = alignment_int64_array_sum(stat->maat_state_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long compile_state_num = alignment_int64_array_sum(stat->compile_state_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long maat_state_free_num = alignment_int64_array_sum(stat->maat_state_free_cnt,
|
||||
stat->nr_worker_thread);
|
||||
long long maat_state_free_bytes = alignment_int64_array_sum(stat->maat_state_free_bytes,
|
||||
stat->nr_worker_thread);
|
||||
|
||||
FILE *fp = fopen(stat->stat_file, "w+");
|
||||
if (NULL == fp) {
|
||||
log_fatal(stat->logger, MODULE_MAAT_STAT, "open stat_file:%s failed.",
|
||||
stat->stat_file);
|
||||
return;
|
||||
}
|
||||
|
||||
long long active_thread_num =
|
||||
alignment_int64_array_cnt(stat->thread_call_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long stream_num =
|
||||
alignment_int64_array_sum(stat->stream_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long hit_compile_num =
|
||||
alignment_int64_array_sum(stat->hit_compile_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long maat_state_num =
|
||||
alignment_int64_array_sum(stat->maat_state_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long compile_state_num =
|
||||
alignment_int64_array_sum(stat->compile_state_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long maat_state_free_num =
|
||||
alignment_int64_array_sum(stat->maat_state_free_cnt, stat->nr_worker_thread);
|
||||
|
||||
long long maat_state_free_bytes =
|
||||
alignment_int64_array_sum(stat->maat_state_free_bytes, stat->nr_worker_thread);
|
||||
|
||||
size_t table_num = table_manager_table_num(stat->ref_tbl_mgr);
|
||||
size_t garbage_q_len = maat_garbage_bin_get_size(stat->ref_garbage_bin);
|
||||
|
||||
@@ -480,30 +481,42 @@ void maat_stat_output(struct maat_stat *stat, long long maat_version, int perf_o
|
||||
if (maat_state_free_num != 0) {
|
||||
per_state_mem = maat_state_free_bytes / maat_state_free_num;
|
||||
}
|
||||
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_VERSION],
|
||||
maat_version);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_THRED_NUM],
|
||||
active_thread_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_TABLE_NUM],
|
||||
table_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_HIT_COMPILE_NUM],
|
||||
hit_compile_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_STATE_NUM],
|
||||
maat_state_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_PER_STATE_MEM],
|
||||
per_state_mem);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_COMPILE_STATE_NUM],
|
||||
compile_state_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_CMD_LINE_NUM],
|
||||
stat->line_cmd_acc_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_GARBAGE_QSIZE],
|
||||
garbage_q_len);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_STREAM_NUM],
|
||||
stream_num);
|
||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_ZOMBIE_STREAM_NUM],
|
||||
stat->zombie_rs_stream);
|
||||
maat_fieldstat_table_row_output(stat, perf_on);
|
||||
|
||||
fieldstat_passive_output(stat->fs_handle);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_VERSION],
|
||||
NULL, 0, maat_version);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_THREAD_NUM],
|
||||
NULL, 0, active_thread_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_TABLE_NUM],
|
||||
NULL, 0, table_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_HIT_COMPILE_NUM],
|
||||
NULL, 0, hit_compile_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_MAAT_STATE_NUM],
|
||||
NULL, 0, maat_state_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_MAAT_PER_STATE_MEM],
|
||||
NULL, 0, per_state_mem);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_COMPILE_STATE_NUM],
|
||||
NULL, 0, compile_state_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_CMD_LINE_NUM],
|
||||
NULL, 0, stat->line_cmd_acc_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_GARBAGE_QUEUE_LEN],
|
||||
NULL, 0, garbage_q_len);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_STREAM_NUM],
|
||||
NULL, 0, stream_num);
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_ZOMBIE_STREAM_NUM],
|
||||
NULL, 0, stat->zombie_rs_stream);
|
||||
|
||||
fs_table_row_output(fp, stat, perf_on);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -1402,6 +1402,28 @@ long long table_manager_runtime_scan_times(struct table_manager *tbl_mgr, int ta
|
||||
return table_ops[table_type].scan_times(runtime);
|
||||
}
|
||||
|
||||
long long table_manager_runtime_hit_times(struct table_manager *tbl_mgr, int table_id)
|
||||
{
|
||||
void *runtime = table_manager_get_runtime(tbl_mgr, table_id);
|
||||
if (NULL == runtime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
|
||||
if (table_type == TABLE_TYPE_INVALID) {
|
||||
log_fatal(tbl_mgr->logger, MODULE_TABLE,
|
||||
"[%s:%d] table(table_id:%d) table_type is invalid, can't get scan count",
|
||||
__FUNCTION__, __LINE__, table_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (NULL == table_ops[table_type].hit_times) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return table_ops[table_type].hit_times(runtime);
|
||||
}
|
||||
|
||||
long long table_manager_runtime_scan_cpu_time(struct table_manager *tbl_mgr, int table_id)
|
||||
{
|
||||
void *runtime = table_manager_get_runtime(tbl_mgr, table_id);
|
||||
|
||||
@@ -363,6 +363,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_instance_name(opts, "firewall");
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_json_file(opts, watched_json);
|
||||
maat_options_set_json_file_gzip_flag(opts, 1);
|
||||
maat_options_set_json_file_decrypt_key(opts, json_decrypt_key);
|
||||
@@ -475,6 +476,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
@@ -781,6 +783,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
@@ -1668,6 +1671,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_expr_engine(opts, MAAT_EXPR_ENGINE_RS);
|
||||
@@ -2565,6 +2569,7 @@ protected:
|
||||
maat_options_set_rule_effect_interval_ms(opts, 0);
|
||||
maat_options_set_gc_timeout_ms(opts, 0); // start GC immediately
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
_shared_maat_inst = maat_new(opts, table_info_path);
|
||||
maat_options_free(opts);
|
||||
}
|
||||
@@ -2678,6 +2683,7 @@ protected:
|
||||
maat_options_set_rule_effect_interval_ms(opts, 0);
|
||||
maat_options_set_gc_timeout_ms(opts, 0); // start GC immediately
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_expr_engine(opts, MAAT_EXPR_ENGINE_RS);
|
||||
_shared_maat_inst = maat_new(opts, table_info_path);
|
||||
maat_options_free(opts);
|
||||
@@ -2795,6 +2801,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -3190,6 +3197,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -3325,6 +3333,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -3424,6 +3433,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -4682,6 +4692,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5068,6 +5079,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_DEBUG);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5331,6 +5343,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5470,6 +5483,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5609,6 +5623,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5779,6 +5794,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5865,6 +5881,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -5930,6 +5947,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
@@ -6082,6 +6100,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
@@ -6263,6 +6282,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
@@ -6673,6 +6693,7 @@ protected:
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
@@ -6744,6 +6765,7 @@ protected:
|
||||
maat_options_set_caller_thread_number(opts, g_thread_num);
|
||||
maat_options_set_instance_name(opts, "files");
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_iris(opts, rule_folder, rule_folder);
|
||||
maat_options_set_rule_update_checking_interval_ms(opts, scan_interval_ms);
|
||||
maat_options_set_rule_effect_interval_ms(opts, effective_interval_ms);
|
||||
@@ -6849,6 +6871,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
@@ -7206,6 +7229,7 @@ protected:
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_FATAL);
|
||||
maat_options_set_hit_path_enabled(opts);
|
||||
maat_options_set_hit_group_enabled(opts);
|
||||
@@ -11143,6 +11167,8 @@ protected:
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_stat_file(opts, "./stat.log");
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ TEST(json_mode, maat_scan_string) {
|
||||
char json_path[PATH_MAX] = {0};
|
||||
snprintf(json_path, sizeof(json_path), "./%s", json_filename);
|
||||
maat_options_set_json_file(opts, json_path);
|
||||
maat_options_set_stat_on(opts);
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_logger(opts, "./maat_input_mode_gtest.log", LOG_LEVEL_INFO);
|
||||
|
||||
struct maat *maat_inst = maat_new(opts, table_info_path);
|
||||
@@ -93,6 +95,8 @@ TEST(iris_mode, maat_scan_string) {
|
||||
"%s/index", json_iris_path);
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_stat_on(opts);
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_iris(opts, tmp_iris_full_idx_path, tmp_iris_inc_idx_path);
|
||||
maat_options_set_logger(opts, "./maat_input_mode_gtest.log", LOG_LEVEL_INFO);
|
||||
|
||||
@@ -225,6 +229,8 @@ TEST(redis_mode, maat_scan_string) {
|
||||
redisFree(c);
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_stat_on(opts);
|
||||
maat_options_set_perf_on(opts);
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_input_mode_gtest.log",
|
||||
LOG_LEVEL_INFO);
|
||||
|
||||
Reference in New Issue
Block a user