diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 300 |
1 files changed, 170 insertions, 130 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index a4afd47..18e6ece 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | //using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Timers; | 30 | using System.Timers; |
31 | using OpenMetaverse.Packets; | 31 | using OpenMetaverse.Packets; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -35,10 +35,18 @@ using OpenSim.Region.Framework.Interfaces; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 36 | namespace OpenSim.Region.Framework.Scenes |
37 | { | 37 | { |
38 | /// <summary> | ||
39 | /// Collect statistics from the scene to send to the client and for access by other monitoring tools. | ||
40 | /// </summary> | ||
41 | /// <remarks> | ||
42 | /// FIXME: This should be a monitoring region module | ||
43 | /// </remarks> | ||
38 | public class SimStatsReporter | 44 | public class SimStatsReporter |
39 | { | 45 | { |
40 | // private static readonly log4net.ILog m_log | 46 | private static readonly log4net.ILog m_log |
41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 47 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
48 | |||
49 | public const string LastReportedObjectUpdateStatName = "LastReportedObjectUpdates"; | ||
42 | 50 | ||
43 | public delegate void SendStatResult(SimStats stats); | 51 | public delegate void SendStatResult(SimStats stats); |
44 | 52 | ||
@@ -48,10 +56,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | 56 | ||
49 | public event YourStatsAreWrong OnStatsIncorrect; | 57 | public event YourStatsAreWrong OnStatsIncorrect; |
50 | 58 | ||
51 | private SendStatResult handlerSendStatResult = null; | 59 | private SendStatResult handlerSendStatResult; |
52 | 60 | ||
53 | private YourStatsAreWrong handlerStatsIncorrect = null; | 61 | private YourStatsAreWrong handlerStatsIncorrect; |
54 | 62 | ||
63 | /// <summary> | ||
64 | /// These are the IDs of stats sent in the StatsPacket to the viewer. | ||
65 | /// </summary> | ||
66 | /// <remarks> | ||
67 | /// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators | ||
68 | /// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky). | ||
69 | /// </remarks> | ||
55 | public enum Stats : uint | 70 | public enum Stats : uint |
56 | { | 71 | { |
57 | TimeDilation = 0, | 72 | TimeDilation = 0, |
@@ -75,20 +90,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
75 | OutPacketsPerSecond = 18, | 90 | OutPacketsPerSecond = 18, |
76 | PendingDownloads = 19, | 91 | PendingDownloads = 19, |
77 | PendingUploads = 20, | 92 | PendingUploads = 20, |
78 | VirtualSizeKB = 21, | 93 | VirtualSizeKb = 21, |
79 | ResidentSizeKB = 22, | 94 | ResidentSizeKb = 22, |
80 | PendingLocalUploads = 23, | 95 | PendingLocalUploads = 23, |
81 | UnAckedBytes = 24, | 96 | UnAckedBytes = 24, |
82 | PhysicsPinnedTasks = 25, | 97 | PhysicsPinnedTasks = 25, |
83 | PhysicsLODTasks = 26, | 98 | PhysicsLodTasks = 26, |
84 | PhysicsStepMS = 27, | 99 | SimPhysicsStepMs = 27, |
85 | PhysicsShapeMS = 28, | 100 | SimPhysicsShapeMs = 28, |
86 | PhysicsOtherMS = 29, | 101 | SimPhysicsOtherMs = 29, |
87 | PhysicsMemory = 30, | 102 | SimPhysicsMemory = 30, |
88 | ScriptEPS = 31, | 103 | ScriptEps = 31, |
89 | SimSpareTime = 32, | 104 | SimSpareMs = 32, |
90 | SimSleepTime = 33, | 105 | SimSleepMs = 33, |
91 | IOPumpTime = 34 | 106 | SimIoPumpTime = 34 |
92 | } | 107 | } |
93 | 108 | ||
94 | /// <summary> | 109 | /// <summary> |
@@ -113,11 +128,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | get { return lastReportedSimStats; } | 128 | get { return lastReportedSimStats; } |
114 | } | 129 | } |
115 | 130 | ||
131 | /// <summary> | ||
132 | /// Extra sim statistics that are used by monitors but not sent to the client. | ||
133 | /// </summary> | ||
134 | /// <value> | ||
135 | /// The keys are the stat names. | ||
136 | /// </value> | ||
137 | private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>(); | ||
138 | |||
116 | // Sending a stats update every 3 seconds- | 139 | // Sending a stats update every 3 seconds- |
117 | private int statsUpdatesEveryMS = 3000; | 140 | private int m_statsUpdatesEveryMS = 3000; |
118 | private float statsUpdateFactor = 0; | 141 | private float m_statsUpdateFactor; |
119 | private float m_timeDilation = 0; | 142 | private float m_timeDilation; |
120 | private int m_fps = 0; | 143 | private int m_fps; |
144 | |||
145 | /// <summary> | ||
146 | /// Number of the last frame on which we processed a stats udpate. | ||
147 | /// </summary> | ||
148 | private uint m_lastUpdateFrame; | ||
121 | 149 | ||
122 | /// <summary> | 150 | /// <summary> |
123 | /// Our nominal fps target, as expected in fps stats when a sim is running normally. | 151 | /// Our nominal fps target, as expected in fps stats when a sim is running normally. |
@@ -135,43 +163,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
135 | private float m_reportedFpsCorrectionFactor = 5; | 163 | private float m_reportedFpsCorrectionFactor = 5; |
136 | 164 | ||
137 | // saved last reported value so there is something available for llGetRegionFPS | 165 | // saved last reported value so there is something available for llGetRegionFPS |
138 | private float lastReportedSimFPS = 0; | 166 | private float lastReportedSimFPS; |
139 | private float[] lastReportedSimStats = new float[23]; | 167 | private float[] lastReportedSimStats = new float[22]; |
140 | private float m_pfps = 0; | 168 | private float m_pfps; |
141 | 169 | ||
142 | /// <summary> | 170 | /// <summary> |
143 | /// Number of agent updates requested in this stats cycle | 171 | /// Number of agent updates requested in this stats cycle |
144 | /// </summary> | 172 | /// </summary> |
145 | private int m_agentUpdates = 0; | 173 | private int m_agentUpdates; |
146 | 174 | ||
147 | /// <summary> | 175 | /// <summary> |
148 | /// Number of object updates requested in this stats cycle | 176 | /// Number of object updates requested in this stats cycle |
149 | /// </summary> | 177 | /// </summary> |
150 | private int m_objectUpdates; | 178 | private int m_objectUpdates; |
151 | 179 | ||
152 | private int m_frameMS = 0; | 180 | private int m_frameMS; |
153 | private int m_netMS = 0; | 181 | private int m_spareMS; |
154 | private int m_agentMS = 0; | 182 | private int m_netMS; |
155 | private int m_physicsMS = 0; | 183 | private int m_agentMS; |
156 | private int m_imageMS = 0; | 184 | private int m_physicsMS; |
157 | private int m_otherMS = 0; | 185 | private int m_imageMS; |
158 | private int m_sleeptimeMS = 0; | 186 | private int m_otherMS; |
159 | |||
160 | 187 | ||
161 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | 188 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. |
162 | //Ckrinke private int m_scriptMS = 0; | 189 | //Ckrinke private int m_scriptMS = 0; |
163 | 190 | ||
164 | private int m_rootAgents = 0; | 191 | private int m_rootAgents; |
165 | private int m_childAgents = 0; | 192 | private int m_childAgents; |
166 | private int m_numPrim = 0; | 193 | private int m_numPrim; |
167 | private int m_inPacketsPerSecond = 0; | 194 | private int m_inPacketsPerSecond; |
168 | private int m_outPacketsPerSecond = 0; | 195 | private int m_outPacketsPerSecond; |
169 | private int m_activePrim = 0; | 196 | private int m_activePrim; |
170 | private int m_unAckedBytes = 0; | 197 | private int m_unAckedBytes; |
171 | private int m_pendingDownloads = 0; | 198 | private int m_pendingDownloads; |
172 | private int m_pendingUploads = 0; | 199 | private int m_pendingUploads = 0; // FIXME: Not currently filled in |
173 | private int m_activeScripts = 0; | 200 | private int m_activeScripts; |
174 | private int m_scriptLinesPerSecond = 0; | 201 | private int m_scriptLinesPerSecond; |
175 | 202 | ||
176 | private int m_objectCapacity = 45000; | 203 | private int m_objectCapacity = 45000; |
177 | 204 | ||
@@ -187,13 +214,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | { | 214 | { |
188 | m_scene = scene; | 215 | m_scene = scene; |
189 | m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; | 216 | m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; |
190 | statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); | 217 | m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); |
191 | ReportingRegion = scene.RegionInfo; | 218 | ReportingRegion = scene.RegionInfo; |
192 | 219 | ||
193 | m_objectCapacity = scene.RegionInfo.ObjectCapacity; | 220 | m_objectCapacity = scene.RegionInfo.ObjectCapacity; |
194 | m_report.AutoReset = true; | 221 | m_report.AutoReset = true; |
195 | m_report.Interval = statsUpdatesEveryMS; | 222 | m_report.Interval = m_statsUpdatesEveryMS; |
196 | m_report.Elapsed += statsHeartBeat; | 223 | m_report.Elapsed += TriggerStatsHeartbeat; |
197 | m_report.Enabled = true; | 224 | m_report.Enabled = true; |
198 | 225 | ||
199 | if (StatsManager.SimExtraStats != null) | 226 | if (StatsManager.SimExtraStats != null) |
@@ -202,20 +229,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
202 | 229 | ||
203 | public void Close() | 230 | public void Close() |
204 | { | 231 | { |
205 | m_report.Elapsed -= statsHeartBeat; | 232 | m_report.Elapsed -= TriggerStatsHeartbeat; |
206 | m_report.Close(); | 233 | m_report.Close(); |
207 | } | 234 | } |
208 | 235 | ||
236 | /// <summary> | ||
237 | /// Sets the number of milliseconds between stat updates. | ||
238 | /// </summary> | ||
239 | /// <param name='ms'></param> | ||
209 | public void SetUpdateMS(int ms) | 240 | public void SetUpdateMS(int ms) |
210 | { | 241 | { |
211 | statsUpdatesEveryMS = ms; | 242 | m_statsUpdatesEveryMS = ms; |
212 | statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); | 243 | m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); |
213 | m_report.Interval = statsUpdatesEveryMS; | 244 | m_report.Interval = m_statsUpdatesEveryMS; |
245 | } | ||
246 | |||
247 | private void TriggerStatsHeartbeat(object sender, EventArgs args) | ||
248 | { | ||
249 | try | ||
250 | { | ||
251 | statsHeartBeat(sender, args); | ||
252 | } | ||
253 | catch (Exception e) | ||
254 | { | ||
255 | m_log.Warn(string.Format( | ||
256 | "[SIM STATS REPORTER] Update for {0} failed with exception ", | ||
257 | m_scene.RegionInfo.RegionName), e); | ||
258 | } | ||
214 | } | 259 | } |
215 | 260 | ||
216 | private void statsHeartBeat(object sender, EventArgs e) | 261 | private void statsHeartBeat(object sender, EventArgs e) |
217 | { | 262 | { |
218 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; | 263 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; |
219 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 264 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
220 | 265 | ||
221 | // Know what's not thread safe in Mono... modifying timers. | 266 | // Know what's not thread safe in Mono... modifying timers. |
@@ -242,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
242 | int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); | 287 | int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); |
243 | 288 | ||
244 | // save the reported value so there is something available for llGetRegionFPS | 289 | // save the reported value so there is something available for llGetRegionFPS |
245 | lastReportedSimFPS = reportedFPS / statsUpdateFactor; | 290 | lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; |
246 | 291 | ||
247 | float physfps = ((m_pfps / 1000)); | 292 | float physfps = ((m_pfps / 1000)); |
248 | 293 | ||
@@ -253,7 +298,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
253 | physfps = 0; | 298 | physfps = 0; |
254 | 299 | ||
255 | #endregion | 300 | #endregion |
256 | float factor = 1 / statsUpdateFactor; | ||
257 | if (reportedFPS <= 0) | 301 | if (reportedFPS <= 0) |
258 | reportedFPS = 1; | 302 | reportedFPS = 1; |
259 | 303 | ||
@@ -264,32 +308,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | 308 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; |
265 | 309 | ||
266 | float sparetime; | 310 | float sparetime; |
267 | float sleeptime; | ||
268 | if (TotalFrameTime > targetframetime) | 311 | if (TotalFrameTime > targetframetime) |
269 | { | 312 | { |
270 | sparetime = 0; | 313 | sparetime = 0; |
271 | sleeptime = 0; | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
276 | sparetime *= perframe; | ||
277 | if (sparetime < 0) | ||
278 | sparetime = 0; | ||
279 | else if (sparetime > TotalFrameTime) | ||
280 | sparetime = TotalFrameTime; | ||
281 | sleeptime = m_sleeptimeMS * perframe; | ||
282 | } | 314 | } |
315 | |||
316 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | ||
317 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | ||
318 | m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); | ||
319 | m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); | ||
320 | m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); | ||
321 | |||
322 | // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code | ||
323 | // so that stat numbers are always consistent. | ||
324 | CheckStatSanity(); | ||
283 | 325 | ||
284 | // other MS is actually simulation time | 326 | // other MS is actually simulation time |
285 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; | 327 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
286 | // m_imageMS m_netMS are not included in m_frameMS | 328 | // m_imageMS m_netMS are not included in m_frameMS |
287 | 329 | ||
288 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; | 330 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS; |
289 | if (m_otherMS < 0) | 331 | if (m_otherMS < 0) |
290 | m_otherMS = 0; | 332 | m_otherMS = 0; |
291 | 333 | ||
292 | for (int i = 0; i < 23; i++) | 334 | uint thisFrame = m_scene.Frame; |
335 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | ||
336 | m_lastUpdateFrame = thisFrame; | ||
337 | |||
338 | // Avoid div-by-zero if somehow we've not updated any frames. | ||
339 | if (framesUpdated == 0) | ||
340 | framesUpdated = 1; | ||
341 | |||
342 | for (int i = 0; i < 22; i++) | ||
293 | { | 343 | { |
294 | sb[i] = new SimStatsPacket.StatBlock(); | 344 | sb[i] = new SimStatsPacket.StatBlock(); |
295 | } | 345 | } |
@@ -298,13 +348,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
298 | sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); | 348 | sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); |
299 | 349 | ||
300 | sb[1].StatID = (uint) Stats.SimFPS; | 350 | sb[1].StatID = (uint) Stats.SimFPS; |
301 | sb[1].StatValue = reportedFPS / statsUpdateFactor; | 351 | sb[1].StatValue = reportedFPS / m_statsUpdateFactor; |
302 | 352 | ||
303 | sb[2].StatID = (uint) Stats.PhysicsFPS; | 353 | sb[2].StatID = (uint) Stats.PhysicsFPS; |
304 | sb[2].StatValue = physfps / statsUpdateFactor; | 354 | sb[2].StatValue = physfps / m_statsUpdateFactor; |
305 | 355 | ||
306 | sb[3].StatID = (uint) Stats.AgentUpdates; | 356 | sb[3].StatID = (uint) Stats.AgentUpdates; |
307 | sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); | 357 | sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor); |
308 | 358 | ||
309 | sb[4].StatID = (uint) Stats.Agents; | 359 | sb[4].StatID = (uint) Stats.Agents; |
310 | sb[4].StatValue = m_rootAgents; | 360 | sb[4].StatValue = m_rootAgents; |
@@ -319,38 +369,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
319 | sb[7].StatValue = m_activePrim; | 369 | sb[7].StatValue = m_activePrim; |
320 | 370 | ||
321 | sb[8].StatID = (uint)Stats.FrameMS; | 371 | sb[8].StatID = (uint)Stats.FrameMS; |
322 | // sb[8].StatValue = m_frameMS / statsUpdateFactor; | 372 | sb[8].StatValue = m_frameMS / framesUpdated; |
323 | sb[8].StatValue = TotalFrameTime; | ||
324 | 373 | ||
325 | sb[9].StatID = (uint)Stats.NetMS; | 374 | sb[9].StatID = (uint)Stats.NetMS; |
326 | // sb[9].StatValue = m_netMS / statsUpdateFactor; | 375 | sb[9].StatValue = m_netMS / framesUpdated; |
327 | sb[9].StatValue = m_netMS * perframe; | ||
328 | 376 | ||
329 | sb[10].StatID = (uint)Stats.PhysicsMS; | 377 | sb[10].StatID = (uint)Stats.PhysicsMS; |
330 | // sb[10].StatValue = m_physicsMS / statsUpdateFactor; | 378 | sb[10].StatValue = m_physicsMS / framesUpdated; |
331 | sb[10].StatValue = m_physicsMS * perframe; | ||
332 | 379 | ||
333 | sb[11].StatID = (uint)Stats.ImageMS ; | 380 | sb[11].StatID = (uint)Stats.ImageMS ; |
334 | // sb[11].StatValue = m_imageMS / statsUpdateFactor; | 381 | sb[11].StatValue = m_imageMS / framesUpdated; |
335 | sb[11].StatValue = m_imageMS * perframe; | ||
336 | 382 | ||
337 | sb[12].StatID = (uint)Stats.OtherMS; | 383 | sb[12].StatID = (uint)Stats.OtherMS; |
338 | // sb[12].StatValue = m_otherMS / statsUpdateFactor; | 384 | sb[12].StatValue = m_otherMS / framesUpdated; |
339 | sb[12].StatValue = m_otherMS * perframe; | ||
340 | |||
341 | 385 | ||
342 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 386 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
343 | sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); | 387 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
344 | 388 | ||
345 | sb[14].StatID = (uint)Stats.OutPacketsPerSecond; | 389 | sb[14].StatID = (uint)Stats.OutPacketsPerSecond; |
346 | sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); | 390 | sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor); |
347 | 391 | ||
348 | sb[15].StatID = (uint)Stats.UnAckedBytes; | 392 | sb[15].StatID = (uint)Stats.UnAckedBytes; |
349 | sb[15].StatValue = m_unAckedBytes; | 393 | sb[15].StatValue = m_unAckedBytes; |
350 | 394 | ||
351 | sb[16].StatID = (uint)Stats.AgentMS; | 395 | sb[16].StatID = (uint)Stats.AgentMS; |
352 | // sb[16].StatValue = m_agentMS / statsUpdateFactor; | 396 | sb[16].StatValue = m_agentMS / framesUpdated; |
353 | sb[16].StatValue = m_agentMS * perframe; | ||
354 | 397 | ||
355 | sb[17].StatID = (uint)Stats.PendingDownloads; | 398 | sb[17].StatID = (uint)Stats.PendingDownloads; |
356 | sb[17].StatValue = m_pendingDownloads; | 399 | sb[17].StatValue = m_pendingDownloads; |
@@ -362,15 +405,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
362 | sb[19].StatValue = m_activeScripts; | 405 | sb[19].StatValue = m_activeScripts; |
363 | 406 | ||
364 | sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; | 407 | sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; |
365 | sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; | 408 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
366 | 409 | ||
367 | sb[21].StatID = (uint)Stats.SimSpareTime; | 410 | sb[21].StatID = (uint)Stats.SimSpareMs; |
368 | sb[21].StatValue = sparetime; | 411 | sb[21].StatValue = m_spareMS / framesUpdated; |
369 | 412 | ||
370 | sb[22].StatID = (uint)Stats.SimSleepTime; | 413 | for (int i = 0; i < 22; i++) |
371 | sb[22].StatValue = sleeptime; | ||
372 | |||
373 | for (int i = 0; i < 23; i++) | ||
374 | { | 414 | { |
375 | lastReportedSimStats[i] = sb[i].StatValue; | 415 | lastReportedSimStats[i] = sb[i].StatValue; |
376 | } | 416 | } |
@@ -387,13 +427,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
387 | } | 427 | } |
388 | 428 | ||
389 | // Extra statistics that aren't currently sent to clients | 429 | // Extra statistics that aren't currently sent to clients |
390 | LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor; | 430 | lock (m_lastReportedExtraSimStats) |
431 | { | ||
432 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | ||
433 | |||
434 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
435 | |||
436 | if (physicsStats != null) | ||
437 | { | ||
438 | foreach (KeyValuePair<string, float> tuple in physicsStats) | ||
439 | { | ||
440 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | ||
441 | // Need to change things so that stats source can indicate whether they are per second or | ||
442 | // per frame. | ||
443 | if (tuple.Key.EndsWith("MS")) | ||
444 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | ||
445 | else | ||
446 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
447 | } | ||
448 | } | ||
449 | } | ||
391 | 450 | ||
392 | resetvalues(); | 451 | ResetValues(); |
393 | } | 452 | } |
394 | } | 453 | } |
395 | 454 | ||
396 | private void resetvalues() | 455 | private void ResetValues() |
397 | { | 456 | { |
398 | m_timeDilation = 0; | 457 | m_timeDilation = 0; |
399 | m_fps = 0; | 458 | m_fps = 0; |
@@ -411,7 +470,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
411 | m_physicsMS = 0; | 470 | m_physicsMS = 0; |
412 | m_imageMS = 0; | 471 | m_imageMS = 0; |
413 | m_otherMS = 0; | 472 | m_otherMS = 0; |
414 | m_sleeptimeMS = 0; | 473 | m_spareMS = 0; |
415 | 474 | ||
416 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 475 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
417 | //Ckrinke m_scriptMS = 0; | 476 | //Ckrinke m_scriptMS = 0; |
@@ -433,13 +492,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
433 | m_timeDilation = td; | 492 | m_timeDilation = td; |
434 | } | 493 | } |
435 | 494 | ||
436 | public void SetRootAgents(int rootAgents) | ||
437 | { | ||
438 | m_rootAgents = rootAgents; | ||
439 | CheckStatSanity(); | ||
440 | |||
441 | } | ||
442 | |||
443 | internal void CheckStatSanity() | 495 | internal void CheckStatSanity() |
444 | { | 496 | { |
445 | if (m_rootAgents < 0 || m_childAgents < 0) | 497 | if (m_rootAgents < 0 || m_childAgents < 0) |
@@ -456,22 +508,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
456 | } | 508 | } |
457 | } | 509 | } |
458 | 510 | ||
459 | public void SetChildAgents(int childAgents) | ||
460 | { | ||
461 | m_childAgents = childAgents; | ||
462 | CheckStatSanity(); | ||
463 | } | ||
464 | |||
465 | public void SetObjects(int objects) | ||
466 | { | ||
467 | m_numPrim = objects; | ||
468 | } | ||
469 | |||
470 | public void SetActiveObjects(int objects) | ||
471 | { | ||
472 | m_activePrim = objects; | ||
473 | } | ||
474 | |||
475 | public void AddFPS(int frames) | 511 | public void AddFPS(int frames) |
476 | { | 512 | { |
477 | m_fps += frames; | 513 | m_fps += frames; |
@@ -513,6 +549,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
513 | m_frameMS += ms; | 549 | m_frameMS += ms; |
514 | } | 550 | } |
515 | 551 | ||
552 | public void AddSpareMS(int ms) | ||
553 | { | ||
554 | m_spareMS += ms; | ||
555 | } | ||
556 | |||
516 | public void addNetMS(int ms) | 557 | public void addNetMS(int ms) |
517 | { | 558 | { |
518 | m_netMS += ms; | 559 | m_netMS += ms; |
@@ -538,15 +579,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
538 | m_otherMS += ms; | 579 | m_otherMS += ms; |
539 | } | 580 | } |
540 | 581 | ||
541 | public void addSleepMS(int ms) | ||
542 | { | ||
543 | m_sleeptimeMS += ms; | ||
544 | } | ||
545 | |||
546 | public void AddPendingDownloads(int count) | 582 | public void AddPendingDownloads(int count) |
547 | { | 583 | { |
548 | m_pendingDownloads += count; | 584 | m_pendingDownloads += count; |
549 | if (m_pendingDownloads < 0) m_pendingDownloads = 0; | 585 | |
586 | if (m_pendingDownloads < 0) | ||
587 | m_pendingDownloads = 0; | ||
588 | |||
550 | //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); | 589 | //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); |
551 | } | 590 | } |
552 | 591 | ||
@@ -555,11 +594,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
555 | m_scriptLinesPerSecond += count; | 594 | m_scriptLinesPerSecond += count; |
556 | } | 595 | } |
557 | 596 | ||
558 | public void SetActiveScripts(int count) | ||
559 | { | ||
560 | m_activeScripts = count; | ||
561 | } | ||
562 | |||
563 | public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) | 597 | public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) |
564 | { | 598 | { |
565 | AddInPackets(inPackets); | 599 | AddInPackets(inPackets); |
@@ -568,5 +602,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
568 | } | 602 | } |
569 | 603 | ||
570 | #endregion | 604 | #endregion |
605 | |||
606 | public Dictionary<string, float> GetExtraSimStats() | ||
607 | { | ||
608 | lock (m_lastReportedExtraSimStats) | ||
609 | return new Dictionary<string, float>(m_lastReportedExtraSimStats); | ||
610 | } | ||
571 | } | 611 | } |
572 | } | 612 | } |