[sr-dev] git:master:997e2e14: kamctl: more compact jsonrpc output by expanding tabs to two whitespaces

Daniel-Constantin Mierla miconda at gmail.com
Fri Dec 16 21:28:41 CET 2016


Module: kamailio
Branch: master
Commit: 997e2e141211450f1a1798b1d89cebe06f3b0079
URL: https://github.com/kamailio/kamailio/commit/997e2e141211450f1a1798b1d89cebe06f3b0079

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-12-16T21:27:54+01:00

kamctl: more compact jsonrpc output by expanding tabs to two whitespaces

---

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

---

Diff:  https://github.com/kamailio/kamailio/commit/997e2e141211450f1a1798b1d89cebe06f3b0079.diff
Patch: https://github.com/kamailio/kamailio/commit/997e2e141211450f1a1798b1d89cebe06f3b0079.patch

---

diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index 1ca1cc0..8b2a8f0 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -89,6 +89,14 @@ if [ -z "$EXPR" ] ; then
 	fi
 	EXPR="$TOOLPATH"
 fi
+if [ -z "$EXPAND" ] ; then
+	locate_tool expand
+	if [ -z "$TOOLPATH" ] ; then
+		EXPAND="cat"
+	else
+		EXPAND="$TOOLPATH -t 2"
+	fi
+fi
 
 ##### ------------------------------------------------ #####
 ### configuration for starting/stopping kamailio
@@ -680,7 +688,7 @@ filter_json()
 				n=split($0, a, ",");
 				for (i=1; i<=n; i++) {
 					if (i==1) {
-						m=split(a[i], b, "\[");
+						m=split(a[i], b, "[");
 						print b[1] "[";
 						if (substr(b[2], length(b[2]), 1)=="[" || substr(b[2], length(b[2]), 1)=="{") {
 							print "\t\t" ltrim(b[2]);
diff --git a/utils/kamctl/kamctl.rpcfifo b/utils/kamctl/kamctl.rpcfifo
index 2742e81..f529e0f 100644
--- a/utils/kamctl/kamctl.rpcfifo
+++ b/utils/kamctl/kamctl.rpcfifo
@@ -121,7 +121,7 @@ rpc_cmd()
 
 	# start reader now so that it is ready for replies
 	# immediately after a request was sent out
-	cat < $path | filter_json &
+	cat < $path | filter_json | $EXPAND &
 
 	# issue FIFO request (printf taken to deal with \n)
 	printf "$CMD" > $RPCFIFOPATH
@@ -202,7 +202,7 @@ rpc_kamailio_monitor() {
 		# print_stats $name $path $attempt
 		mecho "[cycle #: $attempt; if constant make sure server lives]"
 
-		cat < $path | filter_json &
+		cat < $path | filter_json | $EXPAND &
 		cat > $RPCFIFOPATH <<EOF
 {
   "jsonrpc": "2.0",
@@ -213,7 +213,7 @@ rpc_kamailio_monitor() {
 EOF
 		wait
 
-		cat < $path | filter_json &
+		cat < $path | filter_json | $EXPAND &
 		cat > $RPCFIFOPATH << EOF
 {
   "jsonrpc": "2.0",
@@ -226,7 +226,7 @@ EOF
 		echo
 
 		mecho "Transaction Statistics: "
-		cat < $path | filter_json &
+		cat < $path | filter_json | $EXPAND &
 		cat > $RPCFIFOPATH <<EOF
 {
   "jsonrpc": "2.0",
@@ -240,7 +240,7 @@ EOF
 		echo
 
 		mecho "Stateless Server Statistics: "
-		cat < $path | filter_json &
+		cat < $path | filter_json | $EXPAND &
 		cat > $RPCFIFOPATH <<EOF
 {
   "jsonrpc": "2.0",
@@ -254,7 +254,7 @@ EOF
 		echo
 
 		mecho "UsrLoc Stats: "
-		cat < $path | filter_json &
+		cat < $path | filter_json | $EXPAND &
 		cat > $RPCFIFOPATH <<EOF
 {
   "jsonrpc": "2.0",




More information about the sr-dev mailing list