remove msc specific db counters

DB counters has been used to save osmo_counters & osmo_rate_ctr to a local
sqlite databases every 60 seconds.
This is quite slow e.g. 1000 subscriber might slow the msc down.

Change-Id: Id64f1839a55b5326f74ec04b7a5dbed9d269b89c
This commit is contained in:
Alexander Couzens 2019-04-27 17:36:47 +02:00 committed by Harald Welte
parent f15852b992
commit b10ec6a751
4 changed files with 4 additions and 94 deletions

View File

@ -43,8 +43,8 @@ arguments:
*-m, --mncc-sock*:: *-m, --mncc-sock*::
Same as option -M (deprecated). Same as option -M (deprecated).
*-C, --no-dbcounter*:: *-C, --no-dbcounter*::
Disable the regular periodic synchronization of statistics Deprecated. DB statistics and counter has been removed.
counters to the database. This option is only valid for compatiblity and does nothing.
=== Multiple instances === Multiple instances

View File

@ -52,10 +52,4 @@ int db_sms_delete_sent_message_by_id(unsigned long long sms_id);
int db_sms_delete_expired_message_by_id(unsigned long long sms_id); int db_sms_delete_expired_message_by_id(unsigned long long sms_id);
void db_sms_delete_oldest_expired_message(void); void db_sms_delete_oldest_expired_message(void);
/* Statistics counter storage */
struct osmo_counter;
int db_store_counter(struct osmo_counter *ctr);
struct rate_ctr_group;
int db_store_rate_ctr_group(struct rate_ctr_group *ctrg);
#endif /* _DB_H */ #endif /* _DB_H */

View File

@ -1060,63 +1060,3 @@ void db_sms_delete_oldest_expired_message(void)
dbi_result_free(result); dbi_result_free(result);
} }
int db_store_counter(struct osmo_counter *ctr)
{
dbi_result result;
char *q_name;
dbi_conn_quote_string_copy(conn, ctr->name, &q_name);
result = dbi_conn_queryf(conn,
"INSERT INTO Counters "
"(timestamp,name,value) VALUES "
"(datetime('now'),%s,%lu)", q_name, ctr->value);
free(q_name);
if (!result)
return -EIO;
dbi_result_free(result);
return 0;
}
static int db_store_rate_ctr(struct rate_ctr_group *ctrg, unsigned int num,
char *q_prefix)
{
dbi_result result;
char *q_name;
dbi_conn_quote_string_copy(conn, ctrg->desc->ctr_desc[num].name,
&q_name);
result = dbi_conn_queryf(conn,
"Insert INTO RateCounters "
"(timestamp,name,idx,value) VALUES "
"(datetime('now'),%s.%s,%u,%"PRIu64")",
q_prefix, q_name, ctrg->idx, ctrg->ctr[num].current);
free(q_name);
if (!result)
return -EIO;
dbi_result_free(result);
return 0;
}
int db_store_rate_ctr_group(struct rate_ctr_group *ctrg)
{
unsigned int i;
char *q_prefix;
dbi_conn_quote_string_copy(conn, ctrg->desc->group_name_prefix, &q_prefix);
for (i = 0; i < ctrg->desc->num_ctr; i++)
db_store_rate_ctr(ctrg, i, q_prefix);
free(q_prefix);
return 0;
}

View File

@ -102,19 +102,14 @@ static struct {
const char *config_file; const char *config_file;
int daemonize; int daemonize;
const char *mncc_sock_path; const char *mncc_sock_path;
int use_db_counter;
} msc_cmdline_config = { } msc_cmdline_config = {
.database_name = "sms.db", .database_name = "sms.db",
.config_file = "osmo-msc.cfg", .config_file = "osmo-msc.cfg",
.use_db_counter = 1,
}; };
/* timer to store statistics */ /* timer to store statistics */
#define DB_SYNC_INTERVAL 60, 0
#define EXPIRE_INTERVAL 10, 0 #define EXPIRE_INTERVAL 10, 0
static struct osmo_timer_list db_sync_timer;
static int quit = 0; static int quit = 0;
static void print_usage() static void print_usage()
@ -135,7 +130,6 @@ static void print_help()
printf(" -V --version Print the version of OsmoMSC.\n"); printf(" -V --version Print the version of OsmoMSC.\n");
printf(" -e --log-level number Set a global loglevel.\n"); printf(" -e --log-level number Set a global loglevel.\n");
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n"); printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
printf(" -C --no-dbcounter Disable regular syncing of counters to database.\n");
} }
static void handle_options(int argc, char **argv) static void handle_options(int argc, char **argv)
@ -153,7 +147,7 @@ static void handle_options(int argc, char **argv)
{"version", 0, 0, 'V' }, {"version", 0, 0, 'V' },
{"log-level", 1, 0, 'e'}, {"log-level", 1, 0, 'e'},
{"mncc-sock-path", 1, 0, 'M'}, {"mncc-sock-path", 1, 0, 'M'},
{"no-dbcounter", 0, 0, 'C'}, {"no-dbcounter", 0, 0, 'C'}, /* deprecated */
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -192,7 +186,7 @@ static void handle_options(int argc, char **argv)
msc_cmdline_config.mncc_sock_path = optarg; msc_cmdline_config.mncc_sock_path = optarg;
break; break;
case 'C': case 'C':
msc_cmdline_config.use_db_counter = 0; fprintf(stderr, "-C is deprecated and does nothing.");
break; break;
case 'V': case 'V':
print_version(1); print_version(1);
@ -260,19 +254,6 @@ static void signal_handler(int signal)
} }
} }
/* timer handling */
static int _db_store_counter(struct osmo_counter *counter, void *data)
{
return db_store_counter(counter);
}
static void db_sync_timer_cb(void *data)
{
/* store counters to database and re-schedule */
osmo_counters_for_each(_db_store_counter, NULL);
osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
}
static int msc_vty_go_parent(struct vty *vty) static int msc_vty_go_parent(struct vty *vty)
{ {
switch (vty->node) { switch (vty->node) {
@ -665,11 +646,6 @@ TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_i
return 5; return 5;
} }
/* setup the timer */
osmo_timer_setup(&db_sync_timer, db_sync_timer_cb, NULL);
if (msc_cmdline_config.use_db_counter)
osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
signal(SIGINT, &signal_handler); signal(SIGINT, &signal_handler);
signal(SIGTERM, &signal_handler); signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler); signal(SIGABRT, &signal_handler);