2015-09-19 00:07:03 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 Cloudius Systems, Ltd.
|
|
|
|
|
2015-12-13 10:27:19 +01:00
|
|
|
JMX_PORT="7199"
|
2017-01-25 16:12:58 +01:00
|
|
|
JMX_ADDR=
|
|
|
|
|
|
|
|
API_ADDR=
|
|
|
|
API_PORT=
|
|
|
|
|
2015-12-13 10:27:19 +01:00
|
|
|
CONF_FILE=""
|
2016-05-05 13:20:27 +02:00
|
|
|
DEBUG=""
|
2015-09-19 00:07:03 +02:00
|
|
|
PARAM_HELP="-h"
|
|
|
|
PARAM_JMX_PORT="-jp"
|
2017-01-25 16:12:58 +01:00
|
|
|
PARAM_JMX_ADDR="-ja"
|
2015-09-19 00:07:03 +02:00
|
|
|
PARAM_API_PORT="-p"
|
|
|
|
PARAM_ADDR="-a"
|
|
|
|
PARAM_LOCATION="-l"
|
|
|
|
LOCATION="target"
|
2016-05-18 16:04:14 +02:00
|
|
|
LOCATION_SCRIPTS="scripts"
|
2015-12-13 10:27:19 +01:00
|
|
|
PARAM_FILE="-cf"
|
2016-03-01 18:52:26 +01:00
|
|
|
ALLOW_REMOTE="-r"
|
2016-05-05 13:20:27 +02:00
|
|
|
ALLOW_DEBUG="-d"
|
2016-03-01 18:52:26 +01:00
|
|
|
REMOTE=0
|
2016-10-18 03:38:10 +02:00
|
|
|
HOSTNAME=`hostname`
|
2015-09-19 00:07:03 +02:00
|
|
|
|
2017-01-25 16:12:58 +01:00
|
|
|
|
|
|
|
PROPERTIES=
|
|
|
|
JMX_AUTH=-Dcom.sun.management.jmxremote.authenticate=false
|
|
|
|
JMX_SSL=-Dcom.sun.management.jmxremote.ssl=false
|
|
|
|
|
2015-09-19 00:07:03 +02:00
|
|
|
print_help() {
|
|
|
|
cat <<HLPEND
|
|
|
|
|
2015-12-13 10:27:19 +01:00
|
|
|
scylla-jmx [$PARAM_HELP] [$PARAM_API_PORT port] [$PARAM_ADDR address] [$PARAM_JMX_PORT port] [$PARAM_FILE file]
|
2015-09-19 00:07:03 +02:00
|
|
|
|
|
|
|
This script is used to run the jmx proxy
|
|
|
|
|
|
|
|
By default it would connect to the local API ($API_ADDR) and will listen on the JMX port ($JMX_PORT)
|
|
|
|
|
|
|
|
This script receives the following command line arguments:
|
|
|
|
|
|
|
|
$PARAM_HELP - print this help screen and exit
|
|
|
|
$PARAM_JMX_PORT <port> - The jmx port to open
|
|
|
|
$PARAM_API_PORT <port> - The API port to connect to
|
|
|
|
$PARAM_ADDR <address> - The API address to connect to
|
2017-01-25 16:12:58 +01:00
|
|
|
$PARAM_JMX_ADDR <address> - JMX bind address
|
2015-12-13 10:27:19 +01:00
|
|
|
$PARAM_FILE <file> - A configuration file to use
|
2015-09-19 00:07:03 +02:00
|
|
|
$PARAM_LOCATION <location> - The location of the jmx proxy jar file
|
2016-03-01 18:52:26 +01:00
|
|
|
$ALLOW_REMOTE - When set allow remote jmx connectivity
|
2016-05-05 13:20:27 +02:00
|
|
|
$ALLOW_DEBUG - When set open debug ports for remote debugger
|
2015-09-19 00:07:03 +02:00
|
|
|
HLPEND
|
|
|
|
}
|
|
|
|
|
|
|
|
while test "$#" -ne 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
"$PARAM_API_PORT")
|
2015-12-13 10:27:19 +01:00
|
|
|
API_PORT="-Dapiport="$2
|
2015-09-19 00:07:03 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
"$PARAM_ADDR")
|
2015-12-13 10:27:19 +01:00
|
|
|
API_ADDR="-Dapiaddress="$2
|
2015-09-19 00:07:03 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
"$PARAM_JMX_PORT")
|
|
|
|
JMX_PORT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2017-01-25 16:12:58 +01:00
|
|
|
"$PARAM_JMX_ADDR")
|
|
|
|
JMX_ADDR=-Dcom.sun.management.jmxremote.host=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2015-09-19 00:07:03 +02:00
|
|
|
"$PARAM_LOCATION")
|
|
|
|
LOCATION=$2
|
2016-05-18 16:04:14 +02:00
|
|
|
LOCATION_SCRIPTS="$2"
|
2015-09-19 00:07:03 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
2015-12-13 10:27:19 +01:00
|
|
|
"$PARAM_FILE")
|
|
|
|
CONF_FILE="-Dapiconfig="$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2016-03-01 18:52:26 +01:00
|
|
|
"$ALLOW_REMOTE")
|
|
|
|
REMOTE=1
|
|
|
|
shift 1
|
|
|
|
;;
|
2015-09-19 00:07:03 +02:00
|
|
|
"$PARAM_HELP")
|
|
|
|
print_help
|
|
|
|
exit 0
|
|
|
|
;;
|
2016-05-05 13:20:27 +02:00
|
|
|
"$ALLOW_DEBUG")
|
|
|
|
DEBUG="-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:7690,server=y,suspend=n"
|
|
|
|
shift 1
|
|
|
|
;;
|
2017-01-25 16:12:58 +01:00
|
|
|
-Dcom.sun.management.jmxremote.host=*)
|
|
|
|
JMX_ADDR=$1
|
2017-02-06 13:04:59 +01:00
|
|
|
HOSTNAME=${1:36}
|
2017-01-25 16:12:58 +01:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-Dcom.sun.management.jmxremote.authenticate=*)
|
|
|
|
JMX_AUTH=$1
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-Dcom.sun.management.jmxremote.ssl=*)
|
|
|
|
JMX_SSL=$1
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-Dcom.sun.management.jmxremote.local.only=*)
|
|
|
|
JMX_LOCAL=$1
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-D*)
|
|
|
|
PROPERTIES="$PROPERTIES $1"
|
|
|
|
shift 1
|
|
|
|
;;
|
2015-09-19 00:07:03 +02:00
|
|
|
*)
|
2016-07-13 10:52:06 +02:00
|
|
|
echo "Unknown parameter: $1"
|
|
|
|
print_help
|
|
|
|
exit 1
|
2015-09-19 00:07:03 +02:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2017-01-25 16:12:58 +01:00
|
|
|
if [ $REMOTE -eq 0 ]; then
|
|
|
|
if [ -z $JMX_ADDR ]; then
|
|
|
|
JMX_ADDR=-Dcom.sun.management.jmxremote.host=localhost
|
|
|
|
fi
|
2017-02-06 13:04:59 +01:00
|
|
|
HOSTNAME=localhost
|
2016-03-01 18:52:26 +01:00
|
|
|
else
|
2017-01-25 16:12:58 +01:00
|
|
|
if [ -z $JMX_LOCAL ]; then
|
|
|
|
JMX_LOCAL=-Dcom.sun.management.jmxremote.local.only=false
|
|
|
|
fi
|
2016-03-01 18:52:26 +01:00
|
|
|
fi
|
|
|
|
|
2017-01-25 16:12:58 +01:00
|
|
|
exec "$LOCATION_SCRIPTS"/symlinks/scylla-jmx $DEBUG \
|
|
|
|
$API_PORT $API_ADDR $CONF_FILE -Xmx256m -XX:+UseSerialGC \
|
|
|
|
$JMX_AUTH $JMX_SSL $JMX_ADDR $JMX_LOCAL \
|
|
|
|
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_PORT \
|
|
|
|
-Djava.rmi.server.hostname=$HOSTNAME -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \
|
|
|
|
-Djavax.management.builder.initial=com.scylladb.jmx.utils.APIBuilder \
|
|
|
|
$PROPERTIES -jar $LOCATION/scylla-jmx-1.0.jar
|