3 Replies Latest reply on Jul 11, 2016 8:21 AM by wdfink

    jboss 7.1.1 - Write DB connection pool usage, active sessions count, JVM memory usage to a log file

    syau

      JBoss - jboss-as-7.1.1.Final

      Java - 1.6

       

      My production JBoss sometimes loses database connection, I'm thinking of increasing

        Datasource connection pool

        and also JVM heap size

       

      Before doing that, I would like to write to a log file

        pool usage

        memory usage

        active users count

      so that I can use it for debug purposes.

       

      JConsole

      ----------------

      I could see active sessions count under

        'MBeans' tab - 'jboss.web' 'Manager' 'mywebapp' 'default-host' 'Attributes' 'activeSessions'

        I believe this session count is the count of users logged in (my program creates session once user logged in)

       

      But I couldn't see anywhere in JConsole the number of db pool connections in use, I checked under

        'MBeans' tab - 'jboss.as' 'datasources' 'mywebappDS' 'Attributes'

        nothing available here.

        Where can I find this in JConsole?

        At the same time, in JBoss management console, I could see under 'Pool Usage' tab, 'Active Count' and 'Max Used' - Is this

        the correct representation of pool usage?

       

      Anyway, my main requirement is to write to a log necessary stats. Can someone please let me know how I can log,

        db connection pool usage

        memory usage

        Users count

        • 1. Re: jboss 7.1.1 - Write DB connection pool usage, active sessions count, JVM memory usage to a log file
          wdfink

            At the same time, in JBoss management console, I could see under 'Pool Usage' tab, 'Active Count' and 'Max Used' - Is this

            the correct representation of pool usage?

          Yes, Max Used is the peak number of connections used concurrent.

          AFAIR you need to enable the jca pool connection logging to see whether connections are handed out or returned to pool, not sure whether it shows the current usage.

          But you can invoke CLI to show the pool usage periodical.

           

          For memory usage I would use the GC logfile, enable it by set the options to standalone.conf  (i.e. -verbose:gc) you need to check the parameters for your JVM

          • 2. Re: jboss 7.1.1 - Write DB connection pool usage, active sessions count, JVM memory usage to a log file
            syau

            I managed to write gc details into a log file. I added that in the services.bat. Can you please let me know, how I could get that 'Max Used' / 'Active Count' and 'activeSessions' values into a file? Do I have to write a standalone script or Java program to do that? Or Is it possible to include it in the services.bat, just like gc log? If you could provide some samples that will be useful. Thanks.

            • 3. Re: jboss 7.1.1 - Write DB connection pool usage, active sessions count, JVM memory usage to a log file
              wdfink

              you can use the bin/jboss-cli.sh script and call it from a shell script or cron job periodically.

              The command is

                  bin/jboss-cli.sh -c "/subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime="true", recursive=true)"

              also you are able to read a specific attribute using ":read-attribute(name=ActiveCount)"

               

              You can redirect this to a file like each Unix command