From 3f7d02f725015b48dedab0db05327eaedc66c3e4 Mon Sep 17 00:00:00 2001 From: robsunday Date: Fri, 18 Oct 2024 11:37:13 +0200 Subject: [PATCH] Cleanup unnecessary env variables. Removed env file and use JAVA_TOOL_OPTIONS instead to pass JMX options to ActiveMQ --- .../ActiveMqIntegrationTest.java | 8 +- .../target_systems/TomcatIntegrationTest.java | 1 - jmx-scraper/src/main/resources/activemq/env | 119 ------------------ 3 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 jmx-scraper/src/main/resources/activemq/env diff --git a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/ActiveMqIntegrationTest.java b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/ActiveMqIntegrationTest.java index 2648ddc60..036996f5e 100644 --- a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/ActiveMqIntegrationTest.java +++ b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/ActiveMqIntegrationTest.java @@ -14,7 +14,6 @@ import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.images.builder.ImageFromDockerfile; -import org.testcontainers.utility.MountableFile; public class ActiveMqIntegrationTest extends TargetSystemIntegrationTest { @@ -24,13 +23,8 @@ protected GenericContainer createTargetContainer(int jmxPort) { new ImageFromDockerfile() .withDockerfileFromBuilder( builder -> builder.from("apache/activemq-classic:5.18.6").build())) - .withEnv("LOCAL_JMX", "no") - .withCopyFileToContainer( - // Overwrite default ActiveMQ configuration in order to let ActiveMQ use JMX options - // stored in $ACTIVEMQ_JMX_OPTS env variable defined below - MountableFile.forClasspathResource("activemq/env"), "/opt/apache-activemq/bin/env") .withEnv( - "ACTIVEMQ_JMX_OPTS", + "JAVA_TOOL_OPTIONS", "-Dcom.sun.management.jmxremote.port=" + jmxPort + " -Dcom.sun.management.jmxremote.rmi.port=" diff --git a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TomcatIntegrationTest.java b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TomcatIntegrationTest.java index 500e89f82..76bacf265 100644 --- a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TomcatIntegrationTest.java +++ b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TomcatIntegrationTest.java @@ -30,7 +30,6 @@ protected GenericContainer createTargetContainer(int jmxPort) { "https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/sample.war", "/usr/local/tomcat/webapps/ROOT.war") .build())) - .withEnv("LOCAL_JMX", "no") .withEnv( "CATALINA_OPTS", "-Dcom.sun.management.jmxremote.local.only=false" diff --git a/jmx-scraper/src/main/resources/activemq/env b/jmx-scraper/src/main/resources/activemq/env deleted file mode 100644 index 23d70bf4f..000000000 --- a/jmx-scraper/src/main/resources/activemq/env +++ /dev/null @@ -1,119 +0,0 @@ - #!/bin/sh - # ------------------------------------------------------------------------ - # Licensed to the Apache Software Foundation (ASF) under one or more - # contributor license agreements. See the NOTICE file distributed with - # this work for additional information regarding copyright ownership. - # The ASF licenses this file to You under the Apache License, Version 2.0 - # (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------ - # - # Configuration file for running Apache Active MQ as standalone provider. - # - # This file overwrites the predefined settings of the sysv init-script. - # You can also use alternate location for default settings - - # invoke the init-script without a argument an review help section "Configuration of this script" - # /etc/default/activemq /.activemqrc /bin/env - - # Active MQ installation dirs - # ACTIVEMQ_HOME="/" - # ACTIVEMQ_BASE="$ACTIVEMQ_HOME" - # ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf" - # ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data" - # ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp" - - # Set jvm memory configuration (minimal/maximum amount of memory) - ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx256M" - - if [ -z "$ACTIVEMQ_OPTS" ] ; then - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" - fi - - if [ -z "$ACTIVEMQ_OUT" ]; then - ACTIVEMQ_OUT="/dev/null" - fi - - # Uncomment to enable audit logging - #ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.audit=true" - - # Set jvm jmx configuration - # This enables jmx access over a configured jmx-tcp-port. - # You have to configure the first four settings if you run a ibm jvm, caused by the - # fact that IBM's jvm does not support VirtualMachine.attach(PID). - # JMX access is needed for quering a running activemq instance to gain data or to - # trigger management operations. - # - # Example for ${ACTIVEMQ_CONF}/jmx.access: - # --- - # # The "monitorRole" role has readonly access. - # # The "controlRole" role has readwrite access. - # monitorRole readonly - # controlRole readwrite - # --- - # - # Example for ${ACTIVEMQ_CONF}/jmx.password: - # --- - # # The "monitorRole" role has password "abc123". - # # # The "controlRole" role has password "abcd1234". - # monitorRole abc123 - # controlRole abcd1234 - # --- - # - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.port=11099 " - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" - ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" - - # Set jvm jmx configuration for controlling the broker process - # You only have to configure the first four settings if you run a ibm jvm, caused by the - # fact that IBM's jvm does not support VirtualMachine.attach(PID) - # (see also com.sun.management.jmxremote.port, .jmx.password.file and .jmx.access.file ) - #ACTIVEMQ_SUNJMX_CONTROL="--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/jmxrmi --jmxuser controlRole --jmxpassword abcd1234" - ACTIVEMQ_SUNJMX_CONTROL="" - - # Specify the queue manager URL for using "browse" option of sysv initscript - if [ -z "$ACTIVEMQ_QUEUEMANAGERURL" ]; then - ACTIVEMQ_QUEUEMANAGERURL="--amqurl tcp://localhost:61616" - fi - - # Set additional JSE arguments - if [ -z "$ACTIVEMQ_SSL_OPTS" ] ; then - #ACTIVEMQ_SSL_OPTS="-Djava.security.properties=$ACTIVEMQ_CONF/java.security" - ACTIVEMQ_SSL_OPTS="" - fi - - # Uncomment to enable remote debugging - #ACTIVEMQ_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" - - # ActiveMQ tries to shutdown the broker by jmx, - # after a specified number of seconds send SIGKILL - if [ -z "$ACTIVEMQ_KILL_MAXSECONDS" ]; then - ACTIVEMQ_KILL_MAXSECONDS=30 - fi - - # Configure a user with non root privileges, if no user is specified do not change user - # (the entire activemq installation should be owned by this user) - ACTIVEMQ_USER="" - - # location of the pidfile - # ACTIVEMQ_PIDFILE="$ACTIVEMQ_DATA/activemq.pid" - - # Location of the java installation - # Specify the location of your java installation using JAVA_HOME, or specify the - # path to the "java" binary using JAVACMD - # (set JAVACMD to "auto" for automatic detection) - #JAVA_HOME="" - JAVACMD="auto" - - # Use JMX options defined in environment variable - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_JMX_OPTS"