Tracking ColdFusion sessions within FusionReactor, by way of FREC logging
Note: This blog post is from 2013. 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.Someone asked on the FusionReactor mailing list (a Google Group) whether FusionReactor tracked CF sessions. I started to write a reply, with the good news/bad news in answer to that, and as sometimes happens, it became long enough that I thought it might be better suited as a blog entry that I could point to from the list instead, and which may also help those not on the list (which is a great resource, as a low-volume list with a high signal to noise ratio.)
Anyway, here is the answer I wanted to offer to that question...
but which API is called -> "cfide.adminapi.servermonitoring.getActiveSessionCount()" ?
Here is another example using the ColdFusion Server Monitor API to track memory:
<cfscript>
frapi = createObject("java", "com.intergral.fusionreactor.api.FRAPI").getInstance();
adminObj = createObject("component","cfide.adminapi.administrator").login("passwordhere");
srvMon = createObject("component","cfide.adminapi.servermonitoring");
</cfscript>
<cfobject type="java" action="create" class="java.lang.Thread" name="Thread">
<cfloop from=1 to=120 index="j">
<cfscript>
frapi.postNumericAggregateMetric("/CF/MemoryUsage",
srvMon.getRealtimeStats().JVMUSEDMEMORY / 1048576 );
WriteOutput( srvMon.getRealtimeStats().JVMUSEDMEMORY / 1048576 );
Thread.sleep( JavaCast( "long",1000 ) );
</cfscript>
<cfflush>
</cfloop>
Here is an example where you are adding a series called Revenue (doesn't have to be a technical series :-) ). Notice I've just put these into loops with delays because they don't run in a sampler. Typically you would embed them into your code when you have a metric to track. Currently we only show the average of the series if you post multiple values inside the same second.
<cfscript>
frapi = createObject("java", "com.intergral.fusionreactor.api.FRAPI").getInstance();
</cfscript>
<cfobject type="java" action="create" class="java.lang.Thread" name="Thread">
<cfloop from=1 to=120 index="j">
<cfscript>
frapi.postNumericAggregateMetric("/Website/Revenue", RandRange(100,300));
Thread.sleep( JavaCast( "long",1000 ) );
</cfscript>
<cfflush>
</cfloop>
I'm not sure what the unknown series is, can you provide me with a little more information?