Advertisement
Guest User

Untitled

a guest
May 4th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. !/bin/bash
  2. # ******************************************
  3. #
  4. # A function which calculator the Rt of log
  5. #
  6. # ******************************************
  7.  
  8. function getEpochMillionSecond
  9. {
  10. ret=$(date +%s%N -d "$1" | cut -b -13)
  11. eval $2=$ret
  12. }
  13.  
  14. function map_put
  15. {
  16. eval map_$1=$2
  17. }
  18.  
  19. function map_get
  20. {
  21. eval $2=\$map_$1
  22. }
  23.  
  24. function map_remove
  25. {
  26. eval $2=\$map_$1
  27. eval unset map_$1
  28. }
  29.  
  30. while read line
  31. do
  32. dv=$(echo "$line" | awk -F[][] '{print $3}')
  33. c=$(echo "$line" |awk -F[][] '{print $4}' | awk -F[:,] '{print $2}')
  34. d=$(echo "$dv" | cut -b -23)
  35. getEpochMillionSecond "$d" dm
  36. t=$(echo "$dv" | cut -b 25)
  37. if [ $t = "d" ]
  38. then
  39. map_put $c $dm
  40. continue
  41. fi
  42. if [ $t = "e" ]
  43. then
  44. map_remove $c start
  45. if [ -n "$start" ]
  46. then
  47. echo "$c => " $((dm - start))
  48. fi
  49. fi
  50. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement