Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- awk -F, -v hour="$4" -v tgtdate="$5" -v variance=50 '
- (NF==2) {
- topprotos[$1] = $2
- }
- (NF == 4) {
- split($2, datepieces, "T")
- split(datepieces[2], timepieces, ":")
- if (datepieces[1] == tgtdate) {
- if (!($1 in hour_compare)) {
- hour_compare[$1] = 0
- }
- hour_compare[$1] += $3
- } else if (timepieces[1] == hour) {
- file_key = $1 "," datepieces[1]
- sums[file_key] += $3
- }
- }
- END {
- for (key in sums) {
- split(key, keypieces, ",")
- protocol = keypieces[1]
- if (!(protocol in topprotos)) continue
- if (sums[key] > max_value[protocol]) {
- max_value[protocol] = sums[key]
- }
- if (sums[key] < min_value[protocol] || min_value[protocol] == 0) {
- min_value[protocol] = sums[key]
- }
- print key " : " sums[key]
- }
- for (protocol in topprotos) {
- if (!(protocol in max_value) || !(protocol in min_value)) continue
- print "Protocol: " protocol
- print "Max Value: " max_value[protocol]
- print "Min Value: " min_value[protocol]
- max_bound = int(max_value[protocol] * (1 + variance / 100))
- min_bound = int(min_value[protocol] * (1 - variance / 100))
- }
- for (protocol in topprotos) {
- if (hour_compare[protocol] > max_bound) {
- print protocol " " hour_compare[protocol] " is greater than the max boundary: " max_bound
- }
- if (hour_compare[protocol] < min_bound) {
- print protocol " " hour_compare[protocol] " is less than the minimum boundary: " min_bound
- }
- }
- }
- ' "$1" "$2" "$3"
Advertisement
Add Comment
Please, Sign In to add comment