summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-12-15 07:17:52 +0000
committerBart Polot <bart@net.in.tum.de>2014-12-15 07:17:52 +0000
commit35ec85ce5787aff01de31ef662766c055216f24d (patch)
tree12be4ce9f8d1a90ac874d2451cc0d4a26d2fc0e2 /contrib
parent5536b530b8e53158db9d14febbed025bca54fa90 (diff)
Make process_log more generic
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/process_log.sh26
1 files changed, 19 insertions, 7 deletions
diff --git a/contrib/process_log.sh b/contrib/process_log.sh
index 18b921a29..baade73d9 100755
--- a/contrib/process_log.sh
+++ b/contrib/process_log.sh
@@ -1,18 +1,30 @@
-#!/bin/sh
+#!/bin/bash
+
+# Usage: service should print "STARTING SERVICE (srvc) for peer [PEER]" where:
+# - "srvc" is the service name (in lowercase, as in the log output).
+# It cannot contain parenthesis in its name.
+# - "PEER" is the peer ID. Should be 4 alfanumeric characters
+
grep "STARTING SERVICE " log > __tmp_peers
+
SED_EXPR=""
while read -r line; do
+ SRVC=`echo $line | sed -e 's/.*(\([^)]*\)).*/\1/'`
PEER=`echo $line | sed -e 's/.*\[\(....\)\].*/\1/'`
- PID=`echo $line | sed -e 's/.*cadet-\([0-9]*\).*/\1/'`
- echo "$PID => $PEER"
- SED_EXPR="${SED_EXPR}s/cadet-\([a-z2]*\)-$PID/CADET \1 $PEER/;"
- SED_EXPR="${SED_EXPR}s/cadet-$PID/CADET XXX $PEER/;"
+ PID=`echo $line | sed -e "s/.*$SRVC-\([0-9]*\).*/\1/"`
+ echo "$SRVC $PID => $PEER"
+
+ SED_EXPR="${SED_EXPR}s/$SRVC-\([a-z2]*\)-$PID/$SRVC \1 $PEER/;"
+ SED_EXPR="${SED_EXPR}s/$SRVC-$PID/$SRVC XXX $PEER/;"
+ SED_EXPR="${SED_EXPR}s/$SRVC-api-[0-9]/$SRVC-api- /;"
done < __tmp_peers
rm __tmp_peers
-SED_EXPR="${SED_EXPR}s/cadet-api-/cadet-api- /g"
sed -e "$SED_EXPR" log > .log
+echo "$0 sed regex: $SED_EXPR" >> .log
+
+SIZE=`stat -c%s .log`
-if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" ]]; then
+if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" && "$SIZE" < 10000000 ]]; then
kwrite .log --geometry 960x1140-960 &
fi