diff options
Diffstat (limited to 'contrib/process_log.sh')
-rwxr-xr-x | contrib/process_log.sh | 26 |
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 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | |||
3 | # Usage: service should print "STARTING SERVICE (srvc) for peer [PEER]" where: | ||
4 | # - "srvc" is the service name (in lowercase, as in the log output). | ||
5 | # It cannot contain parenthesis in its name. | ||
6 | # - "PEER" is the peer ID. Should be 4 alfanumeric characters | ||
7 | |||
2 | grep "STARTING SERVICE " log > __tmp_peers | 8 | grep "STARTING SERVICE " log > __tmp_peers |
9 | |||
3 | SED_EXPR="" | 10 | SED_EXPR="" |
4 | while read -r line; do | 11 | while read -r line; do |
12 | SRVC=`echo $line | sed -e 's/.*(\([^)]*\)).*/\1/'` | ||
5 | PEER=`echo $line | sed -e 's/.*\[\(....\)\].*/\1/'` | 13 | PEER=`echo $line | sed -e 's/.*\[\(....\)\].*/\1/'` |
6 | PID=`echo $line | sed -e 's/.*cadet-\([0-9]*\).*/\1/'` | 14 | PID=`echo $line | sed -e "s/.*$SRVC-\([0-9]*\).*/\1/"` |
7 | echo "$PID => $PEER" | 15 | echo "$SRVC $PID => $PEER" |
8 | SED_EXPR="${SED_EXPR}s/cadet-\([a-z2]*\)-$PID/CADET \1 $PEER/;" | 16 | |
9 | SED_EXPR="${SED_EXPR}s/cadet-$PID/CADET XXX $PEER/;" | 17 | SED_EXPR="${SED_EXPR}s/$SRVC-\([a-z2]*\)-$PID/$SRVC \1 $PEER/;" |
18 | SED_EXPR="${SED_EXPR}s/$SRVC-$PID/$SRVC XXX $PEER/;" | ||
19 | SED_EXPR="${SED_EXPR}s/$SRVC-api-[0-9]/$SRVC-api- /;" | ||
10 | done < __tmp_peers | 20 | done < __tmp_peers |
11 | rm __tmp_peers | 21 | rm __tmp_peers |
12 | 22 | ||
13 | SED_EXPR="${SED_EXPR}s/cadet-api-/cadet-api- /g" | ||
14 | sed -e "$SED_EXPR" log > .log | 23 | sed -e "$SED_EXPR" log > .log |
24 | echo "$0 sed regex: $SED_EXPR" >> .log | ||
25 | |||
26 | SIZE=`stat -c%s .log` | ||
15 | 27 | ||
16 | if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" ]]; then | 28 | if [[ "`ps aux | grep "kwrite .lo[g]"`" = "" && "$SIZE" < 10000000 ]]; then |
17 | kwrite .log --geometry 960x1140-960 & | 29 | kwrite .log --geometry 960x1140-960 & |
18 | fi | 30 | fi |