GHashTable *classifiers_symbols; /**< hashtable indexed by symbol name of classifiers */
GHashTable* cfg_params; /**< all cfg params indexed by its name in this structure */
int clock_res; /**< resolution of clock used */
+ double grow_factor; /**< grow factor for consolidation callback */
GList *views; /**< views */
GHashTable* domain_settings; /**< settings per-domains */
GHashTable* user_settings; /**< settings per-user */
filters return FILTERS;
factors return FACTORS;
+grow_factor return GROW_FACTOR;
metric return METRIC;
name return NAME;
required_score return REQUIRED_SCORE;
%token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE PROFILE_FILE COUNT
%token VIEW IP FROM SYMBOLS
%token AUTOLEARN MIN_MARK MAX_MARK
-%token SETTINGS USER_SETTINGS DOMAIN_SETTINGS SYMBOL PATH SKIP_CHECK
+%token SETTINGS USER_SETTINGS DOMAIN_SETTINGS SYMBOL PATH SKIP_CHECK GROW_FACTOR
%type <string> STRING
%type <string> VARIABLE
double *tmp = memory_pool_alloc (cfg->cfg_pool, sizeof (double));
*tmp = $3;
g_hash_table_insert (cfg->factors, $1, tmp);
- };
+ }
+ | GROW_FACTOR EQSIGN FRACT {
+ cfg->grow_factor = $3;
+ }
+ | GROW_FACTOR EQSIGN NUMBER {
+ cfg->grow_factor = $3;
+ }
modules:
MODULES OBRACE modulesbody EBRACE
cfg->max_statfile_size = DEFAULT_STATFILE_SIZE;
+ cfg->grow_factor = 1;
cfg->modules_opts = g_hash_table_new (g_str_hash, g_str_equal);
cfg->variables = g_hash_table_new (g_str_hash, g_str_equal);
cfg->metrics = g_hash_table_new (g_str_hash, g_str_equal);
struct consolidation_callback_data {
struct worker_task *task;
double score;
+ int count;
};
static void
consolidation_callback (gpointer key, gpointer value, gpointer arg)
{
- double *factor, fs;
+ double *factor, fs, grow = 1;
struct symbol *s = (struct symbol *)value;
struct consolidation_callback_data *data = (struct consolidation_callback_data *)arg;
+
+ if (data->count > 0) {
+ grow = 1. + (data->task->cfg->grow_factor - 1.) * data->count;
+ }
if (check_factor_settings (data->task, key, &fs)) {
- data->score += fs * s->score;
+ if (s->score > 0) {
+ data->score += fs * s->score * grow;
+ data->count ++;
+ }
+ else {
+ data->score += fs * s->score;
+ }
}
else {
factor = g_hash_table_lookup (data->task->worker->srv->cfg->factors, key);
data->score += s->score;
}
else {
- data->score += *factor * s->score;
+ if (s->score > 0) {
+ data->score += *factor * s->score * grow;
+ data->count ++;
+ }
+ else {
+ data->score += *factor * s->score;
+ }
msg_debug ("consolidation_callback: got %.2f score for metric %s, factor: %.2f", s->score, (char *)key, *factor);
}
}
{
struct metric_result *metric_res;
double res = 0.;
- struct consolidation_callback_data data = { task, 0 };
+ struct consolidation_callback_data data = {
+ .task = task,
+ .score = 0,
+ .count = 0
+ };
metric_res = g_hash_table_lookup (task->results, metric_name);
if (metric_res == NULL) {
cd = g_malloc (sizeof (struct lua_callback_data));
cd->name = g_strdup (callback);
cd->L = L;
- register_expression_function (cd->name, lua_config_function_callback, cd);
+ register_expression_function (name, lua_config_function_callback, cd);
}
}
return 0;