Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
Last active March 10, 2017 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mostlygeek/d3d0cc1ab08923933e672329fa494914 to your computer and use it in GitHub Desktop.
Save mostlygeek/d3d0cc1ab08923933e672329fa494914 to your computer and use it in GitHub Desktop.
sync log awk script tools
#!/usr/bin/awk -f
BEGIN {
idx[0] = 5
idx[1] = 10
idx[2] = 25
idx[3] = 50
idx[4] = 100
idx[5] = 500
idx[6] = 1000
idx[7] = 2000
idx[8] = 4000
idx[9] = 10000
idx[10] = 60000
maxBucket = 10
}
{
GTIME=$(NF-3)*1000;
for (i=0; i<=maxBucket; i++) {
if (GTIME < idx[i]) {
buckets[idx[i]]++
break
}
}
}
END {
printf "Total rows: %d\n", NR
printf " %5s %8s %s\n", "bucket", "count", "pct"
for (i=0; i<=maxBucket; i++) {
printf "< %5dms %8d %.2f%%\n", idx[i], buckets[idx[i]], buckets[idx[i]]/NR*100
}
}
#!/usr/bin/awk -f
{printf "%16s %s %3s %5d %5s %s\n",$1,$2,$7,$(NF-3)*1000,$4,$5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment