Guest User

Untitled

a guest
Nov 24th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. awk -F, -v hour="$4" -v tgtdate="$5" -v variance=50 '
  2.  
  3. (NF==2) {
  4.  
  5. topprotos[$1] = $2
  6.  
  7. }
  8.  
  9. (NF == 4) {
  10.  
  11. split($2, datepieces, "T")
  12.  
  13. split(datepieces[2], timepieces, ":")
  14.  
  15. if (datepieces[1] == tgtdate) {
  16.  
  17. if (!($1 in hour_compare)) {
  18.  
  19. hour_compare[$1] = 0
  20.  
  21. }
  22.  
  23. hour_compare[$1] += $3
  24.  
  25. } else if (timepieces[1] == hour) {
  26.  
  27. file_key = $1 "," datepieces[1]
  28.  
  29. sums[file_key] += $3
  30.  
  31. }
  32.  
  33. }
  34.  
  35. END {
  36.  
  37. for (key in sums) {
  38.  
  39. split(key, keypieces, ",")
  40.  
  41. protocol = keypieces[1]
  42.  
  43.  
  44. if (!(protocol in topprotos)) continue
  45.  
  46.  
  47. if (sums[key] > max_value[protocol]) {
  48.  
  49. max_value[protocol] = sums[key]
  50.  
  51. }
  52.  
  53. if (sums[key] < min_value[protocol] || min_value[protocol] == 0) {
  54.  
  55. min_value[protocol] = sums[key]
  56.  
  57. }
  58.  
  59.  
  60. print key " : " sums[key]
  61.  
  62. }
  63.  
  64.  
  65. for (protocol in topprotos) {
  66.  
  67.  
  68. if (!(protocol in max_value) || !(protocol in min_value)) continue
  69.  
  70.  
  71. print "Protocol: " protocol
  72.  
  73. print "Max Value: " max_value[protocol]
  74.  
  75. print "Min Value: " min_value[protocol]
  76.  
  77.  
  78. max_bound = int(max_value[protocol] * (1 + variance / 100))
  79.  
  80. min_bound = int(min_value[protocol] * (1 - variance / 100))
  81.  
  82.  
  83. }
  84.  
  85.  
  86. for (protocol in topprotos) {
  87.  
  88. if (hour_compare[protocol] > max_bound) {
  89.  
  90. print protocol " " hour_compare[protocol] " is greater than the max boundary: " max_bound
  91.  
  92. }
  93.  
  94. if (hour_compare[protocol] < min_bound) {
  95.  
  96. print protocol " " hour_compare[protocol] " is less than the minimum boundary: " min_bound
  97.  
  98. }
  99.  
  100. }
  101.  
  102. }
  103.  
  104. ' "$1" "$2" "$3"
Advertisement
Add Comment
Please, Sign In to add comment