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

where:
– 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">
server.http-service
server.http-service.server
server.http-service.server.request
server.http-service.__asadmin
server.http-service.__asadmin.request
server.network
server.network.file-cache
server.network.keep-alive
server.network.http-listener-2
server.network.http-listener-2.file-cache
server.network.http-listener-2.keep-alive
server.network.http-listener-2.thread-pool
server.network.http-listener-2.connection-queue
server.network.http-listener-1
server.network.http-listener-1.file-cache
server.network.http-listener-1.keep-alive
server.network.http-listener-1.thread-pool
server.network.http-listener-1.connection-queue
server.network.admin-listener
server.network.admin-listener.file-cache
server.network.admin-listener.keep-alive
server.network.admin-listener.thread-pool
server.network.admin-listener.connection-queue
server.network.thread-pool
server.network.connection-queue

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 server.network.http-listener-2.thread-pool.*
Enter admin password for user "admin">
server.network.http-listener-2.thread-pool.corethreads-count = 5
server.network.http-listener-2.thread-pool.corethreads-description = Core number of threads in the thread pool
server.network.http-listener-2.thread-pool.corethreads-lastsampletime = 1474015329133
server.network.http-listener-2.thread-pool.corethreads-name = CoreThreads
server.network.http-listener-2.thread-pool.corethreads-starttime = 1474015329106
server.network.http-listener-2.thread-pool.corethreads-unit = count
server.network.http-listener-2.thread-pool.currentthreadcount-count = 0
server.network.http-listener-2.thread-pool.currentthreadcount-description = Provides the number of request processing threads currently in the listener thread pool
server.network.http-listener-2.thread-pool.currentthreadcount-lastsampletime = -1
server.network.http-listener-2.thread-pool.currentthreadcount-name = CurrentThreadCount
server.network.http-listener-2.thread-pool.currentthreadcount-starttime = 1474015329106
server.network.http-listener-2.thread-pool.currentthreadcount-unit = count
server.network.http-listener-2.thread-pool.currentthreadsbusy-count = 0
server.network.http-listener-2.thread-pool.currentthreadsbusy-description = Provides the number of request processing threads currently in use in the listener thread pool serving requests
server.network.http-listener-2.thread-pool.currentthreadsbusy-lastsampletime = -1
server.network.http-listener-2.thread-pool.currentthreadsbusy-name = CurrentThreadsBusy
server.network.http-listener-2.thread-pool.currentthreadsbusy-starttime = 1474015329106
server.network.http-listener-2.thread-pool.currentthreadsbusy-unit = count
server.network.http-listener-2.thread-pool.dotted-name = server.network.http-listener-2.thread-pool
server.network.http-listener-2.thread-pool.maxthreads-count = 5
server.network.http-listener-2.thread-pool.maxthreads-description = Maximum number of threads allowed in the thread pool
server.network.http-listener-2.thread-pool.maxthreads-lastsampletime = 1474015329132
server.network.http-listener-2.thread-pool.maxthreads-name = MaxThreads
server.network.http-listener-2.thread-pool.maxthreads-starttime = 1474015329106
server.network.http-listener-2.thread-pool.maxthreads-unit = count
server.network.http-listener-2.thread-pool.totalexecutedtasks-count = 0
server.network.http-listener-2.thread-pool.totalexecutedtasks-description = Provides the total number of tasks, which were executed by the thread pool
server.network.http-listener-2.thread-pool.totalexecutedtasks-lastsampletime = 1474015329107
server.network.http-listener-2.thread-pool.totalexecutedtasks-name = TotalExecutedTasksCount
server.network.http-listener-2.thread-pool.totalexecutedtasks-starttime = 1474015329106
server.network.http-listener-2.thread-pool.totalexecutedtasks-unit = count

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

[paypal_donation_button]

Leave a Reply

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