CF 2018 Update 9 - Get Active Threads programmatically with Performance Monitoring Toolset
Copy link to clipboard
Copied
Hello Team,
After upgrading to Coldfusion 2018 Update 9 , I am getting the below error
"Information","ajp-nio-8018-exec-2","07/31/20","17:34:03","DEVTRUNK","ERROR ~~~ T1 System ERROR during execution of MasterDataQueueCheck.cfm: - Application-Instead, we have introduced a more comprehensive monitoring suite, called Performance Monitoring Toolset.-We have removed Server Monitor in ColdFusion (2018 release).
We used the Server Monitor in Coldfusion 2016 to the list of All Active Threads.
Copy link to clipboard
Copied
True, the monitoring functions have been moved to the Performance Monitoring Toolset (PMT). The PMT is a monitoring tool that is separate from ColdFusion.
You could use Java to programmatically dump the list of active threads. A quick look around and I found the following. It worked the very first time. 🙂
<cfscript>
try {
obj = createobject("java","java.lang.Thread").getAllStackTraces();
for(thread in obj) {
writeoutput("<p><strong>******************** Thead:" & thread.getId() & "******************** </strong></p>" )
writeoutput("ID:" & thread.getId() & "<br>");
writeoutput("Name:" & thread.getName() & "<br>");
writeoutput("Priority:" & thread.getPriority() & "<br>");
writeoutput("StackTrace:" & thread.getStackTrace() & "<br>");
writeoutput("State:" & thread.getState() & "<br>");
writeoutput("ThreadGroup:" & thread.getThreadGroup() & "<br>");
writeoutput("IsAlive:" & thread.isAlive() & "<br>");
writeoutput("IsDaemon:" & thread.isDaemon() & "<br>");
writeoutput("IsInterrupted:" & thread.isInterrupted() & "<br>");
writeoutput("ToString:" & thread.toString() & "<br>");
}
} catch (any exception) {
// Handle exception, for example, by dumping it.
//writedump(exception);
}
</cfscript>
If it is important for you to have detailed information about active threads, then I would recommend that you use a specialist tool. For example, the PMT or FusionReactor.
Copy link to clipboard
Copied
Better:
<cfscript>
try {
obj = createobject("java","java.lang.Thread").getAllStackTraces();
for(thread in obj) {
writeoutput(
"<p><strong>******************** Thead:" & thread.getId() & "******************** </strong></p>"
& "ID:" & thread.getId() & "<br>"
& "Name:" & thread.getName() & "<br>"
& "Priority:" & thread.getPriority() & "<br>"
& "StackTrace:" & thread.getStackTrace() & "<br>"
& "State:" & thread.getState() & "<br>"
& "ThreadGroup:" & thread.getThreadGroup() & "<br>"
& "IsAlive:" & thread.isAlive() & "<br>"
& "IsDaemon:" & thread.isDaemon() & "<br>"
& "IsInterrupted:" & thread.isInterrupted() & "<br>"
& "ToString:" & thread.toString() & "<br>"
& "ActiveCount:" & thread.activeCount() & "<br>"
);
}
} catch (any exception) {
// Handle exception, for example, by dumping it.
//writedump(exception);
}
</cfscript>
Copy link to clipboard
Copied
Thanks for your suggestion BKBK.
Copy link to clipboard
Copied
Adding to BKBK's helpful suggestion, I would agree and lament if the ability to get such cfthread threads via the Admin API call was lost in the move to CF2018's PMT. I would recommend you open a bug report about this. They may tell you of a new method that exists (in the same or another admin api cfc), or they may change it to a "feature request" that needs to be attended to by creating a new one.
Second, it's worth noting that that would list ALL threads in the JVM, you could limit it to JUST cfthread threads (as the OP was requesting) by filtering on that the result of that getName. A cfthread thread would start, I think, with the name "cf-thread" and then a number. Whatever it is, you will see them in your dump and can modify accordingly.
/Charlie (troubleshooter, carehart. org)
Copy link to clipboard
Copied
Thanks Charlie. I will open a bug report for this.

