Multiple Methods for Monitoring and Managing GlassFish 3
GlassFish 3 supports multiple methods of monitoring and management. In this post, I look briefly at the approaches GlassFish provides for administration, monitoring, and management.
GlassFish Admin Console
GlassFish’s web-based Admin Console GUI is probably the best-known interface for GlassFish administration. By default, it is accessed via the URL http://localhost:4848/
once GlassFish is running. The two screen snapshots below provide a taste of this approach, but I don’t look any deeper at this option here as this is a fairly easy to understand interface that is fairly easy to learn and use once logged into the website.
GlassFish Admin Command Line Interface
The GlassFish Admin Console GUI offers advantages of a GUI such as ease of learning and using, but also comes with the drawbacks of a GUI (can take longer to get through the ‘overhead’ of using the GUI approach for things that are easily done from the command line and does not work as well in scripts and headless environments). In some cases, a command-line approach is preferred and GlassFish supports command-line administration with the GlassFish Admin Command Line Interface.
Running asadmin start-domain
is used to start a Domain in GlassFish. The command asadmin help
can be used to learn more about the available commands. A very small snippet from the top of this help output is shown next:
Utility Commands asadmin(1m) NAME asadmin - utility for performing administrative tasks for Oracle GlassFish Server SYNOPSIS asadmin [--host host] [--port port] [--user admin-user] [--passwordfile filename] [--terse={true|false}] [--secure={false|true}] [--echo={true|false}] [--interactive={true|false}] [--help] [subcommand [options] [operands]] DESCRIPTION Use the asadmin utility to perform administrative tasks for Oracle GlassFish Server. You can use this utility instead of the Administration Console interface.
As the beginning of the asadmin help
indicates, the asadmin
utility is an alternative to the GUI-based ‘Administration Console interface.’
There are numerous sub-commands available and some of those are listed here:
- list-applications to list deployed applications
deploy
and other deployment subcommandsversion
to see version of GlassFish (shown in the screen snapshot below)- list-commands (lists available commands) [portion of output shown in the screen snapshot below]
Additional information regarding the GlassFish Admin Command Line Interface is available in Learning GlassFish v3 Command Line Administration Interface (CLI).
GlassFish JMX/AMX
The two approaches shown in this post so far for monitoring and managing GlassFish (web-based Admin Console GUI and GlassFish Admin Command Line Interface) are specific to GlassFish. GlassFish also supports monitoring and management via Java Management Extensions (JMX), including JSR 77 (‘J2EE Management‘) as I have blogged about before in my post Simple Remote JMX with GlassFish.
Because GlassFish supports a JMX interface, it can be easily monitored and managed with readily available tools such as JConsole and JVisualVM. Besides the MBeans that GlassFish exposes itself, the JVM has built-in MBeans since J2SE 5 that can be monitored in relation to the hosted GlassFish instances as well.
The next set of images demonstrates using JConsole to view MBeans exposed via GlassFish and the JVM. The first image shows the standard JVM Platform MBeans available and the images following that one show GlassFish-specific MBeans including the amx-support
and jmxremote
domains. When the bootAMX
operation of the boot-amx
MBean (amx-support
domain) is clicked on that latter MBean, the full complement of AMX MBeans is available as shown in the remainder of the images.
GlassFish REST
The Oracle GlassFish Server 3.1 Administration Guide includes a section called ‘Using REST Interfaces to Administer GlassFish Server‘ that states that the ‘GlassFish Server provides representational state transfer (REST) interfaces to enable you to access monitoring and configuration data for GlassFish Server.’ It goes on to suggest that clients applications such as web browsers, cURL, and GNU Wget can be used to interact with GlassFish via the Jersey-based REST interfaces. Of course, as this page also points out, any tool written in any language that handles REST-based interfaces can be used in conjunction with GlassFish’s REST support.
Not surprisingly, the GlassFish REST APIs are exposed via URLs over HTTP. The previously cited Admin Guide states that configuration/management operations are accessed via URLs of form http://host:port/management/domain/path
and monitoring operations are accessed via URLs of form http://host:port/monitoring/domain/path
.
One of the easiest ways to use GlassFish’s REST interfaces is via web browser using the URLs mentioned earlier (http://localhost:4848/management/domain/ and http://localhost:4848/monitoring/domain/ for example). The next three screen snapshots attempt to give a taste of this style of access. The middle image shows that the monitoring needs to be enabled in GlassFish.
Using a web browser to interact with GlassFish for management and monitoring is easy, but this can be done with the Web Admin Console I covered at the beginning of this blog post. The real advantage of the REST-based interface is the ability to call it from other client tools, especially custom-built tools and scripts. For example, one can write scripts in Groovy, Python, Ruby, and other scripting languages to interact with GlassFish. Like GlassFish’s JMX-exposed APIs, GlassFish’s REST-exposed APIs allow custom scripts and tools to be used or even written to manage and monitor GlassFish. Jason Lee has posted several posts on using GlassFish’s REST management/monitoring APIs such as RESTful GlassFish Monitoring, Deploying Applications to GlassFish Using curl, and GlassFish Administration: The REST of the Story.
Ant Tasks
GlassFish provides several Ant tasks that allow Ant to be used for starting and stopping the GlassFish server, for deploying applications, and for performing other management tasks. A StackOverflow Thread covers this approach. The next two screen snapshots demonstrate using the GlassFish Web Admin Console’s Update Tool -> Available Add-Ons feature to select the Ant Tasks for installation and the contents of the ant-tasks.jar
that is made available upon this selection.
With the ant-tasks.jar
JAR available, it can be placed on the Ant build’s classpath to script certain GlassFish actions via an Ant build.
Conclusion
The ability to manage and monitor an application server is one of its highly important features. This post has looked at several of the most common methods GlassFish supports for its management, monitoring, and general administration.
Reference: Multiple Methods for Monitoring and Managing GlassFish 3 from our JCG partner Dustin Marx at the Inspired by Actual Events blog.