2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #934 from sumpfralle/jstat-plugins

jstat plugins: various improvements
This commit is contained in:
Lars Kruse 2018-08-26 01:33:04 +02:00 committed by GitHub
commit 99f6979f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 301 additions and 485 deletions

View File

@ -6,6 +6,10 @@
ceph_osd - Shows ceph OSD states (total configured, up and in)
=head1 APPLICABLE SYSTEMS
Any host with ceph configured and "jq" being installed .
=head1 AUTHOR
Mate Gabri <mate@gabri.hu>
@ -46,7 +50,6 @@ fi
CEPH_STATUS=$(ceph -s --format=json)
echo "osds.value $(echo $CEPH_STATUS | jq '.osdmap.osdmap.num_osds')"
echo "up.value $(echo $CEPH_STATUS | jq '.osdmap.osdmap.num_up_osds')"
echo "in.value $(echo $CEPH_STATUS | jq '.osdmap.osdmap.num_in_osds')"
echo "osds.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_osds')"
echo "up.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_up_osds')"
echo "in.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_in_osds')"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Plugin for monitor JVM activity - GC Count -
#
@ -22,9 +22,10 @@
#
# Target:
#
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/) (default)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/)
# Sun JDK 8.0 (http://java.sun.com/javase/)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
#
# Parameters:
#
@ -33,140 +34,74 @@
# Config variables:
#
# pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid'
# javahome - Defaults to '/usr/local/java/jdk'
# javahome - override automatic detection of JRE directory
# graphtitle - Title of the graph (defaults to PID file location)
#
DefaultPidFile="/var/run/jsvc.pid"
DefaultJavaHome="/usr/local/java/jdk"
#
# Environment Variables
#
if [ -z "${pidfilepath}" ]; then
pidfilepath="${DefaultPidFile}"
fi
default_java_home=/usr/lib/jvm/default-java
[ -e "$default_java_home" ] || default_java_home=/usr/local/java/jdk
if [ -z "${graphtitle}" ]; then
graphtitle="${pidfilepath}"
fi
pidfilepath=${pidfilepath:-/var/run/jsvc.pid}
graphtitle=${graphtitle:-$pidfilepath}
JAVA_HOME=${javahome:-$default_java_home}
if [ -z "${javahome}" ]; then
JAVA_HOME="${DefaultJavaHome}"
else
JAVA_HOME="${javahome}"
fi
export JAVA_HOME
#
# Functions
#
chk_jdk()
{
isJRockit=`${JAVA_HOME}/bin/java -version 2>&1 | egrep -i 'jrockit'`
if [ -n "${isJRockit}" ]; then
JDK_TYPE="bea"
else
JDK_TYPE="sun"
get_jdk_type() {
local version
if "${JAVA_HOME}/bin/java" -version 2>&1 | grep -qi 'jrockit'; then
echo "bea"
else
version=$("${JAVA_HOME}/bin/java" -version 2>&1 | grep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1)
if echo "$version" | grep -q '^1\.5\.'; then
echo "sun15"
else
echo "sun"
fi
fi
}
chk_version()
{
Version=`${JAVA_HOME}/bin/java -version 2>&1 | egrep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1`
if [ "${Version}" != "1.5.0" ]; then
return 1
else
return 0
fi
print_config() {
echo "graph_title GC Count $graphtitle"
echo 'graph_args -l 0'
echo 'graph_vlabel GC Count(times)'
echo 'graph_total total'
echo 'graph_info GC Count'
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'
else
echo 'Full_GC.label Full_GC'
echo 'Full_GC.min 0'
fi
}
config_common()
{
echo 'graph_title GC Count' $graphtitle
echo 'graph_args -l 0'
echo 'graph_vlabel GC Count(times)'
echo 'graph_total total'
echo 'graph_info GC Count'
echo 'graph_category virtualization'
print_stats() {
local pid_num="$1"
local awk_script
if [ "${JDK_TYPE}" = "bea" ]; then
# shellcheck disable=SC2016
awk_script='{ YC = $4; OC = $5; print "Young_GC.value " YGC; print "Old_GC.value " FGC; }'
elif [ "${JDK_TYPE}" = "sun15" ]; then
# shellcheck disable=SC2016
awk_script='{ YGC = $11; FGC = $13; print "Young_GC.value " YGC; print "Full_GC.value " FGC; }'
else
# example output of jstat for Java 1.8:
# S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
# 2048.0 2048.0 0.0 1344.0 694784.0 145013.5 1398272.0 414857.1 102400.0 96308.0 12544.0 11240.1 979 20.997 5 2.705 23.702
# shellcheck disable=SC2016
awk_script='{ YGC = $13; FGC = $15; print "Young_GC.value " YGC; print "Full_GC.value " FGC; }'
fi
"${JAVA_HOME}/bin/jstat" -gc "$pid_num" | tail -1 | awk "$awk_script"
}
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'
}
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'
}
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 " YGC; \
print "Full_GC.value " FGC; \
}'
}
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 " YC; \
print "Old_GC.value " OC;\
}'
}
#
# common for all argument
#
chk_jdk
#
# autoconf
@ -178,13 +113,7 @@ if [ "$1" = "autoconf" ]; then
exit 1
fi
chk_version
if [ $? != 0 ]; then
echo "no (Java version is invalid)"
exit 1
fi
if [ ! -f "${pidfilepath}" -o ! -r "${pidfilepath}" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}"
exit 1
fi
@ -194,25 +123,12 @@ if [ "$1" = "autoconf" ]; then
fi
#
# config
#
JDK_TYPE=$(get_jdk_type)
if [ "$1" = "config" ]; then
if [ "${JDK_TYPE}" == "bea" ]; then
config_bea_jdk
else
config_sun_jdk
fi
exit 0
print_config
exit 0
fi
#
# Main
#
PidNum=`cat ${pidfilepath}`
if [ "${JDK_TYPE}" == "bea" ]; then
print_bea_stats
else
print_sun_stats
fi
print_stats "$(cat "$pidfilepath")"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Plugin for monitor JVM activity - GC Time -
#
@ -22,9 +22,10 @@
#
# Target:
#
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/) (default)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/)
# Sun JDK 8.0 (http://java.sun.com/javase/)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
#
# Parameters:
#
@ -33,148 +34,94 @@
# Config variables:
#
# pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid'
# javahome - Defaults to '/usr/local/java/jdk'
# javahome - override automatic detection of JRE directory
# graphtitle - Title of the graph (defaults to PID file location)
#
DefaultPidFile="/var/run/jsvc.pid"
DefaultJavaHome="/usr/local/java/jdk"
#
# Environment Variables
#
if [ -z "${pidfilepath}" ]; then
pidfilepath="${DefaultPidFile}"
fi
default_java_home=/usr/lib/jvm/default-java
[ -e "$default_java_home" ] || default_java_home=/usr/local/java/jdk
if [ -z "${graphtitle}" ]; then
graphtitle="${pidfilepath}"
fi
pidfilepath=${pidfilepath:-/var/run/jsvc.pid}
graphtitle=${graphtitle:-$pidfilepath}
JAVA_HOME=${javahome:-$default_java_home}
if [ -z "${javahome}" ]; then
JAVA_HOME="${DefaultJavaHome}"
else
JAVA_HOME="${javahome}"
fi
export JAVA_HOME
#
# Functions
#
chk_jdk()
{
isJRockit=`${JAVA_HOME}/bin/java -version 2>&1 | egrep -i 'jrockit'`
if [ -n "${isJRockit}" ]; then
JDK_TYPE="bea"
else
JDK_TYPE="sun"
get_jdk_type() {
local version
if "${JAVA_HOME}/bin/java" -version 2>&1 | grep -qi 'jrockit'; then
echo "bea"
else
version=$("${JAVA_HOME}/bin/java" -version 2>&1 | grep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1)
if echo "$version" | grep -q '^1\.5\.'; then
echo "sun15"
else
echo "sun"
fi
fi
}
chk_version()
{
Version=`${JAVA_HOME}/bin/java -version 2>&1 | egrep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1`
if [ "${Version}" != "1.5.0" ]; then
return 1
else
return 0
fi
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_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_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; }'
elif [ "${JDK_TYPE}" = "sun15" ]; then
# shellcheck disable=SC2016
awk_script='{
YGCT = $12;
FGCT = $14;
print "Young_GC.value " YGCT;
print "Full_GC.value " FGCT; }'
else
# example output of jstat for Java 1.8:
# S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
# 2048.0 2048.0 0.0 1344.0 694784.0 145013.5 1398272.0 414857.1 102400.0 96308.0 12544.0 11240.1 979 20.997 5 2.705 23.702
# shellcheck disable=SC2016
awk_script='{
YGCT = $14;
FGCT = $16;
print "Young_GC.value " YGCT;
print "Full_GC.value " FGCT; }'
fi
"${JAVA_HOME}/bin/jstat" -gc "$pid_num" | tail -1 | awk "$awk_script"
}
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'
}
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
#
chk_jdk
#
# autoconf
@ -186,13 +133,7 @@ if [ "$1" = "autoconf" ]; then
exit 1
fi
chk_version
if [ $? != 0 ]; then
echo "no (Java version is invalid)"
exit 1
fi
if [ ! -f "${pidfilepath}" -o ! -r "${pidfilepath}" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}"
exit 1
fi
@ -202,25 +143,11 @@ if [ "$1" = "autoconf" ]; then
fi
#
# config
#
JDK_TYPE=$(get_jdk_type)
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")"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Plugin for monitor JVM activity - Heap Usage -
#
@ -22,9 +22,10 @@
#
# Target:
#
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/) (default)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
# Target Java Virtual Machine to monitor are:
# Sun JDK 5.0 (http://java.sun.com/javase/)
# Sun JDK 8.0 (http://java.sun.com/javase/)
# BEA JRockit 5.0 (http://dev2dev.bea.com/jrockit/)
#
# Parameters:
#
@ -33,160 +34,149 @@
# Config variables:
#
# pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid'
# javahome - Defaults to '/usr/local/java/jdk'
# javahome - override automatic detection of JRE directory
# graphtitle - Title of the graph (defaults to PID file location)
#
DefaultPidFile="/var/run/jsvc.pid"
DefaultJavaHome="/usr/local/java/jdk"
#
# Environment Variables
#
if [ -z "${pidfilepath}" ]; then
pidfilepath="${DefaultPidFile}"
fi
default_java_home=/usr/lib/jvm/default-java
[ -e "$default_java_home" ] || default_java_home=/usr/local/java/jdk
if [ -z "${graphtitle}" ]; then
graphtitle="${pidfilepath}"
fi
pidfilepath=${pidfilepath:-/var/run/jsvc.pid}
graphtitle=${graphtitle:-$pidfilepath}
JAVA_HOME=${javahome:-$default_java_home}
if [ -z "${javahome}" ]; then
JAVA_HOME="${DefaultJavaHome}"
else
JAVA_HOME="${javahome}"
fi
export JAVA_HOME
#
# Functions
#
chk_jdk()
{
isJRockit=`${JAVA_HOME}/bin/java -version 2>&1 | egrep -i 'jrockit'`
if [ -n "${isJRockit}" ]; then
JDK_TYPE="bea"
else
JDK_TYPE="sun"
get_jdk_type() {
local version
if "${JAVA_HOME}/bin/java" -version 2>&1 | grep -qi 'jrockit'; then
echo "bea"
else
version=$("${JAVA_HOME}/bin/java" -version 2>&1 | grep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1)
if echo "$version" | grep -q '^1\.5\.'; then
echo "sun15"
else
echo "sun"
fi
fi
}
chk_version()
{
Version=`${JAVA_HOME}/bin/java -version 2>&1 | egrep '^java version' | awk '{print $3}' | sed -e 's/\"//g' | cut -d'_' -f 1`
if [ "${Version}" != "1.5.0" ]; then
return 1
else
return 0
fi
print_config() {
echo "graph_title Heap Usage $graphtitle"
echo "graph_args --base 1024 -l 0"
echo "graph_vlabel Heap Usage(Bytes)"
echo "graph_info Heap Usage"
echo "graph_category virtualization"
if [ "${JDK_TYPE}" = "bea" ]; then
echo "NurserySize.label NurserySize"
echo "HeapSize.label HeapSize"
echo "UsedHeapSize.label UsedHeapSize"
echo "NurserySize.draw AREA"
echo "HeapSize.draw STACK"
echo "UsedHeapSize.draw STACK"
else
echo "Eden_Used.label Eden_Used"
echo "Eden_Free.label Eden_Free"
echo "Survivor0_Used.label Survivor0_Used"
echo "Survivor0_Free.label Survivor0_Free"
echo "Survivor1_Used.label Survivor1_Used"
echo "Survivor1_Free.label Survivor1_Free"
echo "Old_Used.label Old_Used"
echo "Old_Free.label Old_Free"
echo "Permanent_Used.label Permanent_Used"
echo "Permanent_Free.label Permanent_Free"
echo "Eden_Used.draw AREA"
echo "Eden_Free.draw STACK"
echo "Survivor0_Used.draw STACK"
echo "Survivor0_Free.draw STACK"
echo "Survivor1_Used.draw STACK"
echo "Survivor1_Free.draw STACK"
echo "Old_Used.draw STACK"
echo "Old_Free.draw STACK"
echo "Permanent_Used.draw STACK"
echo "Permanent_Free.draw STACK"
fi
}
config_common()
{
echo "graph_title Heap Usage" $graphtitle
echo "graph_args --base 1024 -l 0"
echo "graph_vlabel Heap Usage(Bytes)"
echo "graph_info Heap Usage"
echo "graph_category virtualization"
print_stats() {
local pid_num="$1"
local awk_script
if [ "${JDK_TYPE}" = "bea" ]; then
# shellcheck disable=SC2016
awk_script='{
HeapSize = $1;
NurserySize = $2;
UsedHeapSize = $3;
print "NurserySize.value " NurserySize * 1024;
print "HeapSize.value " HeapSize * 1024;
print "UsedHeapSize.value " UsedHeapSize * 1024; }'
elif [ "${JDK_TYPE}" = "sun15" ]; then
# shellcheck disable=SC2016
awk_script='{
S0C = $1;
S1C = $2;
S0U = $3;
S1U = $4;
EC = $5;
EU = $6;
OC = $7;
OU = $8;
PC = $9;
PU = $10;
S0F = S0C - S0U;
S1F = S1C - S1U;
EF = EC - EU;
OF = OC - OU;
PF = PC - PU;
print "Eden_Used.value " EU * 1024;
print "Eden_Free.value " EF * 1024;
print "Survivor0_Used.value " S0U * 1024;
print "Survivor0_Free.value " S0F * 1024;
print "Survivor1_Used.value " S1U * 1024;
print "Survivor1_Free.value " S1F * 1024;
print "Old_Used.value " OU * 1024;
print "Old_Free.value " OF * 1024;
print "Permanent_Used.value " PU * 1024;
print "Permanent_Free.value " PF * 1024; }'
else
# example output of jstat for Java 1.8:
# S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
# 2048.0 2048.0 0.0 1344.0 694784.0 145013.5 1398272.0 414857.1 102400.0 96308.0 12544.0 11240.1 979 20.997 5 2.705 23.702
# shellcheck disable=SC2016
awk_script='{
S0C = $1;
S1C = $2;
S0U = $3;
S1U = $4;
EC = $5;
EU = $6;
OC = $7;
OU = $8;
MC = $9;
MU = $10;
S0F = S0C - S0U;
S1F = S1C - S1U;
EF = EC - EU;
OF = OC - OU;
MF = MC - MU;
print "Eden_Used.value " EU * 1024;
print "Eden_Free.value " EF * 1024;
print "Survivor0_Used.value " S0U * 1024;
print "Survivor0_Free.value " S0F * 1024;
print "Survivor1_Used.value " S1U * 1024;
print "Survivor1_Free.value " S1F * 1024;
print "Old_Used.value " OU * 1024;
print "Old_Free.value " OF * 1024;
print "Permanent_Used.value " PU * 1024;
print "Permanent_Free.value " MF * 1024; }'
fi
"${JAVA_HOME}/bin/jstat" -gc "$pid_num" | tail -1 | awk "$awk_script"
}
config_sun_jdk()
{
config_common
echo "Eden_Used.label Eden_Used"
echo "Eden_Free.label Eden_Free"
echo "Survivor0_Used.label Survivor0_Used"
echo "Survivor0_Free.label Survivor0_Free"
echo "Survivor1_Used.label Survivor1_Used"
echo "Survivor1_Free.label Survivor1_Free"
echo "Old_Used.label Old_Used"
echo "Old_Free.label Old_Free"
echo "Permanent_Used.label Permanent_Used"
echo "Permanent_Free.label Permanent_Free"
echo "Eden_Used.draw AREA"
echo "Eden_Free.draw STACK"
echo "Survivor0_Used.draw STACK"
echo "Survivor0_Free.draw STACK"
echo "Survivor1_Used.draw STACK"
echo "Survivor1_Free.draw STACK"
echo "Old_Used.draw STACK"
echo "Old_Free.draw STACK"
echo "Permanent_Used.draw STACK"
echo "Permanent_Free.draw STACK"
}
config_bea_jdk()
{
config_common
echo "NurserySize.label NurserySize"
echo "HeapSize.label HeapSize"
echo "UsedHeapSize.label UsedHeapSize"
echo "NurserySize.draw AREA"
echo "HeapSize.draw STACK"
echo "UsedHeapSize.draw STACK"
}
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; \
\
S0F = S0C - S0U; \
S1F = S1C - S1U; \
EF = EC - EU; \
OF = OC - OU; \
PF = PC - PU; \
\
print "Eden_Used.value " EU * 1024; \
print "Eden_Free.value " EF * 1024; \
print "Survivor0_Used.value " S0U * 1024; \
print "Survivor0_Free.value " S0F * 1024; \
print "Survivor1_Used.value " S1U * 1024; \
print "Survivor1_Free.value " S1F * 1024; \
print "Old_Used.value " OU * 1024; \
print "Old_Free.value " OF * 1024; \
print "Permanent_Used.value " PU * 1024; \
print "Permanent_Free.value " PF * 1024; \
}'
}
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 "NurserySize.value " NurserySize * 1024; \
print "HeapSize.value " UsedHeapSize * 1024; \
print "UsedHeapSize.value " UsedHeapSize * 1024; \
}'
}
#
# common for all argument
#
chk_jdk
#
# autoconf
@ -198,13 +188,7 @@ if [ "$1" = "autoconf" ]; then
exit 1
fi
chk_version
if [ $? != 0 ]; then
echo "no (Java version is invalid)"
exit 1
fi
if [ ! -f "${pidfilepath}" -o ! -r "${pidfilepath}" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}"
exit 1
fi
@ -214,25 +198,11 @@ if [ "$1" = "autoconf" ]; then
fi
#
# config
#
JDK_TYPE=$(get_jdk_type)
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")"