[sr-dev] git:master:955e8a54: kamctl: usrloc command to delete older expired records from database table

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 14 13:06:51 CEST 2019


Module: kamailio
Branch: master
Commit: 955e8a5412490020b719f7f57d0a068916bcf8e5
URL: https://github.com/kamailio/kamailio/commit/955e8a5412490020b719f7f57d0a068916bcf8e5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-06-14T13:06:32+02:00

kamctl: usrloc command to delete older expired records from database table

- kamctl ul dbclean [<secs>]
- if secs parameter is not given, the value 3600 is used

---

Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.ctlbase

---

Diff:  https://github.com/kamailio/kamailio/commit/955e8a5412490020b719f7f57d0a068916bcf8e5.diff
Patch: https://github.com/kamailio/kamailio/commit/955e8a5412490020b719f7f57d0a068916bcf8e5.patch

---

diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index a5f51803d8..cc92e0eba6 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -2717,6 +2717,18 @@ usrloc() {
 			fi
 			;;
 
+		dbclean)
+			require_dbengine
+			KSR_CLEAN_VAL=3600
+			if [ $# -eq 2 ] ; then
+				KSR_CLEAN_VAL=$2
+			fi
+			QUERY="delete from $USRLOC_TABLE where expires < SUBDATE(NOW(), INTERVAL $KSR_CLEAN_VAL SECOND);"
+			$DBCMD "$QUERY"
+
+			exit $?
+			;;
+
 		*)
 			usage_usrloc
 			exit 1
diff --git a/utils/kamctl/kamctl.ctlbase b/utils/kamctl/kamctl.ctlbase
index 1fc64091af..5215099a3e 100644
--- a/utils/kamctl/kamctl.ctlbase
+++ b/utils/kamctl/kamctl.ctlbase
@@ -71,6 +71,7 @@ cat <<EOF
  ul add <username> <uri> ............... introduce a permanent usrloc entry
  ul add <username> <uri> <expires> ..... introduce a temporary usrloc entry
  ul add <user> <uri> <expires> <path> .. introduce a temporary usrloc entry
+ ul dbclean [<secs>].................... remove older expired records from db table
 EOF
 }
 USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_usrloc"




More information about the sr-dev mailing list