Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !/bin/bash
- # ******************************************
- #
- # A function which calculator the Rt of log
- #
- # ******************************************
- function getEpochMillionSecond
- {
- ret=$(date +%s%N -d "$1" | cut -b -13)
- eval $2=$ret
- }
- function map_put
- {
- eval map_$1=$2
- }
- function map_get
- {
- eval $2=\$map_$1
- }
- function map_remove
- {
- eval $2=\$map_$1
- eval unset map_$1
- }
- while read line
- do
- dv=$(echo "$line" | awk -F[][] '{print $3}')
- c=$(echo "$line" |awk -F[][] '{print $4}' | awk -F[:,] '{print $2}')
- d=$(echo "$dv" | cut -b -23)
- getEpochMillionSecond "$d" dm
- t=$(echo "$dv" | cut -b 25)
- if [ $t = "d" ]
- then
- map_put $c $dm
- continue
- fi
- if [ $t = "e" ]
- then
- map_remove $c start
- if [ -n "$start" ]
- then
- echo "$c => " $((dm - start))
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement