Last active
May 24, 2021 15:49
-
-
Save mikeslattery/1dff7b9eb1b9acad5a0f6a78e35a8c8c to your computer and use it in GitHub Desktop.
Monitor memory use of all running java applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Display memory useage of all running java processes | |
pidof java | xargs -r ps -f | |
echo '' | |
echo $'PID\t% MEM\tTMEM\tGC Time' | |
while true; do | |
for pid in $(pidof java); do | |
echo -n "$pid " | |
jstat -gc $pid | awk 'NR>1{ print 100.0 * $8 / $7, $8, $17}' | |
sleep 2 | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment