Application Server: Custom REST Pages

From Resin 4.0 Wiki

Revision as of 00:00, 21 March 2013 by Cowan (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Custom REST Pages

Resin actually provides 2 REST interfaces; a newer REST service which enables administration that mirrors Resin's command-line interface, and older customizable REST pages as part of the resin-admin web application.

The newer REST interface is documented thoroughly in the documentation and [[Application_Server:_REST_Graphing|usage examples] are on the Wiki also.


rest.php, located at doc/admin/rest.php is a component of resin-admin that allows you to easy extend and customize resin-admin. Resin admin actually uses it to enable part of the graphing capability.

rest.php requires one parameter "q", which is the name of a rest page to display. rest pages are located in resin-admin's WEB-INF/php/ directory and named with the extension ".rest".

resin-admin includes packaged 2 .rest pages which you can use, or you can add your own to this directory.

This .rest page produces output similar to Apache's mod_status.

This .rest page produces an interactive graph drawn using javascript. It's intended to be embeddable in your own pages or can just be used as an example of how to write .rest pages.

With no parameters, will not graph data. The parameters are as follows:

  • checks: (required) a Resin meter name to graph. Can be passed more than once to graph multiple statistics
  • servers: Resin server cluster index, typically 00 though xx (defaults to the local server)
  • width: graph width (defaults to 640)
  • height: graph height (defaults t 480)
  • canvas: name of html 5 canvas DIV on to draw on (defaults to generated named)
  • period: graph domain, in seconds since the current time (defaults to 60)

For example, this URL will produce a graph of the number of JVM threads over the last hour for the current server:|Thread|JVM%20Thread%20Count&period=3600

The "checks" parameter accepts the name of a Resin "meters". Resin tracks many metrics while running, and stores these in an internal database. They are named hierarchy with keys from least to most specific, separated with a "|" (pipe) character. So in the example above the metric key was "JVM|Thread|JVM Thread Count". There is also a "Resin|Thread|Thread Count". Refer to the Meters page in resin-admin for a more comprehensive list.

Custom .rest Pages

Personal tools