Bash script to moniter current_heap_memory , max_heap_till_now , current_ram , max_ram_used , current_cpu_by_jvm details of all java programs running on current linux system
jpsstat.sh
file and select properties
Permissions
tab, check the Allow executing file as program
option../jpsstat.sh
This tool expects options in ./jpsstat.sh [option]
format.
-l
: use this option to display the full package name for the application's main class or the full path name to the application's JAR file-h
: display the help details. You can also use -help
Example: ./jpsstat.sh -l
or ./jpsstat.sh -h
ctrl+c
to stop the script and enter reset
to clear your screenjps
command to get the list of all processes running java programs (jvm instances)jstat -gc <process_id>
jstat -gc
output -
S0U
: Survivor space 0 utilizationS1U
: Survivor space 1 utilizationEU
: Eden space utilizationOU
: Old space utilizationps -p <process_id> -o %cpu
commandrss
field of the output of /proc/<pid>/statm
command to get the memory(RAM) used by the java process.tput cuu <# of lines>
to refresh screen%.*
./jpsstat.sh: 38: ./jpsstat.sh: Syntax error: "(" unexpected
./jpsstat.sh
and not as sh ./jpsstat.sh
bash --version
to make sure your bash version is >= 4.0bash: ./jpsstat.sh: Permission denied
chmod 777 jpsstat.sh
command or follow How to use section to give execute permission to script file.MIT License
Copyright (c) 2017 Amarjeet Anand
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.