Forráskód Böngészése

kamctl: added acc command

- list acc records fromd database
Daniel-Constantin Mierla 6 éve
szülő
commit
e2784b5ea2
2 módosított fájl, 58 hozzáadás és 0 törlés
  1. 42 0
      utils/kamctl/kamctl
  2. 16 0
      utils/kamctl/kamctl.base

+ 42 - 0
utils/kamctl/kamctl

@@ -2332,6 +2332,44 @@ $SD_SD_DOMAIN_COLUMN='$OSERDOMAIN'"
 	esac
 	esac
 } # end speed_dial()
 } # 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
 ### subscriber management
@@ -3048,6 +3086,10 @@ case $1 in
 		speeddial "$@"
 		speeddial "$@"
 		;;
 		;;
 
 
+	acc)
+		acc "$@"
+		;;
+
 	tls)
 	tls)
 		shift
 		shift
 		tls_ca "$@"
 		tls_ca "$@"

+ 16 - 0
utils/kamctl/kamctl.base

@@ -353,6 +353,11 @@ DIALPLAN_SUBST_EXP_COLUMN=subst_exp
 DIALPLAN_REPL_EXP_COLUMN=repl_exp
 DIALPLAN_REPL_EXP_COLUMN=repl_exp
 DIALPLAN_ATTRS_COLUMN=attrs
 DIALPLAN_ATTRS_COLUMN=attrs
 
 
+# ACC table
+if [ -z "$ACC_TABLE" ] ; then
+	ACC_TABLE=acc
+fi
+
 #
 #
 ##### ------------------------------------------------ #####
 ##### ------------------------------------------------ #####
 ### usage functions
 ### usage functions
@@ -567,6 +572,17 @@ EOF
 }
 }
 USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_mtree"
 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
 #### Common functions