Glassfish: Resource monitoring from command line

By | February 8, 2017

Glassfish Application server is a powerful application server that can support medium to big enterprise environments.

It is one of the easiest to configure and maintain application servers. No jumping through loops is required to adapt the code of your enterprise application to be deployable on it.

I am an adept of command line. Because sometimes a command line is all you get when you try to support a client system on the other side of the planet through an ipsec/openconnect/openvpn connection is better not to rely on GUIs.

The following steps are done on a Glashfish3 Application Server but the same can be applied on the new releases.

STEP1: Start the application server

cd /opt/glassfish3/bin
./asadmin start-domain --verbose domain1

Where “domain1” is the domain where the application is deployed. Make sure you know the administrative console port of the domain. By default 4848 is used but I choose to use 7002.

STEP 2: Enable application server monitoring

./asadmin enable-monitoring -p 7002 -u admin

– 7002 is the administrative console port
– admin is the administrator user name of the domain.

STEP 3: Add a new server monitor
You can activate the following monitors:
– jvm
– connector-service
– jdbc-connection-pool
– web-services-container
– ejb-container
– thread-pool
– http-service
– security
– jms-service
– jersey
– transaction-service
– jpa
– web-container

Add a server monitor by replacing $monitor with one of the above:

./asadmin set server.monitoring-service.module-monitoring-levels.$monitor=HIGH -p 7002 -u admin

Note 1: Do not add all the monitors, you will kill your application server. Some monitors are very resource intensive and will decrease the performance of your application environment,

Note 2: A restart of the application server is needed after a monitor is activated. The monitor will be available only after the restart.

STEP 4: List what server monitors are active

$ ./asadmin -p 7002 -u admin list -m server
Enter admin password for user "admin">

Command list executed successfully.

STEP 5: Get all the active monitor parameters for the server monitor

./asadmin -p 7002 -u admin get -m server.*

Note that a pattern match is used to obtain the values. The above line will dump several pages of parameters. You can always narrow down to what is of interest for you.

For example to get only the “thread-pool” values of the “http-listener-2” that is in our case the https listener.

$ ./asadmin -p 7002 -u admin get -m*
Enter admin password for user "admin"> = 5 = Core number of threads in the thread pool = 1474015329133 = CoreThreads = 1474015329106 = count = 0 = Provides the number of request processing threads currently in the listener thread pool = -1 = CurrentThreadCount = 1474015329106 = count = 0 = Provides the number of request processing threads currently in use in the listener thread pool serving requests = -1 = CurrentThreadsBusy = 1474015329106 = count = = 5 = Maximum number of threads allowed in the thread pool = 1474015329132 = MaxThreads = 1474015329106 = count = 0 = Provides the total number of tasks, which were executed by the thread pool = 1474015329107 = TotalExecutedTasksCount = 1474015329106 = count

Note in this case that each parameter has a description that makes it very easy to understand the meaning of it.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.