![]() |
Hi Guys,
I have been looking a bit on the agents: https://jolokia.org/reference/html/agents.html And I have used the shell script in the bottom of the page: #!/bin/sh url=`java -jar jolokia-jvm-1.3.6-agent.jar start $1 | tail -1` memory_url="${url}read/java.lang:type=Memory/HeapMemoryUsage" used=`wget -q -O - "${memory_url}/used" | sed 's/^.*"value":\([0-9]*\).*$/\1/'` max=`wget -q -O - "${memory_url}/max" | sed 's/^.*"value":\([0-9]*\).*$/\1/'` usage=$((${used}*100/${max})) echo "Memory Usage: $usage %" java -jar jolokia-jvm-1.3.6-agent.jar --quiet stop $1 Downloaded the jvm agent through: https://jolokia.org/download.html (http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.6/jolokia-jvm-1.3.6-agent.jar) When I run the script the first time: ./test.sh 43721 Memory Usage: 14 % When I run it 30 sec latter: Couldn't start agent for PID 43721 Possible reason could be that port '8778' is already occupied. And I can see that it is true. netstat -an | grep -i 8778 tcp 0 0 127.0.0.1:8778 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:35542 127.0.0.1:8778 TIME_WAIT tcp 0 0 127.0.0.1:35544 127.0.0.1:8778 TIME_WAIT lsof -nPi :8778 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 43721 jboss 499u IPv4 3865615 0t0 TCP 127.0.0.1:8778 (LISTEN) It is like the stop command do not terminate the port, and therefore it stays open. When I look at the pid from the `lsof` I can see that it is the PID I gave to the test script. If I run the stop command by hand again: java -jar jolokia-jvm-1.3.6-agent.jar --quiet stop 43721 It stops the agent just fine. If I run both commands by hand: [jboss@machine ~]$ java -jar jolokia-jvm-1.3.6-agent.jar start 43721 | tail -1 http://127.0.0.1:8778/jolokia/ [jboss@machine ~]$ java -jar jolokia-jvm-1.3.6-agent.jar --quiet stop 43721 [jboss@machine ~]$ netstat -an | grep -i 8778 tcp 0 0 127.0.0.1:35550 127.0.0.1:8778 TIME_WAIT tcp 0 0 127.0.0.1:35548 127.0.0.1:8778 TIME_WAIT [jboss@machine ~]$ lsof -nPi :8778 java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b31) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b31, mixed mode) My question is now: Is it a bug or am I doing something wrong? |
Free forum by Nabble | Edit this page |