From 6af31ea318158bf89e0ffe5b95fd23890b6115f2 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Wed, 4 Jul 2018 03:09:45 +0200 Subject: [PATCH] Plugins jstat__*: simplify handling of environment settings --- plugins/jvm/jstat__gccount | 20 +++----------------- plugins/jvm/jstat__gctime | 20 +++----------------- plugins/jvm/jstat__heap | 20 +++----------------- 3 files changed, 9 insertions(+), 51 deletions(-) diff --git a/plugins/jvm/jstat__gccount b/plugins/jvm/jstat__gccount index 165b4118..276910ea 100755 --- a/plugins/jvm/jstat__gccount +++ b/plugins/jvm/jstat__gccount @@ -35,25 +35,11 @@ # pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid' # javahome - Defaults to '/usr/local/java/jdk' # -DefaultPidFile="/var/run/jsvc.pid" -DefaultJavaHome="/usr/local/java/jdk" -# -# Environment Variables -# -if [ -z "${pidfilepath}" ]; then - pidfilepath="${DefaultPidFile}" -fi +pidfilepath=${pidfilepath:-/var/run/jsvc.pid} +graphtitle=${graphtitle:-$pidfilepath} +JAVA_HOME=${javahome:-/usr/local/java/jdk} -if [ -z "${graphtitle}" ]; then - graphtitle="${pidfilepath}" -fi - -if [ -z "${javahome}" ]; then - JAVA_HOME="${DefaultJavaHome}" -else - JAVA_HOME="${javahome}" -fi export JAVA_HOME # diff --git a/plugins/jvm/jstat__gctime b/plugins/jvm/jstat__gctime index de221292..aad1b702 100755 --- a/plugins/jvm/jstat__gctime +++ b/plugins/jvm/jstat__gctime @@ -35,25 +35,11 @@ # pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid' # javahome - Defaults to '/usr/local/java/jdk' # -DefaultPidFile="/var/run/jsvc.pid" -DefaultJavaHome="/usr/local/java/jdk" -# -# Environment Variables -# -if [ -z "${pidfilepath}" ]; then - pidfilepath="${DefaultPidFile}" -fi +pidfilepath=${pidfilepath:-/var/run/jsvc.pid} +graphtitle=${graphtitle:-$pidfilepath} +JAVA_HOME=${javahome:-/usr/local/java/jdk} -if [ -z "${graphtitle}" ]; then - graphtitle="${pidfilepath}" -fi - -if [ -z "${javahome}" ]; then - JAVA_HOME="${DefaultJavaHome}" -else - JAVA_HOME="${javahome}" -fi export JAVA_HOME # diff --git a/plugins/jvm/jstat__heap b/plugins/jvm/jstat__heap index c4c4c33a..3eaeae73 100755 --- a/plugins/jvm/jstat__heap +++ b/plugins/jvm/jstat__heap @@ -35,25 +35,11 @@ # pidfilepath - Which file path use. Defaults to '/var/run/jsvc.pid' # javahome - Defaults to '/usr/local/java/jdk' # -DefaultPidFile="/var/run/jsvc.pid" -DefaultJavaHome="/usr/local/java/jdk" -# -# Environment Variables -# -if [ -z "${pidfilepath}" ]; then - pidfilepath="${DefaultPidFile}" -fi +pidfilepath=${pidfilepath:-/var/run/jsvc.pid} +graphtitle=${graphtitle:-$pidfilepath} +JAVA_HOME=${javahome:-/usr/local/java/jdk} -if [ -z "${graphtitle}" ]; then - graphtitle="${pidfilepath}" -fi - -if [ -z "${javahome}" ]; then - JAVA_HOME="${DefaultJavaHome}" -else - JAVA_HOME="${javahome}" -fi export JAVA_HOME #