2010-11-16 03:34:56 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-07-05 04:46:12 +02:00
|
|
|
set -u -e
|
|
|
|
|
2011-09-30 14:42:44 +02:00
|
|
|
CONNNAME=""
|
|
|
|
|
2011-07-05 04:46:12 +02:00
|
|
|
usage() {
|
|
|
|
echo "usage: %0 --long|--short logfile*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "--long" = $1 ]; then
|
|
|
|
LONG=1
|
|
|
|
elif [ "--short" = $1 ]; then
|
|
|
|
LONG=""
|
|
|
|
else
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
2010-11-16 03:34:56 +01:00
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
LOG=$1
|
|
|
|
while read LINE; do
|
|
|
|
case "$LINE" in
|
|
|
|
*got_connect_cmd:\ connName* )
|
|
|
|
CONNNAME="$(echo $LINE | sed 's,^.*connName: "\(.*\)"$,\1,')"
|
|
|
|
;;
|
2011-07-07 05:02:51 +02:00
|
|
|
*got_connect_cmd:\ set\ hostid* )
|
2010-11-16 03:34:56 +01:00
|
|
|
HOSTID=$(echo $LINE | sed 's,^.*set hostid: \(.\)$,\1,')
|
|
|
|
;;
|
|
|
|
*getChannelSeed:\ channelSeed:*)
|
|
|
|
SEED=$(echo $LINE | sed 's,^.*getChannelSeed: channelSeed: \(.*\)$,\1,')
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < $LOG
|
|
|
|
if [ -z "${CONNNAME}" ]; then
|
|
|
|
echo "CONNNAME not found in $LOG" >&2
|
|
|
|
elif [ -z "${HOSTID}" ]; then
|
|
|
|
echo "HOSTID not found in $LOG" >&2
|
2011-07-01 04:37:37 +02:00
|
|
|
elif [ "${HOSTID}" -eq 0 ]; then
|
|
|
|
echo "HOSTID 0 in $LOG; try later" >&2
|
2011-07-05 04:46:12 +02:00
|
|
|
elif [ -n "$LONG" -a -z "${SEED}" ]; then
|
2010-11-16 03:34:56 +01:00
|
|
|
echo "SEED not found in $LOG" >&2
|
|
|
|
else
|
2011-07-05 04:46:12 +02:00
|
|
|
RESULT=${CONNNAME}/${HOSTID}
|
|
|
|
if [ -n "$LONG" ]; then
|
|
|
|
RESULT="${RESULT}/${SEED}"
|
|
|
|
fi
|
|
|
|
echo $RESULT
|
2010-11-16 03:34:56 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|