[sr-dev] git:master:2ddc54ba: kamctl: added acc initdb command

Daniel-Constantin Mierla miconda at gmail.com
Fri Mar 29 10:18:43 CET 2019


Module: kamailio
Branch: master
Commit: 2ddc54ba212aa9c64a5488e8ae542cc13c97f195
URL: https://github.com/kamailio/kamailio/commit/2ddc54ba212aa9c64a5488e8ae542cc13c97f195

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-03-29T10:11:06+01:00

kamctl: added acc initdb command

- command to add additional columns needed with default kamailio.cfg and
defined WITH_ACCDB for acc and missed_calls table

---

Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.base

---

Diff:  https://github.com/kamailio/kamailio/commit/2ddc54ba212aa9c64a5488e8ae542cc13c97f195.diff
Patch: https://github.com/kamailio/kamailio/commit/2ddc54ba212aa9c64a5488e8ae542cc13c97f195.patch

---

diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 3a25443355..a5f51803d8 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -2345,6 +2345,32 @@ acc() {
 	shift;
 	require_dbengine
 	case $1 in
+		initdb)
+			QUERY=$(cat <<-END
+ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
+ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
+ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
+ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
+ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
+ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
+ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
+END
+)
+			$DBCMD "$QUERY"
+			if [ $? -ne 0 ] ; then
+				merr "error - acc db init"
+				exit 1
+			fi
+
+			mecho "ok - acc db init"
+
+			;;
+
 		showdb)
 			QUERY="select * FROM $ACC_TABLE ;"
 			$DBROCMD "$QUERY"
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index 16f61e04a5..46494f5a04 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -577,6 +577,7 @@ usage_acc() {
 	mecho " -- command 'acc' - manage accounding records"
 	echo
 cat <<EOF
+ acc initdb .................. init acc table by adding extra colums
  acc showdb .................. show content of acc table
  recent [<secs>] ............. show most recent records in acc (default 300s)
 EOF




More information about the sr-dev mailing list