1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 18:07:20 +00:00

Plugins jstat__*: add support for Java 1.8

This commit is contained in:
Lars Kruse 2018-07-04 04:09:58 +02:00
parent 3398ff3c0c
commit f5e6d7ea17
3 changed files with 98 additions and 98 deletions

View file

@ -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:
#
@ -46,28 +47,21 @@ JAVA_HOME=${javahome:-$default_java_home}
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
@ -95,14 +89,16 @@ print_stats() {
if [ "${JDK_TYPE}" == "bea" ]; then
# shellcheck disable=SC2016
awk_script='{ YC = $4; OC = $5; print "Young_GC.value " YGC; print "Old_GC.value " FGC; }'
else
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
# 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"
}
chk_jdk
#
# autoconf
@ -114,12 +110,6 @@ 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
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}"
exit 1
@ -130,6 +120,9 @@ if [ "$1" = "autoconf" ]; then
fi
JDK_TYPE=$(get_jdk_type)
if [ "$1" = "config" ]; then
print_config
exit 0