Change in osmo-msc[master]: remove msc specific db counters

lynxis lazus gerrit-no-reply at lists.osmocom.org
Sat Apr 27 15:42:36 UTC 2019


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/13800


Change subject: remove msc specific db counters
......................................................................

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
---
M include/osmocom/msc/db.h
M src/libmsc/db.c
M src/osmo-msc/msc_main.c
3 files changed, 2 insertions(+), 92 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/00/13800/1

diff --git a/include/osmocom/msc/db.h b/include/osmocom/msc/db.h
index 6d07055..ff5f5ef 100644
--- a/include/osmocom/msc/db.h
+++ b/include/osmocom/msc/db.h
@@ -50,10 +50,4 @@
 int db_sms_delete_expired_message_by_id(unsigned long long sms_id);
 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 */
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index b5e7ad8..9053b1b 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -1057,63 +1057,3 @@
 
 	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;
-}
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index b55d38f..c60a30c 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -97,19 +97,14 @@
 	const char *config_file;
 	int daemonize;
 	const char *mncc_sock_path;
-	int use_db_counter;
 } msc_cmdline_config = {
 	.database_name = "sms.db",
 	.config_file = "osmo-msc.cfg",
-	.use_db_counter = 1,
 };
 
 /* timer to store statistics */
-#define DB_SYNC_INTERVAL	60, 0
 #define EXPIRE_INTERVAL		10, 0
 
-static struct osmo_timer_list db_sync_timer;
-
 static int quit = 0;
 
 static void print_usage()
@@ -130,7 +125,6 @@
 	printf("  -V --version               Print the version of OsmoMSC.\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("  -C --no-dbcounter          Disable regular syncing of counters to database.\n");
 }
 
 static void handle_options(int argc, char **argv)
@@ -148,7 +142,7 @@
 			{"version", 0, 0, 'V' },
 			{"log-level", 1, 0, 'e'},
 			{"mncc-sock-path", 1, 0, 'M'},
-			{"no-dbcounter", 0, 0, 'C'},
+			{"no-dbcounter", 0, 0, 'C'}, /* deprecated */
 			{0, 0, 0, 0}
 		};
 
@@ -187,7 +181,7 @@
 			msc_cmdline_config.mncc_sock_path = optarg;
 			break;
 		case 'C':
-			msc_cmdline_config.use_db_counter = 0;
+			fprintf(stderr, "-C is deprecated and does nothing.");
 			break;
 		case 'V':
 			print_version(1);
@@ -254,19 +248,6 @@
 	}
 }
 
-/* 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)
 {
 	switch (vty->node) {
@@ -664,11 +645,6 @@
 		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(SIGTERM, &signal_handler);
 	signal(SIGABRT, &signal_handler);

-- 
To view, visit https://gerrit.osmocom.org/13800
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id64f1839a55b5326f74ec04b7a5dbed9d269b89c
Gerrit-Change-Number: 13800
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190427/7fd3ed3d/attachment.html>


More information about the gerrit-log mailing list