MT#65050 add stats.call_info site_id support

* new config option site-id (default: 0). with multi site enabled
  it contans the current site id value.
* include site-id into the "Up and running log line".
* extend "insert into stats.call_info to populate the site_id column".

Change-Id: Ieed766356cff8cf8ce26c3e928a71952944c26d0
master
Kirill Solomko 1 month ago
parent 30ee5096db
commit 23e81fda7a

@ -47,6 +47,7 @@ int config_maintenance = 0;
int strict_leg_tokens = 0;
int config_max_acc_age = 0;
int config_intermediate_interval = 0;
int config_site_id = 1;
med_loglevel_t config_loglevel = MEDIATOR_DEFAULT_LOGLEVEL;
@ -89,6 +90,7 @@ enum config_option {
OPT_LEG_TOKENS = 's',
OPT_MAX_ACC_AGE = 'M',
OPT_INTERMEDIATE_INTERVAL = 'I',
OPT_SITE_ID = 'j',
};
static const char options[] = "?a:c:e:D:i:dlL:h:u:p:b:o:H:U:P:B:O:S:t:T:r:R:A:N:Z:z:W:w:X:x:msM:I:y:Y:";
@ -132,6 +134,7 @@ struct option long_options[] = {
{ "leg-tokens", no_argument, NULL, OPT_LEG_TOKENS },
{ "max-acc-age", required_argument, NULL, OPT_MAX_ACC_AGE },
{ "intermediate-interval", required_argument, NULL, OPT_INTERMEDIATE_INTERVAL },
{ "site-id", required_argument, NULL, OPT_SITE_ID },
{ NULL, 0, NULL, 0 },
};
@ -180,6 +183,7 @@ static void config_help(const char *self, int rc)
" -s, --leg-tokens\tStrict acc fields (move to trash otherwise).\n" \
" -M, --max-acc-age\tMaximum age of acc records before trashing them (default = disabled).\n" \
" -I, --intermediate-interval\tHow often to write/update intermediate CDRs (default = disabled).\n" \
" -k, --site-id\tForce a specific multi site id to run with (default = 0).\n" \
" -?, --help\t\tDisplays this message.\n",
MEDIATOR_VERSION, self, MEDIATOR_DEFAULT_CONFIG_FILE,
MEDIATOR_DEFAULT_PIDPATH, MEDIATOR_DEFAULT_LOGLEVEL,
@ -332,6 +336,9 @@ static void config_set_option(enum config_option option, const char *value)
case OPT_INTERMEDIATE_INTERVAL:
config_intermediate_interval = atoi(value);
break;
case OPT_SITE_ID:
config_site_id = atoi(value);
break;
}
}

@ -49,6 +49,8 @@ extern int strict_leg_tokens;
extern int config_max_acc_age;
extern int config_intermediate_interval;
extern int config_site_id;
extern med_loglevel_t config_loglevel;
int config_parse(int argc, char **argv);

@ -269,8 +269,8 @@ int main(int argc, char **argv)
return -1;
}
L_NOTICE("Up and running, daemonized=%d, pid-path='%s', interval=%d",
config_daemonize, config_pid_path, config_interval);
L_NOTICE("Up and running, daemonized=%d, pid-path='%s', interval=%d site-id=%d",
config_daemonize, config_pid_path, config_interval, config_site_id);
sd_notify(0, "READY=1\n");
maprefresh = 0;

@ -1898,9 +1898,9 @@ static int medmysql_flush_call_stat_info() {
}
query.len = sprintf(query.str,
"insert into %s.call_info set period='%s', sip_code='%s', amount=%" PRIu64 " on duplicate key update period='%s', sip_code='%s', amount=(amount+%" PRIu64 ");",
"insert into %s.call_info set site_id='%d', period='%s', sip_code='%s', amount=%" PRIu64 " on duplicate key update period='%s', sip_code='%s', amount=(amount+%" PRIu64 ");",
config_stats_db,
period_t->period, period_t->call_code, period_t->amount,
config_site_id, period_t->period, period_t->call_code, period_t->amount,
period_t->period, period_t->call_code, period_t->amount
);

Loading…
Cancel
Save