Using curl to access JMX port

Viewed 987

I have a jar that I got from one of my teams and I'm trying to connect to the JMX of the app and collect some metrics.

I configured JAVA_OPTS to be the following :

export JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.rmi.port=8099 -Dcom.sun.management.jmxremote.port=8098 -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=127.0.0.1 "

The Java app started successfully with the the new settings. I checked if the app listens on 9098/ and I saw it is :

[root@machine]# netstat -noap | grep -e "8098\|8099"
tcp6       0      0 :::8098                 :::*                    LISTEN      16365/java           off (0.00/0/0)
tcp6       0      0 :::8099                 :::*                    LISTEN      16365/java           off (0.00/0/0)

I tried to run the following curl commands but nothing is returned :

[root]# curl -i 127.0.0.1:9098/jolokia/read/java.lang:type=Memory/HeapMemoryUsage
curl: (52) Empty reply from server
[root]# curl -i 127.0.0.1:9097/jolokia/read/java.lang:type=Memory/HeapMemoryUsage

curl: (56) Recv failure: Connection reset by peer

Is it possible to reach out to the jmx port with an api call ?

0 Answers
Related