Adobe ColdFusion 8

ColdFusion Server Monitor API

Use the Server Monitor API to programmatically retrieve all of the data that the Server Monitor collects. The servermonitoring.cfc ColdFusion component contains methods that you call to perform Server Monitor tasks. For example, use the getAverageResponseTime method to get the average response time for the server.

To view the methods, method arguments, and documentation for the Server Monitor API, use the CFC Explorer. To do so, go to http://localhost:8500/CFIDE/adminapi/servermonitoring.cfc.

Use the Server Monitor API

  1. Instantiate administrator.cfc:
    <cfscript>
    	adminObj = createObject("component","cfide.adminapi.administrator");
    

    Note: You can instantiate administrator.cfc and call the login method in a single line of code, as the following example shows:

    createObject("component","cfide.adminapi.administrator").login("admin");

  2. Call the administrator.cfc login method, passing the ColdFusion Administrator password or the RDS password:
    adminObj.login("admin");

  3. Instantiate the Server Monitor CFC:
    myObj = createObject("component","cfide.adminapi.servermonitoring");

  4. Call the CFC method you want (this example uses getAverageResponseTime):
    myObj.getAverageResponseTime();

Example

The following example uses the Server Monitor API to list the data sources to which the ColdFusion Server is connected:

<cfscript>
 // Login to the ColdFusion Administrator.
 adminObj = createObject("component","cfide.adminapi.administrator");
 adminObj.login("admin");

 // Instantiate the Server Monitor object.
 myObj = createObject("component","cfide.adminapi.servermonitoring");

 // Get the average response time
 myObj.getDbPoolStats();
</cfscript>

<!--- Copy the array. --->
<cfset copyofarray = ArrayNew(1)>
<cfset copyofarray = #myObj.getDbPoolStats()#>

<!--- Get the length of the array. --->
<cfset dbpoolarraylen = ArrayLen(copyofarray)>

<!--- List the data sources. --->
The ColdFusion server is connected to the following data sources:<BR />
<cfset i = 1>
<cfloop index="i" from="1" to="#dbpoolarraylen#">
    <cfoutput>#copyofarray[i].DSN#<br /></cfoutput>
</cfloop>