提高扫描状态输出的可读性。

This commit is contained in:
zhengchao
2016-02-18 09:58:01 +08:00
parent dc5713123a
commit a6ef5b16d1
3 changed files with 16 additions and 4 deletions

View File

@@ -2384,9 +2384,11 @@ void *thread_rule_monitor(void *arg)
const char* inc_cfg_dir=(const char*)feather->inc_dir; const char* inc_cfg_dir=(const char*)feather->inc_dir;
struct _Maat_scanner_t* old_scanner=NULL; struct _Maat_scanner_t* old_scanner=NULL;
long expr_wait_q_cnt=0; long expr_wait_q_cnt=0;
int scan_dir_cnt=0;
while(feather->still_working) while(feather->still_working)
{ {
usleep(feather->scan_interval_ms*1000); usleep(feather->scan_interval_ms*1000);
scan_dir_cnt++;
config_monitor_traverse(feather->maat_version, config_monitor_traverse(feather->maat_version,
inc_cfg_dir, inc_cfg_dir,
maat_start_cb, maat_start_cb,
@@ -2424,7 +2426,7 @@ void *thread_rule_monitor(void *arg)
} }
} }
garbage_bury(feather->garbage_q,feather->logger); garbage_bury(feather->garbage_q,feather->logger);
if(feather->stat_on==1) if(feather->stat_on==1&&scan_dir_cnt%2==0)//output every 2 seconds
{ {
maat_stat_output(feather); maat_stat_output(feather);
} }

View File

@@ -1,5 +1,5 @@
#include "Maat_rule_internal.h" #include "Maat_rule_internal.h"
#include "field_stat.h" #include <MESA/field_stat.h>
enum MAAT_FS_STATUS{ enum MAAT_FS_STATUS{
STATUS_VERSION=0, STATUS_VERSION=0,
STATUS_TABLE_NUM, STATUS_TABLE_NUM,
@@ -40,7 +40,7 @@ void maat_stat_init(struct _Maat_feather_t* feather)
feather->fs_column_id[COLUMN_TABLE_RULE_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"rule"); feather->fs_column_id[COLUMN_TABLE_RULE_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"rule");
feather->fs_column_id[COLUMN_TABLE_REGEX_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"regex"); feather->fs_column_id[COLUMN_TABLE_REGEX_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"regex");
feather->fs_column_id[COLUMN_TABLE_STREAM_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"stream"); feather->fs_column_id[COLUMN_TABLE_STREAM_NUM]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_CURRENT,"stream");
feather->fs_column_id[COLUMN_TABLE_SCAN_CNT]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"scan_cps"); feather->fs_column_id[COLUMN_TABLE_SCAN_CNT]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"IN_Tps");
feather->fs_column_id[COLUMN_TABLE_SCAN_BYTES]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"IN_Bps"); feather->fs_column_id[COLUMN_TABLE_SCAN_BYTES]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"IN_Bps");
if(feather->perf_on==1) if(feather->perf_on==1)
{ {
@@ -50,9 +50,17 @@ void maat_stat_init(struct _Maat_feather_t* feather)
FS_register_ratio(feather->stat_handle, FS_register_ratio(feather->stat_handle,
feather->fs_column_id[COLUMN_TABLE_SCAN_BYTES], feather->fs_column_id[COLUMN_TABLE_SCAN_BYTES],
feather->fs_column_id[COLUMN_TABLE_CPU_TIME], feather->fs_column_id[COLUMN_TABLE_CPU_TIME],
1000000, //microsecond to second
FS_STYLE_COLUMN, FS_STYLE_COLUMN,
FS_CALC_SPEED, FS_CALC_SPEED,
"PROC_Bps"); "PROC_Bps");
FS_register_ratio(feather->stat_handle,
feather->fs_column_id[COLUMN_TABLE_SCAN_CNT],
feather->fs_column_id[COLUMN_TABLE_CPU_TIME],
1000000, //microsecond to second
FS_STYLE_COLUMN,
FS_CALC_SPEED,
"PROC_Tps");
} }
feather->fs_column_id[COLUMN_TABLE_HIT_CNT]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"hit_cnt"); feather->fs_column_id[COLUMN_TABLE_HIT_CNT]=FS_register(feather->stat_handle, FS_STYLE_COLUMN, FS_CALC_SPEED,"hit_cnt");
value=feather->fs_column_id[COLUMN_TABLE_HIT_CNT]; value=feather->fs_column_id[COLUMN_TABLE_HIT_CNT];
@@ -60,6 +68,7 @@ void maat_stat_init(struct _Maat_feather_t* feather)
FS_register_ratio(feather->stat_handle, FS_register_ratio(feather->stat_handle,
feather->fs_column_id[COLUMN_TABLE_HIT_CNT], feather->fs_column_id[COLUMN_TABLE_HIT_CNT],
feather->fs_column_id[COLUMN_TABLE_SCAN_CNT], feather->fs_column_id[COLUMN_TABLE_SCAN_CNT],
1,
FS_STYLE_COLUMN, FS_STYLE_COLUMN,
FS_CALC_SPEED, FS_CALC_SPEED,
"hit_rate"); "hit_rate");

View File

@@ -49,7 +49,8 @@ void FS_stop(screen_stat_handle_t* handle);
int FS_register(screen_stat_handle_t handle,enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name); int FS_register(screen_stat_handle_t handle,enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name);
//numerator_id and denominator_id must be column/field/status style. //numerator_id and denominator_id must be column/field/status style.
int FS_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name); //scaling: negative value: zoom in; positive value: zoom out;
int FS_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,int scaling,enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name);
//id: when id's type is FIELD , column_id is ignore. //id: when id's type is FIELD , column_id is ignore.
int FS_operate(screen_stat_handle_t handle,int id,int column_id,enum field_op op,long long value); int FS_operate(screen_stat_handle_t handle,int id,int column_id,enum field_op op,long long value);