mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-08-01 22:03:57 +00:00
Plugins jstat__*: simplify handling of different JVM types
This commit is contained in:
parent
4c755fd4a7
commit
3398ff3c0c
3 changed files with 157 additions and 323 deletions
|
@ -69,97 +69,55 @@ chk_version()
|
|||
fi
|
||||
}
|
||||
|
||||
config_common()
|
||||
{
|
||||
echo 'graph_title GC Time' $graphtitle
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel GC Time(sec)'
|
||||
echo 'graph_total total'
|
||||
echo 'graph_info GC Time'
|
||||
echo 'graph_category virtualization'
|
||||
print_config() {
|
||||
echo 'graph_title GC Time' $graphtitle
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel GC Time(sec)'
|
||||
echo 'graph_total total'
|
||||
echo 'graph_info GC Time'
|
||||
echo 'graph_category virtualization'
|
||||
|
||||
echo 'Young_GC.label Young_GC'
|
||||
echo 'Young_GC.min 0'
|
||||
if [ "${JDK_TYPE}" == "bea" ]; then
|
||||
echo 'Old_GC.label Old_GC'
|
||||
echo 'Old_GC.min 0'
|
||||
echo 'Young_Pause.label Young_GC Pause'
|
||||
echo 'Young_Pause.min 0'
|
||||
echo 'Old_Pause.label Old_GC Pause'
|
||||
echo 'Old_Pause.min 0'
|
||||
else
|
||||
echo 'Full_GC.label Full_GC'
|
||||
echo 'Full_GC.min 0'
|
||||
fi
|
||||
}
|
||||
|
||||
config_sun_jdk()
|
||||
{
|
||||
config_common
|
||||
|
||||
echo 'Young_GC.label Young_GC'
|
||||
echo 'Young_GC.min 0'
|
||||
echo 'Full_GC.label Full_GC'
|
||||
echo 'Full_GC.min 0'
|
||||
|
||||
print_stats() {
|
||||
local pid_num="$1"
|
||||
local awk_script
|
||||
if [ "${JDK_TYPE}" == "bea" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
awk_script='{
|
||||
YCTime = $6;
|
||||
OCTime = $7;
|
||||
YCPauseTime = $9;
|
||||
OCPauseTime = $10;
|
||||
print "Young_GC.value " YCTime;
|
||||
print "Old_GC.value " OCTime;
|
||||
print "Young_Pause.value " YCPauseTime;
|
||||
print "Old_Pause.value " OCPauseTime; }'
|
||||
else
|
||||
# shellcheck disable=SC2016
|
||||
awk_script='{
|
||||
YGCT = $12;
|
||||
FGCT = $14;
|
||||
print "Young_GC.value " YGCT;
|
||||
print "Full_GC.value " FGCT; }'
|
||||
fi
|
||||
"${JAVA_HOME}/bin/jstat" -gc "$pid_num" | tail -1 | awk "$awk_script"
|
||||
}
|
||||
|
||||
config_bea_jdk()
|
||||
{
|
||||
config_common
|
||||
|
||||
echo 'Young_GC.label Young_GC'
|
||||
echo 'Young_GC.min 0'
|
||||
echo 'Old_GC.label Old_GC'
|
||||
echo 'Old_GC.min 0'
|
||||
echo 'Young_Pause.label Young_GC Pause'
|
||||
echo 'Young_Pause.min 0'
|
||||
echo 'Old_Pause.label Old_GC Pause'
|
||||
echo 'Old_Pause.min 0'
|
||||
|
||||
}
|
||||
|
||||
print_sun_stats()
|
||||
{
|
||||
${JAVA_HOME}/bin/jstat -gc ${PidNum} | tail -1 | awk \
|
||||
'{\
|
||||
S0C = $1; \
|
||||
S1C = $2; \
|
||||
S0U = $3; \
|
||||
S1U = $4; \
|
||||
EC = $5; \
|
||||
EU = $6; \
|
||||
OC = $7; \
|
||||
OU = $8; \
|
||||
PC = $9; \
|
||||
PU = $10; \
|
||||
YGC = $11; \
|
||||
YGCT = $12; \
|
||||
FGC = $13; \
|
||||
FGCT = $14; \
|
||||
GCT = $15; \
|
||||
|
||||
\
|
||||
S0F = S0C - S0U; \
|
||||
S1F = S1C - S1U; \
|
||||
EF = EC - EU; \
|
||||
OF = OC - OU; \
|
||||
PF = PC - PU; \
|
||||
\
|
||||
print "Young_GC.value " YGCT; \
|
||||
print "Full_GC.value " FGCT; \
|
||||
}'
|
||||
}
|
||||
|
||||
print_bea_stats()
|
||||
{
|
||||
${JAVA_HOME}/bin/jstat -gc ${PidNum} | tail -1 | awk \
|
||||
'{\
|
||||
HeapSize = $1; \
|
||||
NurserySize = $2; \
|
||||
UsedHeapSize = $3; \
|
||||
YC = $4; \
|
||||
OC = $5; \
|
||||
YCTime = $6; \
|
||||
OCTime = $7; \
|
||||
GCTime = $8; \
|
||||
YCPauseTime = $9; \
|
||||
OCPauseTime = $10; \
|
||||
PauseTime = $11; \
|
||||
Finalizers = $12; \
|
||||
\
|
||||
print "Young_GC.value " YCTime; \
|
||||
print "Old_GC.value " OCTime; \
|
||||
print "Young_Pause.value " YCPauseTime; \
|
||||
print "Old_Pause.value " OCPauseTime
|
||||
}'
|
||||
}
|
||||
|
||||
#
|
||||
# common for all argument
|
||||
|
@ -192,25 +150,8 @@ if [ "$1" = "autoconf" ]; then
|
|||
fi
|
||||
|
||||
|
||||
#
|
||||
# config
|
||||
#
|
||||
if [ "$1" = "config" ]; then
|
||||
if [ "${JDK_TYPE}" == "bea" ]; then
|
||||
config_bea_jdk
|
||||
else
|
||||
config_sun_jdk
|
||||
fi
|
||||
exit 0
|
||||
print_config
|
||||
fi
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
PidNum=`cat ${pidfilepath}`
|
||||
|
||||
if [ "${JDK_TYPE}" == "bea" ]; then
|
||||
print_bea_stats
|
||||
else
|
||||
print_sun_stats
|
||||
fi
|
||||
print_stats "$(cat "$pidfilepath")"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue