JConsole for remote JMX access against JBoss AS7 standalone mode - java

I am trying to access Jconsole for monitoring JBoss of a remote machine in the same intranet, but I am getting:
Connection failed! The connection to user#service:jmx:remoting-jmx://192.168.124.x:9999 did not succeed.
OS: Ubuntu,
Command: ./jconsole -J-Djava.class.path=/home/stpl/software/jdk1.7.0_51/lib/jconsole.jar:/home/stpl/software/jdk1.7.0_51/lib/jconsole.jar/tools.jar:/home/stpl/software/jboss-as-7.1.1:/home/stpl/software/jdk1.7.0_51/lib/tools.jar
In the machine which I want to access I have done following changes:
standalone.xml: All inet address from 127.0.0.1 to 0.0.0.0 and
remoting-connector use-management-endpoint="false".
In standalone.conf added following:
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=standalone.xml"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9999"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver"
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=192.168.124.31"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:../modules/org/jboss/logmanager/main/jboss-logmanager-1.2.2.GA.jar -Xbootclasspath/p:../modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar -Xbootclasspath/p:../modules/org/apache/log4j/main/log4j-1.2.16.jar"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.logmanager"
I can access admin console from the remote machine and can telnet successfully for port 9999.
Kindly tell the clear steps for the same as I googled a lot but couldn't succeed to find solution .
Any help will be highly appreciated!

This worked for after following changes:
In standalone.xml, added remoting-connector use-management-endpoint="true"
like:-
<subsystem xmlns="urn:jboss:domain:jmx:1.1">
<show-model value="true"/>
<remoting-connector use-management-endpoint="true"/>
</subsystem>
Instead of running from JDK run this command from JBoss bin:
$JBOSS_HOME/bin/jconsole.sh
No configuration changes required in standalone.conf
In jconsole.sh set path for the JAVA_HOME and JBOSS_HOME and following jar classpath:
CLASSPATH=$JAVA_HOME/lib/jconsole.jar
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
CLASSPATH=$CLASSPATH:/home/stpl/software/jboss-as-7.1.1.Final/bin/client/jboss-client.jar

Related

Integration of JMX in Wildfly

I have been meaning to monitor my wildfly in zabbix through JMX. The versions are listed below
wildfly: 20.0.0.1 final
zabbix: 5.0.7
java(that is present in wildfly host): openjdk version "11.0.8" 2020-07-14
The issue i am facing while i run wildlfy is as follows.
-Xbootclasspath is no longer a supported option. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit
My standalone.conf file looks like as below:
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.bytemani,org.joss.logmanager"
fi
# Uncomment the following line to prevent manipulation of JVM options
# by shell scripts.
#
#PRESERVE_JAVA_OPTS=true
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms2G -Xmx2G -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=1G -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath:/opt/wildfly/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.15.Final.jar"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
As per my research, i have found that my java version is not compatible and i dont know the work around process.

Wildfly 17 enabling JMX remote on the same server gives logmanager errors

I’m looking to enable JMX to allow datadog to monitor our java JBoss wildfly systems but keep hitting runtime errors
I have set up the standalone.xml with
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector use-management-endpoint="true"/>
</subsystem>
And
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
As well as
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
Then in my startup.sh i have added
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
But this gives me
java.lang.IllegalStateException: The LogManager was not properly
installed (you must set the "java.util.logging.manager" system
property to "org.jboss.logmanage r.LogManager")
This seems to be fairly common if I look at both here and on google but there seem to be different solutions depending on the version of wildfly.
I think I need to do something like
Set at the start of the standalone.conf
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager"
And then
JBOSS_HOME="/opt/wildfly"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.11.Final.jar -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/log4j/logmanager/main/log4j-jboss-logmanager-1.2.0.Final.jar"
At the end.
But I still get errors “Could not load Logmanager "org.jboss.logmanager.LogManager"”
Any advice would be appreciated.
I encountered the same issue when I upgrade Wildfly server version from 10.1 to 24.0.0 and I resolved it using the below changes.
The below JAVA_OPTS changes are required to be added at the end of the standalone.conf file
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/a:$JBOSS_HOME/modules/system/layers/base/org/wildfly/common/main/wildfly-common-1.5.4.Final.jar -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager -Xbootclasspath/a:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.18.Final.jar -Xbootclasspath/a:$JBOSS_HOME/modules/system/layers/base/org/jboss/log4j/logmanager/main/log4j-jboss-logmanager-1.2.0.Final.jar"
# Enable jmx remote management
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=4447 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dsun.util.logging.disableCallerCheck=true -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.local.only=false"
NOTE: wildfly-common-.jar, jboss-logmanager-.jar, log4j-jboss-logmanager-.jar dependencies should be added to classpath using -Xbootclasspath/a
Use the supplied jconsole.sh script in bin, don't try and build up the classpath by hand. You also need to use the custom service url. See the docs for details
change in standalone.sh: #!/bin/sh to #!/bin/bash
then
in standalone.conf :
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager,jdk.nashorn.api,com.sun.crypto.provider,$JBOSS_MODULES_SYSTEM_PKGS"
...
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
...
BOOT_CP=()
BOOT_CP=("$(find $JBOSS_HOME/modules -type f -name "jboss-logmanager-*.jar")")
BOOT_CP+=("$(find $JBOSS_HOME/modules -type f -name "wildfly-common*.jar")")
for f in $(find $JBOSS_HOME/modules -type f -name "javax.json-*.jar"); do
BOOT_CP+=("$f")
done
x="-Xbootclasspath/a"
for p in "${BOOT_CP[#]}"; do
x+=":$p"
done
JAVA_OPTS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dsun.util.logging.disableCallerCheck=true $x $JAVA_OPTS"
it is work but I have still some issues...

Using VisualVM on tomcat 8 running on EC2

I am trying to use VisualVM in my system to monitor a Tomcat instance running over EC2. I tried steps provided in multiple blogs about how to configure it, but still when I try to run tomcat it gives me following error.
./catalina.sh: 5: /home/gvr/apache-tomcat-8.0.18/bin/setenv.sh: -Dcom.sun.management.jmxremote: not found
I added following statement in server.xml
<listener classname="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
rmiregistryportplatform="10001"
rmiserverportplatform="10002"
uselocalports="true" />
And my setenv.sh is as follows
CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=ec2-xx-xxx-xx-xx.ap-southeast-1.compute.amazonaws.com"
$CATALINA_OPTS
Besides this I have added, catalina-jmx-remote.jar in tomcat's lib directory
Could anyone please provide me some hint, what is possibly going wrong. I tried everything I have found related to configuring VisualVM
I am running Tomcat 8.0.18, java 8 over ubuntu
I believe there are two issues
formatting in setenv.sh, you need \ to split across lines
last line $CATALINA_OPTS which tries to execute the arguments, hence -Dcom.sun.management.jmxremote not found...
Suggested fix
CATALINA_OPTS="-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=ec2-xx-xxx-xx-xx.ap-southeast-1.compute.amazonaws.com"
echo $CATALINA_OPTS
I also tried using the JmxRemoteLifecycleListener and it didn't work for me.
Here it is how I did it:
1)I choose 1005 as jmx port and my setenve.sh is like:
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10005 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost"
2) redirect using ssh the jmx port and the rmi
3) Run visualvm using the following uri: service:jmx:rmi:///jndi/rmi://localhost:10005/jmxrmi
If you need more information have a look to this post:
http://ignaciosuay.com/how-to-connect-a-java-profiler-like-visualvm-or-jconsole-to-a-remote-tomcat-running-on-amazon-ec2/

How to enable the JMX of cluster servers on Weblogic?(not the Weblogic AdminServer itself)

I am running Weblogic 12c on CentOS6. I have enabled the JMX on Weblogic AdminServer.
But I want to enable the JMX on the cluster servers such as ms1 listed below to monitor specific Java service. What shall I do? Thank you!
Servers:AdminServer(admin)
Clusters: ms1/ms2/ms3
[root#weblogic61 bin]# ps -ef |grep java
weblogic 3618 3571 0 Jun04 ? 03:14:41 /home/jdk/jdk1.7.0_45/bin/java -server -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -Dweblogic.Name=ms1 -Djava.security.policy=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Dweblogic.security.SSL.trustedCAKeyStore=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/cacerts -Djava.endorsed.dirs=/home/jdk/jdk1.7.0_45/jre/lib/endorsed:/home/weblogic/Oracle/Middleware/wlserver_12.1/endorsed -da -Dplatform.home=/home/weblogic/Oracle/Middleware/wlserver_12.1 -Dwls.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.management.discover=false -Dweblogic.management.server=http://192.168.97.61:7001 -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/home/weblogic/Oracle/Middleware/patch_wls1211/profiles/default/sysext_manifest_classpath:/home/weblogic/Oracle/Middleware/patch_ocp371/profiles/default/sysext_manifest_classpath weblogic.Server
root 27588 27541 41 09:56 pts/0 00:00:25 /home/jdk/jdk1.7.0_45/bin/java -server -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -Dweblogic.Name=AdminServer -Djava.security.policy=/home/weblogic/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Djava.endorsed.dirs=/home/jdk/jdk1.7.0_45/jre/lib/endorsed:/home/weblogic/Oracle/Middleware/wlserver_12.1/endorsed -Djava.rmi.server.hostname=192.168.97.61 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -da -Dplatform.home=/home/weblogic/Oracle/Middleware/wlserver_12.1 -Dwls.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.home=/home/weblogic/Oracle/Middleware/wlserver_12.1/server -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/home/weblogic/Oracle/Middleware/patch_wls1211/profiles/default/sysext_manifest_classpath:/home/weblogic/Oracle/Middleware/patch_ocp371/profiles/default/sysext_manifest_classpath weblogic.Server
root 27638 27312 0 09:57 pts/1 00:00:00 grep java
zabbix 27853 1 0 Jun13 ? 00:14:16 java -server -classpath lib:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/org-json-2010-12-28.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-2.0.12.jar -Dzabbix.pidFile=/var/run/zabbix/zabbix_java.pid -Dzabbix.listenIP=0.0.0.0 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 com.zabbix.gateway.JavaGateway
The first question is where are those settings coming from for your admin server. My guess is you need to edit startWebLogic.sh and find where the following are being set:
JAVA_OPTIONS="-Dcom.sun.management.jmxremote.port=12345"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTIONS="${JAVA_OPTIONS} -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
export JAVA_OPTIONS
Thos settings are probably being explicitly set for your admin server only based on an if statement or some such.
You can also set those -D values for your managed server by going to:
Admin Console -> Servers -> MS -> Server Start -> JVM Arguments
Last, in the Weblogic Domain->Configuration->General->Advanced
Enable both - Platform MBean Server Enabled and Platform MBean Server Used
Admin Console -> Servers -> Server-1 -> Server Start -> JVM Arguments
-DUseSunHttpHandler=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8501 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.20.209
Admin Console -> Servers -> Server-2 -> Server Start -> JVM Arguments
-DUseSunHttpHandler=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8502 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.20.209
along with below command line parameters ,
-Dcom.sun.management.jmxremote.port='you jmx port'
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder
Sometimes in the linux servers , imx connection doesn't get succeeded. that is because , in cloud linux host, in /etc/hosts so that the hostname resolves to the host address.
the best way to fix it is, ping the particular linux server from other machine in network and use that host IP address in the
-Djava.rmi.server.hostname=IP address that obtained when you ping that linux server.
But never rely on the ipaddress that you get from linux server using ifconfig.me. the ip that you get there is masked one which is present in the host file.

Java VisualVM not able to connect to Jboss

Java VisualVM not able to connect Jboss server, when jboss server running with option -b 0.0.0.0.
jboss run script - run.sh -c web -b 0.0.0.0
When i try to run jboss with this like - run.sh -c web -b {MyIp}
then Java VisualVM is able to connect jboss server.
Can any one help me how to connect while jboss running with first option ( -b 0.0.0.0)
I am using this configuration in run.conf file in jboss
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8077 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
Add this to JAVA_OPTS
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8077 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=0.0.0.0"
instead of 0.0.0.0 use your system IP.

Categories