Highlighted

CF 2018 Update 9 - Get Active Threads programmatically with Performance Monitoring Toolset

Community Beginner ,
Sep 18, 2020

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.

 

var objMonitor = createobject("component","cfide.adminapi.servermonitoring");
var arrThreads = objMonitor.getAllActiveCFThreads();
 
I know this is deprecated now and we are supposed to use the Performance Monitoring Toolset, but I cannot find any code for this to use it programmatically in Coldfsuion.
 
Can someone shed some light as to how are we supposed to get the active threads programmatically using the new Performance Monitoring Toolset?
 
Thanks

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CF 2018 Update 9 - Get Active Threads programmatically with Performance Monitoring Toolset

Community Beginner ,
Sep 18, 2020

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.

 

var objMonitor = createobject("component","cfide.adminapi.servermonitoring");
var arrThreads = objMonitor.getAllActiveCFThreads();
 
I know this is deprecated now and we are supposed to use the Performance Monitoring Toolset, but I cannot find any code for this to use it programmatically in Coldfsuion.
 
Can someone shed some light as to how are we supposed to get the active threads programmatically using the new Performance Monitoring Toolset?
 
Thanks

Views

92

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 18, 2020 0
Adobe Community Professional ,
Sep 19, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 19, 2020 0
Adobe Community Professional ,
Sep 19, 2020

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 19, 2020 0
Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Thanks for your suggestion BKBK.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2020 0
Adobe Community Professional ,
Sep 21, 2020

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 (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2020 1
Community Beginner ,
Sep 22, 2020

Copy link to clipboard

Copied

Thanks Charlie. I will open a bug report for this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2020 0