{"id":2855,"date":"2013-05-09T12:22:20","date_gmt":"2013-05-09T17:22:20","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=2855"},"modified":"2013-05-21T15:58:26","modified_gmt":"2013-05-21T20:58:26","slug":"formatting-garbage-collection-output-with-timestamps","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2013\/05\/09\/formatting-garbage-collection-output-with-timestamps\/","title":{"rendered":"Formatting garbage collection output with timestamps"},"content":{"rendered":"<p>If you are running a version of java where -XX:+PrintGCDateStamps is not honored, you can run what is below.<\/p>\n<p>For those that are unaware, by default garbage collection will print the seconds since the JVM process started.  In the heat of battle, this is almost useless unless you are the guy from &#8220;A Beautiful Mind&#8221;.<\/p>\n<p>What is below will read the entire file and convert the seconds to a timestamp.<\/p>\n<pre lang=\"text\">\r\n#!\/bin\/sh\r\n<<HEADER\r\n--------------------------------------------------------------------------------------------------------------\r\nAuthor:         Steve Howard\r\nDate:           May 9, 2013\r\nPurpose:        Print garbage collection with timestamps rather than seconds since JVM startup.\r\n                  This is a bit of a kludge, but it makes troubleshooting easier.\r\n--------------------------------------------------------------------------------------------------------------\r\nHEADER\r\n\r\nPID=$(jps | awk '$2 == \"Main\" {print $1}')\r\nSTART=$(ps -eo pid,lstart,cmd | awk -v PID=$PID '$1 == PID {gsub(\":\",\" \",$0);print $8\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7}')\r\nawk -v START=\"$START\" 'BEGIN{split(\"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec\",l,\"|\");while (i++ < length(l)) {s[l[i]]=i} {gsub(\":\",\" \",START);gsub($2,s[$2],START);split(START,t,\" \");gsub(t[2],s[t[2]],START)}} {gsub(\":\",\"\",$1);$1=strftime(\"%c\",mktime(START) + $1);print}' \/tmp\/app1.gclog\r\n<\/pre>\n<p>Output will be similar to what is below...<\/p>\n<pre lang=\"text\">\r\nThu 09 May 2013 01:20:51 PM EDT [GC 1321092.626: [ParNew: 671948K->45789K(707840K), 0.1335720 secs] 4130848K->3510152K(6212864K), 0.1422530 secs] [Times: user=0.40 sys=0.00, real=0.14 secs]\r\nThu 09 May 2013 01:21:18 PM EDT [GC 1321119.062: [ParNew: 675037K->45370K(707840K), 0.1424780 secs] 4139400K->3515895K(6212864K), 0.1507360 secs]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are running a version of java where -XX:+PrintGCDateStamps is not honored, you can run what is below. For those that are unaware, by default garbage collection will print the seconds since the JVM process started. In the heat&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2013\/05\/09\/formatting-garbage-collection-output-with-timestamps\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[24,25,28],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2855"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2855"}],"version-history":[{"count":8,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2855\/revisions"}],"predecessor-version":[{"id":2862,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2855\/revisions\/2862"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2855"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}