users@glassfish.java.net

Re: Writing probes for Glassfish container events

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Thu, 16 Feb 2012 18:17:39 -0800

I created a simple webapp that listens to 2 of the 137 built-in
GlassFish probes. When either of the probes fire, the listener class in
the app is called with the parameters that the probe received. I simply
write the info out to the server.log but a real app could do anything it
likes. Including, e.g. sending an email when a limit is exceeded etc.

This sample app will give you an idea of the power of Monitoring in
GlassFish 3.x

Details -

 1. the source is available from subversion here:
    *https://svn.java.net/svn/glassfish~svn/trunk/v2/appserv-tests/devtests/admin/cli/apps/ConnectionProber*
 2. Run the app like so:
    http://localhost:8080/ConnectionProber
 3. On the page from (2) notice these 2 lines -- these are the 2 probes
    of interest:
      * glassfish:web:http-service:requestStartEvent (java.lang.String
        appName, java.lang.String hostName, java.lang.String serverName,
        int serverPort,
        java.lang.String contextPath, java.lang.String servletPath)
      * glassfish:jdbc:connection-pool:connectionAcquiredEvent
        (java.lang.String poolName, java.lang.String appName,
        java.lang.String moduleName
 4. Hit the page a few times to get some typical output like this in the
    server.log
    (ugly logging junk deleted)
    Web Start Event with these params:ConnectionProber, server,
    localhost, 8080, /ConnectionProber, /
    Connection Accepted! name=http-listener-1, connection: 27419954,
    address: /127.0.0.1:53313

Take a look at the sample code and you can see how easy it is to create
a listener and register it at run-time.





On 2/16/2012 3:13 PM, Byron Nevins wrote:
> See this blog that demonstrates how to make and use your own probes
> inside apps.
> *https://blogs.oracle.com/foo/entry/mort_learns_how_to_use
> *
> As a bonus -- it does what list-probes does!
>
>
> On 2/15/2012 6:21 PM, Comerford, Sean wrote:
>> We're finally about to turn the keys on V3 in production here at ESPN.
>>
>> Been doing a bit of reading on the probes that have been added to the
>> V3 monitoring framework.
>>
>> These look really promising.
>>
>> But I'm a little stuck on how to actually go about creating and
>> deploying one that listens for container events.
>>
>> For example, I want to create a probe to be notified of things like
>> when an http-listener's connection queue overflows or even when it
>> reaches a certain threshold (i.e. more than X requests are queued).
>>
>> Can anyone point me in the right direction?
>>
>> --
>> Sean Comerford
>> ESPN.com Site Architecture
>>>
>>