Getting a list of running requests in ColdFusion 9 standard edition

限于喜欢 提交于 2019-12-12 18:59:40

问题


Does anyone know if there is a way in Adobe ColdFusion 9 standard edition to get a list of the running requests? Maybe by invoking a method from one of the CF Java objects, like coldfusion.server.ServiceFactory???

I know in enterprise you can use the server monitor for this but as we are using standard edition we do not have the server monitor available.

Thanks.


回答1:


Thanks to the steer from @barnyr I have managed to get some code that will output a list of the currently running script names, which is exactly what I needed. Here it is for anyone who is interested.

<!--- Create the thread object --->
<cfobject type="JAVA" action="Create" name="thread" class="java.lang.Thread">

<!--- Get all stack traces from the thread object --->
<cfset stackTrace = thread.getAllStackTraces()>

<!--- Convert the entrySet into an array --->
<cfset stackArray = stackTrace.entrySet().toArray()>

<cfoutput>
    <!--- Loop over the entrySet array --->
    <cfloop from="1" to="#ArrayLen(stackArray)#" index="sIndex">
        <!--- Get the current thread values --->
        <cfset thisThread = stackArray[sIndex].getValue()>
        <!--- Loop over current thread values --->
        <cfloop from="1" to="#ArrayLen(thisThread)#" index="tIndex">
            <!--- Get the filename for this thread --->
            <cfset thisThreadFile = thisThread[tIndex].getFileName()>
            <!--- If the file name contains .cfm output it --->
            <cfif isDefined("thisThreadFile") AND thisThreadFile CONTAINS ".cfm">
                #thisThreadFile#<br>
            </cfif>
        </cfloop>
    </cfloop>
</cfoutput>



回答2:


If you're after seeing just the script names and don't mind doing a little bit of manual work, you can have this for free. What you need to do is initiate a Stack trace. There's a few methods of doing this, but for me, they break down like this:

  • Run ColdFusion as yourself (either by launching CF from the command line or changing the Windows Service to run as yourself), then use jStack to get the stack dumps

  • Leave CF running as the existing user, but configure it to allow remote JMX connections, then use VisualVM to connect and use that to collect a stack dump

  • Programatically get the list of threads using Thread. getAllStackTraces(). You can then do whatever you want with the data. All ColdFusion request threads start web- (for the built-in webserver) or jrpp- (for those handled through IIS or apache) so you can filter out other threads like that

If you use the first two options to get a stack dump, then I highly recommend using Samurai to examine them. You can do several dumps 10 seconds apart and quickly identify which requests are long-running




回答3:


Try cftracker, it may d what you neef https://github.com/misterdai/cfTrackercfTracker



来源:https://stackoverflow.com/questions/16108962/getting-a-list-of-running-requests-in-coldfusion-9-standard-edition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!