Posted By

cruelfate on 01/07/11


Tagged

java awk jvm gc garbage collector


Versions (?)

GC-freq.awk


 / Published in: Awk
 

Parse Java stdout (or .out log) and print GC frequency per minute. Assumes following JVM flags are set:

-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -verbose:gc

  1. #! /usr/bin/awk -f
  2.  
  3. # Awk script to parse Java .out log and print GC frequency per minute
  4. #
  5. # Assumes following JVM flags are set:
  6. # -XX:+PrintGCDetails
  7. # -XX:+PrintGCTimeStamps
  8. # -verbose:gc
  9.  
  10. BEGIN {print "t,count"}
  11.  
  12. /\[GC:/ {
  13. split($7, a, ":");
  14. t=a[1]":"a[2];
  15. freq[t]++ ;
  16. if (start[1] == null) {
  17. start[1] = a[1];
  18. start[2] = a[2];
  19. }
  20. end[1] = a[1];
  21. end[2] = a[2];
  22. }
  23.  
  24. END {
  25. for (hour = start[1]; hour <= end[1]; hour++) {
  26. for (minute = 0; minute <= 59; minute++) {
  27. t = sprintf("%02d:%02d", hour, minute);
  28. if (freq[t] == null) {
  29. printf "%s,%d\n", t, 0;
  30. } else {
  31. printf "%s,%d\n", t, freq[t];
  32. }
  33. }
  34. }
  35. }

Report this snippet  

You need to login to post a comment.