http://wiki4.caucho.com/index.php?title=Application_Server:_Custom_REST_Pages&feed=atom&action=historyApplication Server: Custom REST Pages - Revision history2024-03-28T09:32:10ZRevision history for this page on the wikiMediaWiki 1.18.0http://wiki4.caucho.com/index.php?title=Application_Server:_Custom_REST_Pages&diff=1077&oldid=prevCowan at 00:00, 21 March 20132013-03-21T00:00:00Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:00, 21 March 2013</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 29:</td>
<td colspan="2" class="diff-lineno">Line 29:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>With no parameters, graph.rest will produce no graph.  The parameters are as follows:</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>With no parameters, graph.rest will produce no graph.  The parameters are as follows:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* checks: a Resin meter name to graph<del class="diffchange diffchange-inline">, include more than once to graph multiple statistics </del>(required)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* checks: a <ins class="diffchange diffchange-inline">comma separated list of </ins>Resin meter name to graph (required)</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* servers: Resin server cluster <del class="diffchange diffchange-inline">index</del>, typically 00 though xx<del class="diffchange diffchange-inline">, include more than once to graph multiple statistics </del>(defaults to the local server)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* servers: <ins class="diffchange diffchange-inline">a comma separated list of </ins>Resin server cluster <ins class="diffchange diffchange-inline">indexes</ins>, typically 00 though xx (defaults to the local server)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* width: graph width (defaults to 640)</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* width: graph width (defaults to 640)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* height: graph height (defaults t 480)</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* height: graph height (defaults t 480)</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 39:</td>
<td colspan="2" class="diff-lineno">Line 39:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600]</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600]</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">Each Resin server in a cluster actually has access to the stats from the other servers, making cluster graphing possible, as shown in this example:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count,Resin|Thread|Thread%20Count&servers=00,01 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count,Resin|Thread|Thread%20Count&servers=00,01]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The "checks" parameter accepts the names 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".  [http://127.0.0.1:8080/resin-admin/?q=meters&s=0 Refer to the Meters page in resin-admin for a more comprehensive list.]</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The "checks" parameter accepts the names 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".  [http://127.0.0.1:8080/resin-admin/?q=meters&s=0 Refer to the Meters page in resin-admin for a more comprehensive list.]</div></td></tr>
</table>Cowanhttp://wiki4.caucho.com/index.php?title=Application_Server:_Custom_REST_Pages&diff=1076&oldid=prevCowan at 00:00, 21 March 20132013-03-21T00:00:00Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:00, 21 March 2013</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 44:</td>
<td colspan="2" class="diff-lineno">Line 44:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Writing a custom REST page ==  </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Writing a custom REST page ==  </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>To gather <del class="diffchange diffchange-inline">custom </del>JMX data, you'll create a custom REST page, which is just a PHP page accessing JMX. The page has the extension .rest and can be named whatever you like, e.g. mypage.rest. Put the my-app.rest page in WEB-INF/php/mypage.rest.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">resin-admin only accesses data via JMX.  </ins>To gather JMX data, you'll create a custom REST page, which is just a PHP page accessing JMX. The page has the extension .rest and can be named whatever you like, e.g. mypage.rest. Put the my-app.rest page in WEB-INF/php/mypage.rest.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Location of mypage.rest ==  </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Location of mypage.rest ==  </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The mypage.rest can be put directly in WEB-INF/php or in a custom location given by "resin_admin_ext_path. We recommend using resin_admin_ext_path so you can keep your extensions distinct from Resin's standard pages. The resin_admin_ext_path is configured in the resin.xml like:</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The mypage.rest can be put directly in WEB-INF/php or in a custom location given by "resin_admin_ext_path. We recommend using resin_admin_ext_path so you can keep your extensions distinct from Resin's standard pages. The resin_admin_ext_path is configured in the resin.xml like:</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"><resin xmlns="http://caucho.com/ns/resin"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">  ...</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin"></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin"></div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 76:</td>
<td colspan="2" class="diff-lineno">Line 72:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>   </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>   </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  printf("JvmThreadCount: %d\n", $jvm_thread->ThreadCount);</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  printf("JvmThreadCount: %d\n", $jvm_thread->ThreadCount);</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  ?></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>  ?></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The $mbean_server is a Resin's PHP interface to Java JMX MBeanServer. The lookup($name) method looks up a MBean by its ObjectName. The field reference is a JXM attribute.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The $mbean_server is a Resin's PHP interface to Java JMX MBeanServer. The lookup($name) method looks up a MBean by its ObjectName. The field reference is a JXM attribute.</div></td></tr>
</table>Cowanhttp://wiki4.caucho.com/index.php?title=Application_Server:_Custom_REST_Pages&diff=1075&oldid=prevCowan at 00:00, 21 March 20132013-03-21T00:00:00Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:00, 21 March 2013</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 5:</td>
<td colspan="2" class="diff-lineno">Line 5:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>The newer REST interface is documented thoroughly in the [http://www.caucho.com/resin-4.0/admin/resin-admin-rest.xtp documentation] and [[Application_Server:_REST_Graphing|usage examples] are on the Wiki also.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>The newer REST interface is documented thoroughly in the [http://www.caucho.com/resin-4.0/admin/resin-admin-rest.xtp <ins class="diffchange diffchange-inline">Resin </ins>documentation] and [[Application_Server:_REST_Graphing|usage examples<ins class="diffchange diffchange-inline">]</ins>] are on the Wiki also.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== rest.php ==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== rest.php ==</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 13:</td>
<td colspan="2" class="diff-lineno">Line 13:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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".</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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".</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>resin-admin <del class="diffchange diffchange-inline">includes </del>packaged 2 .rest pages <del class="diffchange diffchange-inline">which you can </del>use, or you can add your own <del class="diffchange diffchange-inline">to </del>this directory.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>resin-admin <ins class="diffchange diffchange-inline">as </ins>packaged <ins class="diffchange diffchange-inline">includes </ins>2 .rest pages <ins class="diffchange diffchange-inline">for your </ins>use, or you can add your own <ins class="diffchange diffchange-inline">additional .rest pagesto </ins>this directory.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== mod_status.rest ==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== mod_status.rest ==</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 27:</td>
<td colspan="2" class="diff-lineno">Line 27:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>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.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>With no parameters, graph.rest will <del class="diffchange diffchange-inline">not </del>graph <del class="diffchange diffchange-inline">data</del>.  The parameters are as follows:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>With no parameters, graph.rest will <ins class="diffchange diffchange-inline">produce no </ins>graph.  The parameters are as follows:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* checks: <del class="diffchange diffchange-inline">(required) </del>a Resin meter name to graph<del class="diffchange diffchange-inline">.  Can be passed </del>more than once to graph multiple statistics</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* checks: a Resin meter name to graph<ins class="diffchange diffchange-inline">, include </ins>more than once to graph multiple statistics <ins class="diffchange diffchange-inline">(required)</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>* servers: Resin server cluster index, typically 00 though xx (defaults to the local server)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>* servers: Resin server cluster index, typically 00 though xx<ins class="diffchange diffchange-inline">, include more than once to graph multiple statistics </ins>(defaults to the local server)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* width: graph width (defaults to 640)</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* width: graph width (defaults to 640)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* height: graph height (defaults t 480)</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* height: graph height (defaults t 480)</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 40:</td>
<td colspan="2" class="diff-lineno">Line 40:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600]</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>The "checks" parameter accepts the <del class="diffchange diffchange-inline">name </del>of a Resin <del class="diffchange diffchange-inline">"meters"</del>.  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".  [http://127.0.0.1:8080/resin-admin/?q=meters&s=0 Refer to the Meters page in resin-admin for a more comprehensive list.]</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>The "checks" parameter accepts the <ins class="diffchange diffchange-inline">names </ins>of a Resin <ins class="diffchange diffchange-inline">Meters</ins>.  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".  [http://127.0.0.1:8080/resin-admin/?q=meters&s=0 Refer to the Meters page in resin-admin for a more comprehensive list.]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>== <del class="diffchange diffchange-inline">Custom </del>.rest <del class="diffchange diffchange-inline">Pages </del>==</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>== <ins class="diffchange diffchange-inline">Writing a custom REST page == </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">To gather custom JMX data, you'll create a custom REST page, which is just a PHP page accessing JMX. The page has the extension </ins>.rest <ins class="diffchange diffchange-inline">and can be named whatever you like, e.g. mypage.rest. Put the my-app.rest page in WEB-INF/php/mypage.rest.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>== <ins class="diffchange diffchange-inline">Location of mypage.rest == </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">The mypage.rest can be put directly in WEB-INF/php or in a custom location given by "resin_admin_ext_path. We recommend using resin_admin_ext_path so you can keep your extensions distinct from Resin's standard pages. The resin_admin_ext_path is configured in the resin.xml like:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"><resin xmlns="http://caucho.com/ns/resin"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  ...</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  <prologue></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    <resin:set var="resin_admin_external" value="false"/></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    <resin:set var="resin_admin_insecure" value="true"/></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    <resin:set var="resin_admin_ext_path"</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">              value="/var/resin/admin/php"/></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </prologue></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </web-app></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">== mypage.rest sample code ==</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">The code for a REST page will look like:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> <?php</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> header("Content-Type: text/plain; charset=utf-8");</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> $mbean_server = new MBeanServer();</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> $jvm_thread = $mbean_server->lookup("java.lang:type=Threading");</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> printf("JvmThreadCount: %d\n", $jvm_thread->ThreadCount);</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> ?></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">The $mbean_server is a Resin's PHP interface to Java JMX MBeanServer. The lookup($name) method looks up a MBean by its ObjectName. The field reference is a JXM attribute.</ins></div></td></tr>
</table>Cowanhttp://wiki4.caucho.com/index.php?title=Application_Server:_Custom_REST_Pages&diff=1074&oldid=prevCowan: Created page with "{{Cookbook}} {{Integration}} {{WebServer}} = Custom REST Pages = Resin actually provides 2 REST interfaces; a newer REST service which enables administration that mirrors ..."2013-03-21T00:00:00Z<p>Created page with "{{Cookbook}} {{Integration}} {{WebServer}} = Custom REST Pages = Resin actually provides 2 REST interfaces; a newer REST service which enables administration that mirrors ..."</p>
<p><b>New page</b></p><div>{{Cookbook}} {{Integration}} {{WebServer}} <br />
<br />
= Custom REST Pages =<br />
<br />
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.<br />
<br />
The newer REST interface is documented thoroughly in the [http://www.caucho.com/resin-4.0/admin/resin-admin-rest.xtp documentation] and [[Application_Server:_REST_Graphing|usage examples] are on the Wiki also.<br />
<br />
== rest.php ==<br />
<br />
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.<br />
<br />
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".<br />
<br />
resin-admin includes packaged 2 .rest pages which you can use, or you can add your own to this directory.<br />
<br />
== mod_status.rest ==<br />
<br />
[http://127.0.0.1:8080/resin-admin/rest.php?q=mod_status http://127.0.0.1:8080/resin-admin/rest.php?q=mod_status]<br />
<br />
This .rest page produces output similar to Apache's mod_status.<br />
<br />
== graph.rest ==<br />
<br />
[http://127.0.0.1:8080/resin-admin/rest.php?q=graph http://127.0.0.1:8080/resin-admin/rest.php?q=graph]<br />
<br />
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.<br />
<br />
With no parameters, graph.rest will not graph data. The parameters are as follows:<br />
<br />
* checks: (required) a Resin meter name to graph. Can be passed more than once to graph multiple statistics<br />
* servers: Resin server cluster index, typically 00 though xx (defaults to the local server)<br />
* width: graph width (defaults to 640)<br />
* height: graph height (defaults t 480)<br />
* canvas: name of html 5 canvas DIV on to draw on (defaults to generated named)<br />
* period: graph domain, in seconds since the current time (defaults to 60)<br />
<br />
For example, this URL will produce a graph of the number of JVM threads over the last hour for the current server:<br />
<br />
[http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600 http://127.0.0.1:8080/resin-admin/rest.php?q=graph&checks=JVM|Thread|JVM%20Thread%20Count&period=3600]<br />
<br />
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". [http://127.0.0.1:8080/resin-admin/?q=meters&s=0 Refer to the Meters page in resin-admin for a more comprehensive list.]<br />
<br />
== Custom .rest Pages ==</div>Cowan