12.3 Invoking Scripts through the Experience Manager-Monitor Web Server (WebOps)

The Experience Manager-Monitor scripting layer allows certain scripted functions to be invoked through the monitor’s Web server through a feature called Web-Invocable Scripted Operations (WebOps). This feature allows custom functionality to be accessed by remote systems or custom Web pages hosted on the monitor’s Web server. In the default configuration, only diagnostic WebOps are enabled:

  • threadDump: Returns a dump of all threads in the Experience Manager-Monitor’s process space.

  • heapDump: Dumps the current Experience Manager-Monitor heap data to a file and returns the file path to the caller.

These and other sample WebOps are included in the WebOps.js file in the Monitor’s “scripts” directory. WebOps can be invoked by pointing a browser to /Plugins/invoke.pl?op=WebOps_name on the monitor’s Web server. For example, to assuming a monitor with the default configuration is running on the local system and the Web server is listening on port 8080, pointing a browser to http://localhost:8080/Plugins/invoke.pl?op=threadDump returns a thread dump for the running monitor.

Custom WebOps might be coded to perform virtually any action available to the monitor scripting layer. Web server requests to /Plugins/invoke.pl are routed to the WebOps framework. Upon receiving a request, the framework searches for a valid WebOps specified by the op parameter. If found, all of the parameters in the request are bound into a java.util.Map object and passed as an argument to the operation. Anything returned by the operation is automatically returned to the caller as an HTML string. Refer to the included WebOps.js file for examples.

Two settings in monitor.properties are used to manage WebOps functionality:

  • Monitor.webserver.ops.script: Specifies the name of the script file containing any defined WebOps. Only JavaScript functions that are first loaded with this file are eligible to be invoked through the WebOps framework. If this property is left blank, WebOps functionality is disabled.

  • Monitor.webserver.ops.functions: Specifies the names of Javascript functions that can be invoked as WebOps. If this property is left blank, any function loaded in the specified WebOps script can be invoked.