Module: kamailio
Branch: master
Commit: e2784b5ea2a796455b62deb2f85b1547dce2ad67
URL:
https://github.com/kamailio/kamailio/commit/e2784b5ea2a796455b62deb2f85b154…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-25T02:20:14+01:00
kamctl: added acc command
- list acc records fromd database
---
Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.base
---
Diff:
https://github.com/kamailio/kamailio/commit/e2784b5ea2a796455b62deb2f85b154…
Patch:
https://github.com/kamailio/kamailio/commit/e2784b5ea2a796455b62deb2f85b154…
---
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index d9d70a538e..012cf20a05 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -2332,6 +2332,44 @@ $SD_SD_DOMAIN_COLUMN='$OSERDOMAIN'"
esac
} # end speed_dial()
+#
+##### ------------------------------------------------ #####
+### acc management
+#
+acc() {
+ if [ "$#" -lt 2 ] ; then
+ merr "acc - too few parameters"
+ usage_acc
+ exit 1
+ fi
+ shift;
+ require_dbengine
+ case $1 in
+ showdb)
+ QUERY="select * FROM $ACC_TABLE ;"
+ $DBROCMD "$QUERY"
+ ;;
+
+ recent)
+ TIMENOW=`date +"%s"`
+ if [ $# -eq 2 ] ; then
+ CLAUSE=" WHERE time>=$TIMENOW - $2 "
+ else
+ CLAUSE=" WHERE time>=$TIMENOW - 300 "
+ fi
+ QUERY="select * FROM $ACC_TABLE $CLAUSE ; "
+ $DBROCMD "$QUERY"
+ ;;
+
+
+ *)
+ usage_acc
+ exit 1
+ ;;
+ esac
+} # end acc()
+
+
#
##### ================================================ #####
### subscriber management
@@ -3048,6 +3086,10 @@ case $1 in
speeddial "$@"
;;
+ acc)
+ acc "$@"
+ ;;
+
tls)
shift
tls_ca "$@"
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index b538cd70d1..ef94526d21 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -353,6 +353,11 @@ DIALPLAN_SUBST_EXP_COLUMN=subst_exp
DIALPLAN_REPL_EXP_COLUMN=repl_exp
DIALPLAN_ATTRS_COLUMN=attrs
+# ACC table
+if [ -z "$ACC_TABLE" ] ; then
+ ACC_TABLE=acc
+fi
+
#
##### ------------------------------------------------ #####
### usage functions
@@ -567,6 +572,17 @@ EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_mtree"
+usage_acc() {
+ echo
+ mecho " -- command 'acc' - manage accounding records"
+ echo
+cat <<EOF
+ acc showdb .................. show content of acc table
+ recent [<secs>] ............. show most recent records in acc (default 300s)
+EOF
+}
+USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_acc"
+
##### ----------------------------------------------- #####
#### Common functions