浏览代码

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

Daniel-Constantin Mierla 8 年之前
父节点
当前提交
997e2e1412
共有 2 个文件被更改,包括 15 次插入7 次删除
  1. 9 1
      utils/kamctl/kamctl.base
  2. 6 6
      utils/kamctl/kamctl.rpcfifo

+ 9 - 1
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]);

+ 6 - 6
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",