ColdFusion Server Monitor API



Use the Server Monitor API to programmatically retrieve all 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 and the number of connections:

<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 dsn pool data array 
       dbpool = myObj.getDbPoolStats(); 
</cfscript> 
 
<!---  List the data sources ---> 
The ColdFusion server is connected to the following data sources:<br />  
<cfloop index="i" from="1" to="#ArrayLen(dbpool)#">  
       <cfoutput>#dbpool[i].DSN# #dbpool[i].TOTALCONNECTIONCOUNT#<br /></cfoutput> 
</cfloop>