GlassFish REST Interface
Monitoring GlassFish using REST Interface
GlassFish
v3, now exposes its monitoring and configuration in technology-agnostic
manner, enabling you to write scripts/clients using your own language
of
expertise to manage GlassFish. REST interface is implemented using
Jersey and is
available in
web
as well as in
glassFish
distributions. REST interface supports JSON, XML and HTML resource
representations.
In this blog, I would like to talk about Monitoring REST Interface
which
exposes GlassFish runtime model as REST urls. Monitoring resources are
read-only and supports only
GET
method as
of now. The url for monitoring
root resource is
http://{host}
:{port}
/monitoring/domain
, where {host} is the server host and {port} is the
administration port. Using root url, client can discover and traverse
the entire runtime model.
 |
Lets see how we can monitor GlassFish using REST
interface.
We can use one of the most widely used
and available software - browser, to monitor
GlassFish. Here we are addressing the monitoring root resource, Domain, on
my local GlassFish v3 install using its REST
url. Domain resource
has no attributes and has one child resource, server. |
Click
on the child resource link to discover
its
attributes and/or children. server resource
has four child resources.
By clicking through child urls we
can
discover the entire runtime data available. |

|
 |
Lets
get
any other resource that has attributes, say, ClassLoadingSystem
resource. This
resource has three attributes and no
children.
So
far we have seen accessing GlassFish monitoring resources
through
browser, accepting html resource representations. |
I
would like to demonstrate another client , a java client which
uses
Jersey client API's.
This is a simple java program that does a
GET on
the given resource requesting the given representation. You can
download the client with its source and the required libraries (to
compile & run the client) by clicking
here.
The
client zip file also has convenience script,
rget. The
inputs to the script are, url and the acceptable
representation of the resource.
rget script
simply accepts the input parameters and in turn, calls the java program
with the supplied input parameters.
Lets
GET
the
ClassLoadingSystem
resource again. This time we will use java client to request
JSON and
XML
representations.
rget
http://localhost:4848/monitoring/domain/server/jvm/class-loading-system "application/json"
| {ClassLoadingSystem:{"loadedclass-count"
: 8604,"unloadedclass-count" :
56,"totalloadedclass-count" : 8660},"child-resources":[]} |
rget
http://localhost:4848/monitoring/domain/server/jvm/class-loading-system "application/xml"
| <ClassLoadingSystem
loadedclass-count="8604" unloadedclass-count="56"
totalloadedclass-count="8660"></ClassLoadingSystem> |
Posted at
01:12AM Jul 10, 2009
by rajeshwar in Sun |
Posted by Arun Gupta's Blog on August 20, 2009 at 05:41 AM PDT #