-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_info.cfm
144 lines (118 loc) · 4.38 KB
/
server_info.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<cfsetting enablecfoutputonly="true">
<cfscript>
// Returns information about the instance this script is run in, from application and session data
// to Java memory usage
try
{
startTime = getTickCount();
nodeServerPwd = "<railo server password>";
configs = getPageContext().getConfig().getConfigServer(nodeServerPwd).getConfigWebs();
appCount = 0;
totalSessionCount = 0;
apps = [];
for(config in configs)
{
thisScopeContext = config.getFactory().getScopeContext();
appScopes = thisScopeContext.getAllApplicationScopes();
for(appName IN appScopes)
{
appCount++;
thisApp = {
"name" = appName
};
// Get the session info
sessionScopes[appName] = thisScopeContext.getAllSessionScopes(getPageContext(), appName);
thisApp["sessioncount"] = structCount(sessionScopes[appName]);
totalSessionCount += thisApp['sessioncount'];
arrayAppend(apps, thisApp);
}
data = {
"memory" = getJavaMemoryInfo(),
"processors" = getProcessorCount(),
"apps" = apps,
"appcount" = appCount,
"totalsessioncount" = totalSessionCount,
"memoryPools" = getJavaMemoryPoolInfo(),
"gc" = getJavaGCInfo(),
"compilation" = getJavaCompilationInfo(),
"classloading" = getClassLoadingInfo(),
"pageproccessingtimems" = getTickCount() - startTime
};
writeDump(data);
//writeOutput(serializeJSON(data));
}
}
catch (any e)
{
writeOutput(e.message);
getPageContext().getResponse().setstatus(500);
}
</cfscript>
<cffunction name="getClassLoadingInfo" returntype="struct" output="false">
<cfscript>
var bean = createObject("java","java.lang.management.ManagementFactory").getClassLoadingMXBean();
var data = structNew();
data.loadedClassCount = bean.getLoadedClassCount();
data.unloadedClassCount = bean.getUnloadedClassCount();
data.totalLoadedClassCount = bean.getTotalLoadedClassCount();
return data;
</cfscript>
</cffunction>
<cffunction name="getJavaCompilationInfo" returntype="struct" output="false">
<cfscript>
var bean = createObject("java","java.lang.management.ManagementFactory").getCompilationMXBean();
var data = structNew();
data.name = bean.getName();
data.totalCompilationTime = bean.getTotalCompilationTime();
data.isCompilationTimeMonitoringSupported = bean.isCompilationTimeMonitoringSupported();
return data;
</cfscript>
</cffunction>
<cffunction name="getJavaGCInfo" returntype="array" output="false">
<cfscript>
var memoryPools = createObject("java","java.lang.management.ManagementFactory").getGarbageCollectorMXBeans().toArray();
var data = arrayNew();
for(i=1;i LTE ArrayLen(memoryPools);i++){
data[i].name = memoryPools[i].getName();
data[i].count = memoryPools[i].getCollectionCount();
data[i].timespent = memoryPools[i].getCollectionTime();
}
return data;
</cfscript>
</cffunction>
<cffunction name="getJavaMemoryPoolInfo" returntype="array" output="false">
<cfscript>
var memoryPools = createObject("java","java.lang.management.ManagementFactory").getMemoryPoolMXBeans().toArray();
var data = arrayNew();
for(i=1;i LTE ArrayLen(memoryPools);i++){
data[i].name = memoryPools[i].getName();
data[i].type = memoryPools[i].getType().toString();
data[i].currentUsed = memoryPools[i].getUsage().getUsed();
data[i].currentCommited = memoryPools[i].getUsage().getCommitted();
data[i].currentMax = memoryPools[i].getUsage().getMax();
data[i].currentPercent = round((data[i].currentUsed/data[i].currentMax) * 100) ;
data[i].peakUsed = memoryPools[i].getPeakUsage().getUsed();
data[i].peakCommited = memoryPools[i].getPeakUsage().getCommitted();
data[i].peakMax = memoryPools[i].getPeakUsage().getMax();
data[i].peakPercent = round((data[i].peakUsed/data[i].peakMax) * 100) ;
}
return data;
</cfscript>
</cffunction>
<cffunction name="getJavaMemoryInfo" returntype="struct" output="false">
<cfscript>
var runtime = createObject("java","java.lang.Runtime").getRuntime();
var data = structNew();
data.freeMemory = runtime.freeMemory();
data.maxMemory = runtime.maxMemory();
data.totalMemory = runtime.totalMemory();
data.heapMemory = runtime.totalMemory()-runtime.freeMemory();
return data;
</cfscript>
</cffunction>
<cffunction name="getProcessorCount" returntype="numeric" output="false">
<cfscript>
var runtime = createObject("java","java.lang.Runtime").getRuntime();
return runtime.availableProcessors();
</cfscript>
</cffunction>