aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Statistics
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-25 23:11:50 +0100
committerJustin Clark-Casey (justincc)2012-07-25 23:11:50 +0100
commit35efa88c26d249d315837fdca0faf643511e1a4e (patch)
tree00227cb097196ca172ed9639c536e4934326e89f /OpenSim/Framework/Statistics
parentAdd MemoryWatchdog class missing from git master a1e9964 (diff)
downloadopensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.zip
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.gz
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.bz2
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.xz
Rename OpenSim.Framework.Statistics to OpenSim.Framework.Monitoring.
This better reflects the long-term purpose of that project and matches Monitoring modules.
Diffstat (limited to 'OpenSim/Framework/Statistics')
-rw-r--r--OpenSim/Framework/Statistics/AssetStatsCollector.cs104
-rw-r--r--OpenSim/Framework/Statistics/BaseStatsCollector.cs68
-rw-r--r--OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs41
-rw-r--r--OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs49
-rw-r--r--OpenSim/Framework/Statistics/SimExtraStatsCollector.cs464
-rw-r--r--OpenSim/Framework/Statistics/StatsManager.cs65
-rw-r--r--OpenSim/Framework/Statistics/UserStatsCollector.cs92
7 files changed, 0 insertions, 883 deletions
diff --git a/OpenSim/Framework/Statistics/AssetStatsCollector.cs b/OpenSim/Framework/Statistics/AssetStatsCollector.cs
deleted file mode 100644
index 7082ef3..0000000
--- a/OpenSim/Framework/Statistics/AssetStatsCollector.cs
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Timers;
30
31namespace OpenSim.Framework.Statistics
32{
33 /// <summary>
34 /// Asset service statistics collection
35 /// </summary>
36 public class AssetStatsCollector : BaseStatsCollector
37 {
38 private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000);
39 private DateTime startTime = DateTime.Now;
40
41 private long assetRequestsToday;
42 private long assetRequestsNotFoundToday;
43 private long assetRequestsYesterday;
44 private long assetRequestsNotFoundYesterday;
45
46 public long AssetRequestsToday { get { return assetRequestsToday; } }
47 public long AssetRequestsNotFoundToday { get { return assetRequestsNotFoundToday; } }
48 public long AssetRequestsYesterday { get { return assetRequestsYesterday; } }
49 public long AssetRequestsNotFoundYesterday { get { return assetRequestsNotFoundYesterday; } }
50
51 public AssetStatsCollector()
52 {
53 ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
54 ageStatsTimer.Enabled = true;
55 }
56
57 private void OnAgeing(object source, ElapsedEventArgs e)
58 {
59 assetRequestsYesterday = assetRequestsToday;
60
61 // There is a possibility that an asset request could occur between the execution of these
62 // two statements. But we're better off without the synchronization overhead.
63 assetRequestsToday = 0;
64
65 assetRequestsNotFoundYesterday = assetRequestsNotFoundToday;
66 assetRequestsNotFoundToday = 0;
67 }
68
69 /// <summary>
70 /// Record that an asset request failed to find an asset
71 /// </summary>
72 public void AddNotFoundRequest()
73 {
74 assetRequestsNotFoundToday++;
75 }
76
77 /// <summary>
78 /// Record that a request was made to the asset server
79 /// </summary>
80 public void AddRequest()
81 {
82 assetRequestsToday++;
83 }
84
85 /// <summary>
86 /// Report back collected statistical information.
87 /// </summary>
88 /// <returns></returns>
89 override public string Report()
90 {
91 double elapsedHours = (DateTime.Now - startTime).TotalHours;
92 if (elapsedHours <= 0) { elapsedHours = 1; } // prevent divide by zero
93
94 long assetRequestsTodayPerHour = (long)Math.Round(AssetRequestsToday / elapsedHours);
95 long assetRequestsYesterdayPerHour = (long)Math.Round(AssetRequestsYesterday / 24.0);
96
97 return string.Format(
98@"Asset requests today : {0} ({1} per hour) of which {2} were not found
99Asset requests yesterday : {3} ({4} per hour) of which {5} were not found",
100 AssetRequestsToday, assetRequestsTodayPerHour, AssetRequestsNotFoundToday,
101 AssetRequestsYesterday, assetRequestsYesterdayPerHour, AssetRequestsNotFoundYesterday);
102 }
103 }
104}
diff --git a/OpenSim/Framework/Statistics/BaseStatsCollector.cs b/OpenSim/Framework/Statistics/BaseStatsCollector.cs
deleted file mode 100644
index 1fe086c..0000000
--- a/OpenSim/Framework/Statistics/BaseStatsCollector.cs
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Diagnostics;
30using System.Text;
31using OpenMetaverse;
32using OpenMetaverse.StructuredData;
33
34
35namespace OpenSim.Framework.Statistics
36{
37 /// <summary>
38 /// Statistics which all collectors are interested in reporting
39 /// </summary>
40 public class BaseStatsCollector : IStatsCollector
41 {
42 public virtual string Report()
43 {
44 StringBuilder sb = new StringBuilder(Environment.NewLine);
45 sb.Append("MEMORY STATISTICS");
46 sb.Append(Environment.NewLine);
47
48 sb.AppendFormat(
49 "Allocated to OpenSim objects: {0} MB\n",
50 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
51
52 sb.AppendFormat(
53 "OpenSim object memory churn : {0} MB/s\n",
54 Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3));
55
56 sb.AppendFormat(
57 "Process memory : {0} MB\n",
58 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0));
59
60 return sb.ToString();
61 }
62
63 public virtual string XReport(string uptime, string version)
64 {
65 return (string) Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0).ToString() ;
66 }
67 }
68}
diff --git a/OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs b/OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs
deleted file mode 100644
index 430e580..0000000
--- a/OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.Framework.Statistics.Interfaces
29{
30 /// <summary>
31 /// Implemented by objects which allow statistical information to be pulled from them.
32 /// </summary>
33 public interface IPullStatsProvider
34 {
35 /// <summary>
36 /// Provide statistical information. Only temporary one long string.
37 /// </summary>
38 /// <returns></returns>
39 string GetStats();
40 }
41}
diff --git a/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs b/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs
deleted file mode 100644
index 477bbb3..0000000
--- a/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.Framework.Statistics
29{
30 /// <summary>
31 /// Implemented by classes which collect up non-viewer statistical information
32 /// </summary>
33 public interface IStatsCollector
34 {
35 /// <summary>
36 /// Report back collected statistical information.
37 /// </summary>
38 /// <returns></returns>
39 string Report();
40
41 /// <summary>
42 /// Report back collected statistical information in json
43 /// </summary>
44 /// <returns>
45 /// A <see cref="System.String"/>
46 /// </returns>
47 string XReport(string uptime, string version);
48 }
49}
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
deleted file mode 100644
index a506e3b..0000000
--- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
+++ /dev/null
@@ -1,464 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using OpenMetaverse;
33using OpenSim.Framework.Statistics.Interfaces;
34using OpenMetaverse.StructuredData;
35
36namespace OpenSim.Framework.Statistics
37{
38 /// <summary>
39 /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane
40 /// </summary>
41 public class SimExtraStatsCollector : BaseStatsCollector
42 {
43 private long abnormalClientThreadTerminations;
44
45// private long assetsInCache;
46// private long texturesInCache;
47// private long assetCacheMemoryUsage;
48// private long textureCacheMemoryUsage;
49// private TimeSpan assetRequestTimeAfterCacheMiss;
50// private long blockedMissingTextureRequests;
51
52// private long assetServiceRequestFailures;
53// private long inventoryServiceRetrievalFailures;
54
55 private volatile float timeDilation;
56 private volatile float simFps;
57 private volatile float physicsFps;
58 private volatile float agentUpdates;
59 private volatile float rootAgents;
60 private volatile float childAgents;
61 private volatile float totalPrims;
62 private volatile float activePrims;
63 private volatile float totalFrameTime;
64 private volatile float netFrameTime;
65 private volatile float physicsFrameTime;
66 private volatile float otherFrameTime;
67 private volatile float imageFrameTime;
68 private volatile float inPacketsPerSecond;
69 private volatile float outPacketsPerSecond;
70 private volatile float unackedBytes;
71 private volatile float agentFrameTime;
72 private volatile float pendingDownloads;
73 private volatile float pendingUploads;
74 private volatile float activeScripts;
75 private volatile float scriptLinesPerSecond;
76
77 /// <summary>
78 /// Number of times that a client thread terminated because of an exception
79 /// </summary>
80 public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } }
81
82// /// <summary>
83// /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the
84// /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these
85// /// haven't yet been implemented...
86// /// </summary>
87// public long AssetsInCache { get { return assetsInCache; } }
88//
89// /// <value>
90// /// Currently unused
91// /// </value>
92// public long TexturesInCache { get { return texturesInCache; } }
93//
94// /// <value>
95// /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit
96// /// </value>
97// public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
98//
99// /// <value>
100// /// Currently unused
101// /// </value>
102// public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
103
104 public float TimeDilation { get { return timeDilation; } }
105 public float SimFps { get { return simFps; } }
106 public float PhysicsFps { get { return physicsFps; } }
107 public float AgentUpdates { get { return agentUpdates; } }
108 public float RootAgents { get { return rootAgents; } }
109 public float ChildAgents { get { return childAgents; } }
110 public float TotalPrims { get { return totalPrims; } }
111 public float ActivePrims { get { return activePrims; } }
112 public float TotalFrameTime { get { return totalFrameTime; } }
113 public float NetFrameTime { get { return netFrameTime; } }
114 public float PhysicsFrameTime { get { return physicsFrameTime; } }
115 public float OtherFrameTime { get { return otherFrameTime; } }
116 public float ImageFrameTime { get { return imageFrameTime; } }
117 public float InPacketsPerSecond { get { return inPacketsPerSecond; } }
118 public float OutPacketsPerSecond { get { return outPacketsPerSecond; } }
119 public float UnackedBytes { get { return unackedBytes; } }
120 public float AgentFrameTime { get { return agentFrameTime; } }
121 public float PendingDownloads { get { return pendingDownloads; } }
122 public float PendingUploads { get { return pendingUploads; } }
123 public float ActiveScripts { get { return activeScripts; } }
124 public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } }
125
126// /// <summary>
127// /// This is the time it took for the last asset request made in response to a cache miss.
128// /// </summary>
129// public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } }
130//
131// /// <summary>
132// /// Number of persistent requests for missing textures we have started blocking from clients. To some extent
133// /// this is just a temporary statistic to keep this problem in view - the root cause of this lies either
134// /// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics
135// /// driver bugs on clients (though this seems less likely).
136// /// </summary>
137// public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } }
138//
139// /// <summary>
140// /// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as
141// /// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted
142// /// as a failure
143// /// </summary>
144// public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } }
145
146 /// <summary>
147 /// Number of known failures to retrieve avatar inventory from the inventory service. This does not
148 /// cover situations where the inventory service accepts the request but never returns any data, since
149 /// we do not yet timeout this situation.
150 /// </summary>
151 /// <remarks>Commented out because we do not cache inventory at this point</remarks>
152// public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } }
153
154 /// <summary>
155 /// Retrieve the total frame time (in ms) of the last frame
156 /// </summary>
157 //public float TotalFrameTime { get { return totalFrameTime; } }
158
159 /// <summary>
160 /// Retrieve the physics update component (in ms) of the last frame
161 /// </summary>
162 //public float PhysicsFrameTime { get { return physicsFrameTime; } }
163
164 /// <summary>
165 /// Retain a dictionary of all packet queues stats reporters
166 /// </summary>
167 private IDictionary<UUID, PacketQueueStatsCollector> packetQueueStatsCollectors
168 = new Dictionary<UUID, PacketQueueStatsCollector>();
169
170 public void AddAbnormalClientThreadTermination()
171 {
172 abnormalClientThreadTerminations++;
173 }
174
175// public void AddAsset(AssetBase asset)
176// {
177// assetsInCache++;
178// //assetCacheMemoryUsage += asset.Data.Length;
179// }
180//
181// public void RemoveAsset(UUID uuid)
182// {
183// assetsInCache--;
184// }
185//
186// public void AddTexture(AssetBase image)
187// {
188// if (image.Data != null)
189// {
190// texturesInCache++;
191//
192// // This could have been a pull stat, though there was originally a nebulous idea to measure flow rates
193// textureCacheMemoryUsage += image.Data.Length;
194// }
195// }
196//
197// /// <summary>
198// /// Signal that the asset cache has been cleared.
199// /// </summary>
200// public void ClearAssetCacheStatistics()
201// {
202// assetsInCache = 0;
203// assetCacheMemoryUsage = 0;
204// texturesInCache = 0;
205// textureCacheMemoryUsage = 0;
206// }
207//
208// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts)
209// {
210// assetRequestTimeAfterCacheMiss = ts;
211// }
212//
213// public void AddBlockedMissingTextureRequest()
214// {
215// blockedMissingTextureRequests++;
216// }
217//
218// public void AddAssetServiceRequestFailure()
219// {
220// assetServiceRequestFailures++;
221// }
222
223// public void AddInventoryServiceRetrievalFailure()
224// {
225// inventoryServiceRetrievalFailures++;
226// }
227
228 /// <summary>
229 /// Register as a packet queue stats provider
230 /// </summary>
231 /// <param name="uuid">An agent UUID</param>
232 /// <param name="provider"></param>
233 public void RegisterPacketQueueStatsProvider(UUID uuid, IPullStatsProvider provider)
234 {
235 lock (packetQueueStatsCollectors)
236 {
237 // FIXME: If the region service is providing more than one region, then the child and root agent
238 // queues are wrongly replacing each other here.
239 packetQueueStatsCollectors[uuid] = new PacketQueueStatsCollector(provider);
240 }
241 }
242
243 /// <summary>
244 /// Deregister a packet queue stats provider
245 /// </summary>
246 /// <param name="uuid">An agent UUID</param>
247 public void DeregisterPacketQueueStatsProvider(UUID uuid)
248 {
249 lock (packetQueueStatsCollectors)
250 {
251 packetQueueStatsCollectors.Remove(uuid);
252 }
253 }
254
255 /// <summary>
256 /// This is the method on which the classic sim stats reporter (which collects stats for
257 /// client purposes) sends information to listeners.
258 /// </summary>
259 /// <param name="pack"></param>
260 public void ReceiveClassicSimStatsPacket(SimStats stats)
261 {
262 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
263 // SimStatsPacket that was being used).
264 timeDilation = stats.StatsBlock[0].StatValue;
265 simFps = stats.StatsBlock[1].StatValue;
266 physicsFps = stats.StatsBlock[2].StatValue;
267 agentUpdates = stats.StatsBlock[3].StatValue;
268 rootAgents = stats.StatsBlock[4].StatValue;
269 childAgents = stats.StatsBlock[5].StatValue;
270 totalPrims = stats.StatsBlock[6].StatValue;
271 activePrims = stats.StatsBlock[7].StatValue;
272 totalFrameTime = stats.StatsBlock[8].StatValue;
273 netFrameTime = stats.StatsBlock[9].StatValue;
274 physicsFrameTime = stats.StatsBlock[10].StatValue;
275 otherFrameTime = stats.StatsBlock[11].StatValue;
276 imageFrameTime = stats.StatsBlock[12].StatValue;
277 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
278 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
279 unackedBytes = stats.StatsBlock[15].StatValue;
280 agentFrameTime = stats.StatsBlock[16].StatValue;
281 pendingDownloads = stats.StatsBlock[17].StatValue;
282 pendingUploads = stats.StatsBlock[18].StatValue;
283 activeScripts = stats.StatsBlock[19].StatValue;
284 scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
285 }
286
287 /// <summary>
288 /// Report back collected statistical information.
289 /// </summary>
290 /// <returns></returns>
291 public override string Report()
292 {
293 StringBuilder sb = new StringBuilder(Environment.NewLine);
294// sb.Append("ASSET STATISTICS");
295// sb.Append(Environment.NewLine);
296
297 /*
298 sb.Append(
299 string.Format(
300@"Asset cache contains {0,6} non-texture assets using {1,10} K
301Texture cache contains {2,6} texture assets using {3,10} K
302Latest asset request time after cache miss: {4}s
303Blocked client requests for missing textures: {5}
304Asset service request failures: {6}"+ Environment.NewLine,
305 AssetsInCache, Math.Round(AssetCacheMemoryUsage / 1024.0),
306 TexturesInCache, Math.Round(TextureCacheMemoryUsage / 1024.0),
307 assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0,
308 BlockedMissingTextureRequests,
309 AssetServiceRequestFailures));
310 */
311
312 /*
313 sb.Append(
314 string.Format(
315@"Asset cache contains {0,6} assets
316Latest asset request time after cache miss: {1}s
317Blocked client requests for missing textures: {2}
318Asset service request failures: {3}" + Environment.NewLine,
319 AssetsInCache,
320 assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0,
321 BlockedMissingTextureRequests,
322 AssetServiceRequestFailures));
323 */
324
325 sb.Append(Environment.NewLine);
326 sb.Append("CONNECTION STATISTICS");
327 sb.Append(Environment.NewLine);
328 sb.Append(
329 string.Format(
330 "Abnormal client thread terminations: {0}" + Environment.NewLine,
331 abnormalClientThreadTerminations));
332
333// sb.Append(Environment.NewLine);
334// sb.Append("INVENTORY STATISTICS");
335// sb.Append(Environment.NewLine);
336// sb.Append(
337// string.Format(
338// "Initial inventory caching failures: {0}" + Environment.NewLine,
339// InventoryServiceRetrievalFailures));
340
341 sb.Append(Environment.NewLine);
342 sb.Append("FRAME STATISTICS");
343 sb.Append(Environment.NewLine);
344 sb.Append("Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS");
345 sb.Append(Environment.NewLine);
346 sb.Append(
347 string.Format(
348 "{0,6:0.00} {1,6:0} {2,6:0.0} {3,6:0.0} {4,6:0} {5,6:0} {6,6:0} {7,6:0} {8,6:0} {9,6:0}",
349 timeDilation, simFps, physicsFps, agentUpdates, rootAgents,
350 childAgents, totalPrims, activePrims, activeScripts, scriptLinesPerSecond));
351
352 sb.Append(Environment.NewLine);
353 sb.Append(Environment.NewLine);
354 // There is no script frame time currently because we don't yet collect it
355 sb.Append("PktsIn PktOut PendDl PendUl UnackB TotlFt NetFt PhysFt OthrFt AgntFt ImgsFt");
356 sb.Append(Environment.NewLine);
357 sb.Append(
358 string.Format(
359 "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}",
360 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
361 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
362 sb.Append(Environment.NewLine);
363
364 /*
365 sb.Append(Environment.NewLine);
366 sb.Append("PACKET QUEUE STATISTICS");
367 sb.Append(Environment.NewLine);
368 sb.Append("Agent UUID ");
369 sb.Append(
370 string.Format(
371 " {0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
372 "Send", "In", "Out", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset"));
373 sb.Append(Environment.NewLine);
374
375 foreach (UUID key in packetQueueStatsCollectors.Keys)
376 {
377 sb.Append(string.Format("{0}: ", key));
378 sb.Append(packetQueueStatsCollectors[key].Report());
379 sb.Append(Environment.NewLine);
380 }
381 */
382
383 sb.Append(base.Report());
384
385 return sb.ToString();
386 }
387
388 /// <summary>
389 /// Report back collected statistical information as json serialization.
390 /// </summary>
391 /// <returns></returns>
392 public override string XReport(string uptime, string version)
393 {
394 OSDMap args = new OSDMap(30);
395// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
396// args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}",
397// assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0));
398// args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}",
399// BlockedMissingTextureRequests));
400// args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}",
401// AssetServiceRequestFailures));
402// args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}",
403// abnormalClientThreadTerminations));
404// args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}",
405// InventoryServiceRetrievalFailures));
406 args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation));
407 args["SimFPS"] = OSD.FromString (String.Format ("{0:0.##}", simFps));
408 args["PhyFPS"] = OSD.FromString (String.Format ("{0:0.##}", physicsFps));
409 args["AgntUp"] = OSD.FromString (String.Format ("{0:0.##}", agentUpdates));
410 args["RootAg"] = OSD.FromString (String.Format ("{0:0.##}", rootAgents));
411 args["ChldAg"] = OSD.FromString (String.Format ("{0:0.##}", childAgents));
412 args["Prims"] = OSD.FromString (String.Format ("{0:0.##}", totalPrims));
413 args["AtvPrm"] = OSD.FromString (String.Format ("{0:0.##}", activePrims));
414 args["AtvScr"] = OSD.FromString (String.Format ("{0:0.##}", activeScripts));
415 args["ScrLPS"] = OSD.FromString (String.Format ("{0:0.##}", scriptLinesPerSecond));
416 args["PktsIn"] = OSD.FromString (String.Format ("{0:0.##}", inPacketsPerSecond));
417 args["PktOut"] = OSD.FromString (String.Format ("{0:0.##}", outPacketsPerSecond));
418 args["PendDl"] = OSD.FromString (String.Format ("{0:0.##}", pendingDownloads));
419 args["PendUl"] = OSD.FromString (String.Format ("{0:0.##}", pendingUploads));
420 args["UnackB"] = OSD.FromString (String.Format ("{0:0.##}", unackedBytes));
421 args["TotlFt"] = OSD.FromString (String.Format ("{0:0.##}", totalFrameTime));
422 args["NetFt"] = OSD.FromString (String.Format ("{0:0.##}", netFrameTime));
423 args["PhysFt"] = OSD.FromString (String.Format ("{0:0.##}", physicsFrameTime));
424 args["OthrFt"] = OSD.FromString (String.Format ("{0:0.##}", otherFrameTime));
425 args["AgntFt"] = OSD.FromString (String.Format ("{0:0.##}", agentFrameTime));
426 args["ImgsFt"] = OSD.FromString (String.Format ("{0:0.##}", imageFrameTime));
427 args["Memory"] = OSD.FromString (base.XReport (uptime, version));
428 args["Uptime"] = OSD.FromString (uptime);
429 args["Version"] = OSD.FromString (version);
430
431 string strBuffer = "";
432 strBuffer = OSDParser.SerializeJsonString(args);
433
434 return strBuffer;
435 }
436 }
437
438 /// <summary>
439 /// Pull packet queue stats from packet queues and report
440 /// </summary>
441 public class PacketQueueStatsCollector : IStatsCollector
442 {
443 private IPullStatsProvider m_statsProvider;
444
445 public PacketQueueStatsCollector(IPullStatsProvider provider)
446 {
447 m_statsProvider = provider;
448 }
449
450 /// <summary>
451 /// Report back collected statistical information.
452 /// </summary>
453 /// <returns></returns>
454 public string Report()
455 {
456 return m_statsProvider.GetStats();
457 }
458
459 public string XReport(string uptime, string version)
460 {
461 return "";
462 }
463 }
464}
diff --git a/OpenSim/Framework/Statistics/StatsManager.cs b/OpenSim/Framework/Statistics/StatsManager.cs
deleted file mode 100644
index 436ce2f..0000000
--- a/OpenSim/Framework/Statistics/StatsManager.cs
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.Framework.Statistics
29{
30 /// <summary>
31 /// Singleton used to provide access to statistics reporters
32 /// </summary>
33 public class StatsManager
34 {
35 private static AssetStatsCollector assetStats;
36 private static UserStatsCollector userStats;
37 private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector();
38
39 public static AssetStatsCollector AssetStats { get { return assetStats; } }
40 public static UserStatsCollector UserStats { get { return userStats; } }
41 public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } }
42
43 /// <summary>
44 /// Start collecting statistics related to assets.
45 /// Should only be called once.
46 /// </summary>
47 public static AssetStatsCollector StartCollectingAssetStats()
48 {
49 assetStats = new AssetStatsCollector();
50
51 return assetStats;
52 }
53
54 /// <summary>
55 /// Start collecting statistics related to users.
56 /// Should only be called once.
57 /// </summary>
58 public static UserStatsCollector StartCollectingUserStats()
59 {
60 userStats = new UserStatsCollector();
61
62 return userStats;
63 }
64 }
65} \ No newline at end of file
diff --git a/OpenSim/Framework/Statistics/UserStatsCollector.cs b/OpenSim/Framework/Statistics/UserStatsCollector.cs
deleted file mode 100644
index fd2a9bf..0000000
--- a/OpenSim/Framework/Statistics/UserStatsCollector.cs
+++ /dev/null
@@ -1,92 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Timers;
29
30namespace OpenSim.Framework.Statistics
31{
32 /// <summary>
33 /// Collects user service statistics
34 /// </summary>
35 public class UserStatsCollector : BaseStatsCollector
36 {
37 private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000);
38
39 private int successfulLoginsToday;
40 public int SuccessfulLoginsToday { get { return successfulLoginsToday; } }
41
42 private int successfulLoginsYesterday;
43 public int SuccessfulLoginsYesterday { get { return successfulLoginsYesterday; } }
44
45 private int successfulLogins;
46 public int SuccessfulLogins { get { return successfulLogins; } }
47
48 private int logouts;
49 public int Logouts { get { return logouts; } }
50
51 public UserStatsCollector()
52 {
53 ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
54 ageStatsTimer.Enabled = true;
55 }
56
57 private void OnAgeing(object source, ElapsedEventArgs e)
58 {
59 successfulLoginsYesterday = successfulLoginsToday;
60
61 // There is a possibility that an asset request could occur between the execution of these
62 // two statements. But we're better off without the synchronization overhead.
63 successfulLoginsToday = 0;
64 }
65
66 /// <summary>
67 /// Record a successful login
68 /// </summary>
69 public void AddSuccessfulLogin()
70 {
71 successfulLogins++;
72 successfulLoginsToday++;
73 }
74
75 public void AddLogout()
76 {
77 logouts++;
78 }
79
80 /// <summary>
81 /// Report back collected statistical information.
82 /// </summary>
83 /// <returns></returns>
84 override public string Report()
85 {
86 return string.Format(
87@"Successful logins total : {0}, today : {1}, yesterday : {2}
88 Logouts total : {3}",
89 SuccessfulLogins, SuccessfulLoginsToday, SuccessfulLoginsYesterday, Logouts);
90 }
91 }
92}