Module: sip-router
Branch: master
Commit: 833632a0eafcbbbcd7ce53937c4b4a21f99d9bec
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=833632a…
Author: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Date: Thu May 20 16:24:55 2010 +0300
Extended kamctl with new features built over sercmd:
1. Posibility to run sercmd commands via "kamctl ser" (no readline enhancements
yet)
2. A new CTLENGINE ser_mi that besides unixsock and fifo provides access to mi commands.
"CTLENGINE=ser_mi kamctl ser_mi debug 3"
---
utils/kamctl/Makefile | 10 ++++
utils/kamctl/kamctl | 20 ++++++++-
utils/kamctl/kamctl.ser | 60 +++++++++++++++++++++++++++
utils/kamctl/kamctl.ser_mi | 98 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 187 insertions(+), 1 deletions(-)
diff --git a/utils/kamctl/Makefile b/utils/kamctl/Makefile
index 61bcee0..57677a0 100644
--- a/utils/kamctl/Makefile
+++ b/utils/kamctl/Makefile
@@ -48,6 +48,16 @@ install-bin: $(bin_prefix)/$(bin_dir)
$(modules_prefix)/$(lib_dir)/kamctl/kamctl.fifo
rm -fr /tmp/kamctl.fifo
sed -e "s#/usr/local#$(bin_target)#g" \
+ < kamctl.ser > /tmp/kamctl.ser
+ $(INSTALL_CFG) /tmp/kamctl.ser \
+ $(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser
+ rm -fr /tmp/kamctl.ser
+ sed -e "s#/usr/local#$(bin_target)#g" \
+ < kamctl.ser_mi > /tmp/kamctl.ser_mi
+ $(INSTALL_CFG) /tmp/kamctl.ser_mi \
+ $(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser_mi
+ rm -fr /tmp/kamctl.ser_mi
+ sed -e "s#/usr/local#$(bin_target)#g" \
< kamctl.unixsock > /tmp/kamctl.unixsock
$(INSTALL_CFG) /tmp/kamctl.unixsock \
$(modules_prefix)/$(lib_dir)/kamctl/kamctl.unixsock
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index afb7a46..09a0fb8 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -127,8 +127,21 @@ case $CTLENGINE in
CTLENGINELOADED=1
fi
;;
+ SER_MI|ser_mi)
+ if [ -f "$MYLIBDIR/kamctl.ser_mi" ]; then
+ . "$MYLIBDIR/kamctl.ser_mi"
+ CTLENGINELOADED=1
+ fi
+ ;;
esac
+#### ------------------------------------------------- #####
+### Load sercm interface
+#
+if [ -f "$MYLIBDIR/kamctl.ser" ]; then
+ . "$MYLIBDIR/kamctl.ser"
+fi
+
if [ $CTLENGINELOADED -eq 1 ] ; then
mdbg "Control engine '$CTLENGINE' loaded"
else
@@ -2313,12 +2326,17 @@ case $1 in
trusted "$@"
;;
- fifo|unixsock)
+ fifo|unixsock|ser_mi)
require_ctlengine
shift
$CTLCMD "$@"
;;
+ ser)
+ shift
+ $SERCTLCMD "$@"
+ ;;
+
lcr)
shift
lcr "$@"
diff --git a/utils/kamctl/kamctl.ser b/utils/kamctl/kamctl.ser
new file mode 100644
index 0000000..b70deed
--- /dev/null
+++ b/utils/kamctl/kamctl.ser
@@ -0,0 +1,60 @@
+#
+# $Id$
+#
+# control tool for maintaining Kamailio
+#
+#===================================================================
+
+##### ----------------------------------------------- #####
+### FIFO specific variables and functions
+#
+
+##### ----------------------------------------------- #####
+### load CTL base
+#
+if [ -f "$MYLIBDIR/kamctl.ctlbase" ]; then
+ . "$MYLIBDIR/kamctl.ctlbase"
+else
+ mwarn "Cannot load CTL core functions '$MYLIBDIR/kamctl.ctlbase' ..."
+ # exit -1
+fi
+
+#
+##### ----------------------------------------------- #####
+### parameters
+#
+SERCMD=`which sercmd`
+if [ -z "$SERCMD" ] ; then
+ SERCMD="/usr/local/sbin/sercmd"
+fi
+
+#
+##### ----------------------------------------------- #####
+### functions
+#
+usage_ser() {
+ echo
+ mecho " -- command 'ser'"
+ echo
+cat <<EOF
+ ser ............................... send command thru sercmd
+EOF
+}
+USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ser"
+
+
+ser_cmd()
+{
+ mdbg "entering ser_mi_cmd $*"
+
+ if [ "$#" -lt 1 ]; then
+ merr "ser_cmd must take at least command name as parameter"
+ exit 1
+ fi
+
+
+ $SERCMD "$@"
+}
+
+SERCTLCMD=ser_cmd
+
diff --git a/utils/kamctl/kamctl.ser_mi b/utils/kamctl/kamctl.ser_mi
new file mode 100644
index 0000000..fdf247c
--- /dev/null
+++ b/utils/kamctl/kamctl.ser_mi
@@ -0,0 +1,98 @@
+#
+# $Id$
+#
+# control tool for maintaining Kamailio
+#
+#===================================================================
+
+##### ----------------------------------------------- #####
+### FIFO specific variables and functions
+#
+
+##### ----------------------------------------------- #####
+### load CTL base
+#
+if [ -f "$MYLIBDIR/kamctl.ctlbase" ]; then
+ . "$MYLIBDIR/kamctl.ctlbase"
+else
+ mwarn "Cannot load CTL core functions '$MYLIBDIR/kamctl.ctlbase' ..."
+ # exit -1
+fi
+
+#
+##### ----------------------------------------------- #####
+### parameters
+#
+SERCMD=`which sercmd`
+if [ -z "$SERCMD" ] ; then
+ SERCMD="/usr/local/sbin/sercmd"
+fi
+
+#
+##### ----------------------------------------------- #####
+### functions
+#
+usage_ser_mi() {
+ echo
+ mecho " -- command 'ser_mi'"
+ echo
+cat <<EOF
+ ser ............................... send mi command thru sercmd
+EOF
+}
+USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ser_mi"
+
+
+ser_mi_cmd()
+{
+ mdbg "entering ser_mi_cmd $*"
+
+ if [ "$#" -lt 1 ]; then
+ merr "ser_cmd must take at least command name as parameter"
+ exit 1
+ fi
+
+
+ $SERCMD mi "$@"
+}
+
+CTLCMD=ser_mi_cmd
+
+ser_mi_monitor() {
+ trap "rm $path; clear; echo monitor ^C-ed; exit 1" 2
+ attempt=0
+ if [ "$2" = "" ]; then
+ loops=-1;
+ else
+ loops=$2;
+ fi
+ clear
+ while [ $loops -ne $attempt ] ; do
+ attempt=`$EXPR $attempt + 1`
+ #clear
+ tput clear
+
+ # print_stats $name $path $attempt
+ mecho "[cycle #: $attempt; if constant make sure server lives]"
+
+ $SERCMD mi version
+ $SERCMD mi uptime
+ mecho "Transaction Statistics"
+ $SERCMD mi get_statistics UAS_transactions UAC_transactions inuse_transactions
+
+ mecho "Stateless Server Statistics: "
+ $SERCMD mi get_statistics sent_replies sent_err_replies received_ACKs
+
+ mecho "UsrLoc Stats: "
+ $SERCMD mi get_statistics usrloc
+ if [ $loops -ne $attempt ] ; then
+ sleep $WATCH_PERIOD
+ fi
+ done
+ exit 0
+}
+
+OPENSER_MONITOR=ser_mi_monitor
+
+
+