-
Notifications
You must be signed in to change notification settings - Fork 0
/
sessioncount_external.cfm
43 lines (39 loc) · 1.49 KB
/
sessioncount_external.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<cfsetting enablecfoutputonly="true">
<cfscript>
// Returns a count (Int) of the number of active sessions for a specific application on the node/instance
// This script is run outside the application WEB-INF you want to track, but within the same node/instance.
// You must add your `targetAppName` and `nodeServerPwd` (Railo server password)
// You man need to enable `Application.cfc_` (ie remove the trailing underscore) to prevent the application
// server bubbling up to find an Application.cfc
try
{
targetAppName = "<app name>";
nodeServerPwd = "<railo server password>";
// Retrieve all the web config/contexts for this instance
configs = getPageContext().getConfig().getConfigServer(nodeServerPwd).getConfigWebs();
output = "";
targetAppFound = false;
for(config in configs)
{
// Retrieve all the application scopes active on this config/context
appScopes = config.getFactory().getScopeContext().getAllApplicationScopes();
if (structKeyExists(appScopes, targetAppName))
{
output = structCount(config.getFactory().getScopeContext().getAllSessionScopes(targetAppName)); // Railo 3.x
//output = config.getFactory().getScopeContext().getSessionCount(getPageContext()); Railo 4.x
targetAppFound = true;
break;
}
}
if (!targetAppFound)
{
output = "I didn't find any applications running that match '#targetAppName#'";
}
}
catch (any e)
{
output = e.message;
getPageContext().getResponse().setstatus(500);
}
writeOutput(output);
</cfscript>