Adam Bien's Weblog

Monitoring GlassFish With Java8 And Nashorn

GlassFish emits JSON monitoring data over HTTP. Java 8 comes with JavaScript "Nashorn" engine with shell scripting support. JSON stands for "JavaScript Object Notation" and is easily accessible from JavaScript:


print("${numberOfRollbacks()} rollbacks");

function numberOfRollbacks() {
    var command = "curl http://localhost:4848/monitoring/domain/server/transaction-service/rolledbackcount.json";
    var result = $OUT;
    var elements = JSON.parse(result);
    return elements.extraProperties.entity.rolledbackcount.count;

Output is (hopefully): 0 rollbacks

The script above can be easily extended to monitor different aspects: from http, over JDBC connection pools, to even application specific performance metrics. See also: RESTful GlassFish Monitoring and Management and

See you at Java EE Workshops at MUC Airport!

NEW dates, new workshop: Java EE 7 Workshops: Bootstrap, Effective, Architectures, JavaScript Bootstrap and HTML 5 December, 7th-11th
NEW: Java EE 7 Testing-- Available For Streaming


A book about rethinking Java EE Patterns


If script is not working, make sure you have set monitoring-level to high in:
Btw, I really like you lightFish presentation. I need to check the program out. Is deployment over the app also possible?

Posted by FilterPunk on March 06, 2014 at 11:02 AM CET #

Does glassfish supports JSONP, to integrate monitoring on websites?

Posted by Nikolai Alex on March 07, 2014 at 12:29 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments