有没有人知道Adobe ColdFusion 9标准版中是否有办法获取正在运行的请求列表?也许通过从一个CF Java对象调用一个方法,比如coldfusion.server.ServiceFactory ???
我知道在企业中您可以使用服务器监视器,但由于我们使用的是标准版,因此我们没有可用的服务器监视器。
感谢。
答案 0 :(得分:4)
感谢来自@barnyr的转向,我设法获得了一些代码,这些代码将输出当前运行的脚本名称列表,这正是我所需要的。这是任何有兴趣的人。
<!--- 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>
答案 1 :(得分:0)
如果您只是看到了脚本名称并且不介意做一些手工操作,那么您可以免费使用它。您需要做的是启动堆栈跟踪。有几种方法可以做到这一点,但对我来说,它们会像这样分解:
自己运行ColdFusion(通过从命令行启动CF或更改Windows服务以自行运行),然后使用jStack获取堆栈转储
让CF作为现有用户运行,但是configure it to allow remote JMX connections,然后使用VisualVM连接并use that to collect a stack dump
使用Thread以编程方式获取线程列表。 getAllStackTraces()。然后,您可以使用数据执行任何操作。所有ColdFusion请求线程都启动web-(对于内置web服务器)或jrpp-(对于那些通过IIS或apache处理的线程),因此你可以过滤掉其他类似的线程
如果您使用前两个选项来获取堆栈转储,那么我强烈建议您使用Samurai来检查它们。您可以间隔10秒进行多次转储,并快速识别哪些请求长时间运行
答案 2 :(得分:0)
尝试cftracker,它可能会做你需要的 https://github.com/misterdai/cfTrackercfTracker