Database Changes
It is uncertain what will happen if the new version of your application makes changes to your database schema (e.g., uses [ERXMigrations|WO:Project WONDER-Frameworks-ERXMigration]). The old instances may raise exceptions before they can gracefully shut down because the schema no longer matches what the old application's EOF expects. *Try it out on a test server first and then update this page so everyone knows\!*
{note}
h4. Statistics
If you call {noformat:nopanel=true}http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/wa/statistics{noformat}, JavaMonitor will send you back statistics, in JSON format, about instances, per application.
{code:title=Statistics Example Results}
(
{
"configuredInstances" = "2";
"maxSessions" = "0";
"maxAvgIdleTime" = "2.078";
"avgTransactions" = "44.0000";
"sumSessions" = "0";
"avgAvgTransactionTime" = "0.0985000";
"refusingInstances" = "0";
"avgSessions" = "0.0000";
"maxTransactions" = "88";
"applicationName" = "AjaxExample";
"avgAvgIdleTime" = "1.0390000";
"maxAvgTransactionTime" = "0.197";
"runningInstances" = "2";
"sumTransactions" = "88";
},
{
"configuredInstances" = "2";
"maxSessions" = "0";
"maxAvgIdleTime" = "325.443";
"avgTransactions" = "0.5000";
"sumSessions" = "0";
"avgAvgTransactionTime" = "0.00000";
"refusingInstances" = "0";
"avgSessions" = "0.0000";
"maxTransactions" = "1";
"applicationName" = "AjaxExample2";
"avgAvgIdleTime" = "162.7215000";
"maxAvgTransactionTime" = "0.0";
"runningInstances" = "2";
"sumTransactions" = "1";
}
)
{code}
If JavaMonitor is configured with a password, and I hope you do, pass _pw=monitorpassword_ as a argument to the query :
[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/wa/statistics?pw=monitorpassword]
h4. Direct Actions to many tasks
You can do most of the standard tasks you do in Monitor by calling direct actions. They are in a different query handler, _/admin_. They follow the same format and use the same query parameters. Those DA can be useful if you need to restart instances or other tasks within ant or other build/deployment systems.
_?type=all_ : return details about all applications and instances
_?type=app&name=AppName_ : return details about all instances of a specific application
_?type=ins&name=AppName-InstanceNo_ : return details about one specific instance
For example, if you want to get details about all instances and applications, you call :
[http://hostname:56789/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=all]
To get details about the _AjaxExample_ application :
[http://hostname:56789/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=app&name=AjaxExample]
And for a specific instance :
[http://hostname:56789/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=ins&name=AjaxExample-1]
The response for the direct actions will either send a JSON array or YES/NO. For example, the query _info_ for all instances will return :
{code}
[Hudson Build Server for Wonder|http://webobjects.mdimension.com/hudson/job/Wonder54/lastSuccessfulBuild/artifact/dist/]
{code}
List of available direct actions :
_/info_ : return details (number of deaths, state, etc.; see above), in JSON, about an instance.
_/running_ : return YES if the instance is running, NO if not.
_/stopped_ : return NO if the instance is running, YES if not.
_/bounce_: more on it later.
_/clearDeaths_ : clear the number of deaths (same action as clicking the "Clear deaths" in JavaMonitor)
_/turnScheduledOn_ : turn scheduling on for an application or instance. Call _/turnScheduledOff_ to do the opposite.
_/turnRefuseNewSessionsOn_ : turn "Refuse new sessions" on, call _turnRefuseNewSessionsOff_ to do the opposite.
_/turnAutoRecoverOn_ : guess what? It activate "Auto recover"\! And guess again? _/turnAutoRecoverOff_ do the opposite\!
_/forceQuit_ : force quit an application, might be useful to call it from a monitoring system.
_/stop_ : stop an application/instance the normal way.
_/start_ : start an application/instance the normal way.
h4. Remote Control via REST Routes
On September 28th 2010, REST routes were added in JavaMonitor. Those routes + the direct actions explained in this document allow you to control almost everything remotely (make sure that your JavaMonitor installation is secure\!). As the direct actions, append _?pw=XXXX_ to the URLs if JavaMonitor is password protected.
Examples of REST calls :
Fetching the details of all applications :
{code}
curl -X GET http://127.0.0.1:56789/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications.json
{code}
Adding a new application :
{code}
curl -X POST -d "{id: 'AjaxExample',type: 'MApplication', name: 'AjaxExample',unixOutputPath: '/opt/Local/Library/WebObjects/Logs', unixPath: '/opt/Local/Library/WebObjects/Applications/AjaxExample.woa/AjaxExample'}" http://127.0.0.1:56789/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications.json
{code}
Adding a new instance :
{code}
curl -X GET http://127.0.0.1:56789/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample/addInstance&host=localhost
{code}
Delete an application :
{code}
curl -X DELETE http://127.0.0.1:56789/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample.json
{code}
Delete an instance :
{code}
curl -X GET http://127.0.0.1:56789/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample/deleteInstance?id=1
{code}
Adding a new host :
{code}
curl -X POST -d "{id: 'otherserver.com',type: 'MHost', osType: 'MACOSX',address: '192.168.20.5', name: 'otherserver.com'}" http://127.0.0.1:56789/apps/WebObjects/JavaMonitor.woa/ra/mHosts.json