Skip to content

Instantly share code, notes, and snippets.

@jturel
Created October 5, 2021 23:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jturel/7c22f4017f00c441e22cd90e3a17bd16 to your computer and use it in GitHub Desktop.
Save jturel/7c22f4017f00c441e22cd90e3a17bd16 to your computer and use it in GitHub Desktop.
function extract_request_id(str) {
reqidIdx = match(str, /[a-z0-9]{8}/)
return substr(str, reqidIdx, 8)
}
BEGIN {
}
/Processing by/ {
{
req_id = extract_request_id($2)
requests[req_id] = $5
next
}
}
/Completed/ {
{
idx = match($0, /Allocations: [0-9]+/)
num_allocations = substr($0, idx, RLENGTH)
gsub(/[^0-9]+/, "", num_allocations)
req_id = extract_request_id($2)
type = requests[req_id]
if (!type) {
print "Couldn't determine type for request:"
print $0
next
}
total_allocations_by_type[type] += num_allocations
request_count_by_type[type]++
}
}
END {
printf "%-70s\t%-10s\t%s\t%s\n", "REQUEST", "REQUESTS", "TOTAL ALLOCATIONS", "AVG ALLOCATIONS"
for (request_type in total_allocations_by_type) {
avg = (total_allocations_by_type[request_type] / request_count_by_type[request_type])
average_allocations[request_type] = avg
}
PROCINFO["sorted_in"] = "@val_num_desc"
asort(average_allocations, keys)
for (request_type in average_allocations) {
printf "%-70s\t%-10d\t%-20d\t%d\n", request_type, request_count_by_type[request_type], total_allocations_by_type[request_type], average_allocations[request_type]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment