Skip to content

Instantly share code, notes, and snippets.

@rhenning
Created January 6, 2014 19:14
Show Gist options
  • Save rhenning/8288077 to your computer and use it in GitHub Desktop.
Save rhenning/8288077 to your computer and use it in GitHub Desktop.
Watch JVM heap utilization
#!/usr/bin/env ruby
## run like: tail --lines=0 --follow=name /var/log/tomcat6/gc.log | this_ruby_script
ARGF.each do |line|
if match = /secs\]\s\d+K-\>(\d+)K\((\d+)K\)/.match(line)
heap_cur = match[1]
heap_lim = match[2]
heap_pct = heap_cur.to_f / heap_lim.to_f * 100.0
puts "#{heap_cur} / #{heap_lim} KiB : #{heap_pct}%"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment