2 Replies Latest reply on Jun 20, 2016 9:35 AM by ctomc

    Monitoring used Java memory

    xarous

      I'm trying to monitor the Used Java memory in WildFly8 using JMX.

       

      Currently I have the following options -

      Using jboss-cli

      C:\wildfly-8.2.1.Final\bin\jboss-cli --connect command='/core-service=platform-mbean/type=memory/ :read-attribute(name=heap-memory-usage)'

      Using standalone twiddle

      "C:\Program Files (x86)\twiddle\bin\twiddle.bat" -s service:jmx:http-remoting-jmx://localhost:9990 get --noprefix jboss.as:core-service=platform-mbean,type=memory heap-memory-usage

       

      but they return a structure e.g.

      {

          "outcome" => "success",

          "result" => {

              "init" => 134217728L,

              "used" => 804574352L,

              "committed" => 918552576L,

              "max" => 1431830528L

          }

      }

       

      Is there a way to pull just the "used" number directly?

        • 1. Re: Monitoring used Java memory
          xarous

          I've got a workaround using powershell to pull the value from the structure.

           

          powershell.exe -command "$output = $(C:\Progra~2\twiddle\bin\twiddle.bat -s service:jmx:http-remoting-jmx://localhost:9990 get --noprefix jboss.as:core-service=platform-mbean`,type=memory heap-memory-usage | select-string 'used') ; $output -replace '.*used=' -replace '\}.*'"

          • 2. Re: Monitoring used Java memory
            ctomc

            why don't you collect memory info directly from jdk via jmx? It looks quite bit of roundtrip if you could access jdk's memory info directly.

            see more on that at:

            Monitoring and Management Using JMX Technology - Java SEMonitoring and Management Guide

             

            on cli topic you are mentioning, starting with version 9, you could use enhanced syntax for reading complex attributes like this.

            where command would then look like

             

            /core-service=platform-mbean/type=memory/:read-attribute(name=heap-memory-usage.used)