Tracking number of CF sessions per application easily, and why you should care
Note: This blog post is from 2009. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.Ever wanted to count how many sessions are active on your server, in total and per application, whether on CF 7 or 8? And regardless of whether you're using CF's regular sessions or the "new" J2EE sessions feature introduced in CF 6? Would you be surprised to find you could have a shocking number of active sessions?
But here's the very good news: it's just that one tiny method (two of code) get the instance name, using a jrun method. That no longer works since CF10. (I have a blog post on the new way to get it, since CF10, here: https://www.carehart...)
Anyway, we just need to replace that approach (a single line using the Admin API) for the two lines he had before.
The change is to be made in au\com\lynchconsulting\cfc\managers\SystemManager.cfc
And in there, see the method getCFInstanceName. In there, he has these two lines of code, that I have commented out and added in the newer line:
//var jrunObj = createObject("java", "jrunx.kernel.JRun");
//return jrunObj.getServerName();
return createobject("component","CFIDE.adminapi.runtime").getinstancename();
I did that and it works for me, on CF2018. Let me know how it goes for you.