http业务层链接redis时,从端口范围内随机选一个。
This commit is contained in:
@@ -15,7 +15,7 @@ stat_file=log/pangu_scan.status
|
||||
full_cfg_dir=pangu_policy/full/index/
|
||||
inc_cfg_dir=pangu_policy/inc/index/
|
||||
maat_redis_server=192.168.11.243
|
||||
maat_redis_port=6379
|
||||
maat_redis_port_range=6379-6379
|
||||
maat_redis_db_index=4
|
||||
effect_interval_s=1
|
||||
|
||||
|
||||
@@ -103,7 +103,9 @@ static Maat_feather_t create_maat_feather(const char * profile, const char * sec
|
||||
int ret = 0, scan_detail = 0, effect_interval = 60;
|
||||
char table_info[TFE_STRING_MAX] = {0}, inc_cfg_dir[TFE_STRING_MAX] = {0}, ful_cfg_dir[TFE_STRING_MAX] = {0};
|
||||
char redis_server[TFE_STRING_MAX] = {0};
|
||||
int redis_port = 0;
|
||||
char redis_port_range[TFE_STRING_MAX] = {0};
|
||||
int redis_port_begin=0, redis_port_end=0;
|
||||
int redis_port_select=0;
|
||||
int redis_db_idx = 0;
|
||||
char json_cfg_file[TFE_STRING_MAX] = {0}, maat_stat_file[TFE_STRING_MAX] = {0};
|
||||
const char * instance_name = "pangu";
|
||||
@@ -116,7 +118,21 @@ static Maat_feather_t create_maat_feather(const char * profile, const char * sec
|
||||
MESA_load_profile_string_def(profile, section, "JSON_CFG_FILE", json_cfg_file, sizeof(json_cfg_file), "");
|
||||
|
||||
MESA_load_profile_string_def(profile, section, "MAAT_REDIS_SERVER", redis_server, sizeof(redis_server), "");
|
||||
MESA_load_profile_int_def(profile, section, "MAAT_REDIS_PORT", &(redis_port), 6379);
|
||||
MESA_load_profile_string_def(profile, section, "MAAT_REDIS_PORT_RANGE", redis_port_range, sizeof(redis_server), "6379");
|
||||
ret=sscanf(redis_port_range,"%d-%d", &redis_port_begin, &redis_port_end);
|
||||
if(ret==1)
|
||||
{
|
||||
redis_port_select=redis_port_begin;
|
||||
}
|
||||
else if(ret==2)
|
||||
{
|
||||
srand(time(NULL));
|
||||
redis_port_select=redis_port_begin+rand()%(redis_port_end-redis_port_begin);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "Invalid redis port range %s, MAAT init failed.", redis_port_range);
|
||||
}
|
||||
MESA_load_profile_int_def(profile, section, "MAAT_REDIS_DB_INDEX", &(redis_db_idx), 0);
|
||||
|
||||
MESA_load_profile_string_def(profile, section, "INC_CFG_DIR", inc_cfg_dir, sizeof(inc_cfg_dir), "");
|
||||
@@ -137,7 +153,7 @@ static Maat_feather_t create_maat_feather(const char * profile, const char * sec
|
||||
break;
|
||||
case MAAT_INPUT_REDIS:
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_IP, redis_server, strlen(redis_server) + 1);
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_PORT, &redis_port, sizeof(redis_port));
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_PORT, &redis_port_select, sizeof(redis_port_select));
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_INDEX, &redis_db_idx, sizeof(redis_db_idx));
|
||||
break;
|
||||
case MAAT_INPUT_FILE: Maat_set_feather_opt(target, MAAT_OPT_FULL_CFG_DIR, ful_cfg_dir, strlen(ful_cfg_dir) + 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <cjson/cJSON.h>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include <rdkafka.h>
|
||||
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
|
||||
Reference in New Issue
Block a user