aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SimStatsReporter.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SimStatsReporter.cs274
1 files changed, 135 insertions, 139 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
index 1f02f23..a53bfcd 100644
--- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
@@ -34,68 +34,105 @@ namespace OpenSim.Region.Environment.Scenes
34{ 34{
35 public class SimStatsReporter 35 public class SimStatsReporter
36 { 36 {
37 #region Delegates
38
39 public delegate void SendStatResult(SimStatsPacket pack); 37 public delegate void SendStatResult(SimStatsPacket pack);
40 38
41 #endregion 39 public event SendStatResult OnSendStatsResult;
42 40
43 private readonly Timer m_report = new Timer(); 41 private SendStatResult handlerSendStatResult = null;
44 private readonly SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
45 private readonly RegionInfo ReportingRegion;
46 private readonly SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
47 private readonly SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
48
49 private SendStatResult handlerSendStatResult;
50 private int m_activePrim;
51 private int m_activeScripts;
52 private int m_agentMS;
53
54 private int m_agentUpdates;
55 private int m_childAgents;
56 private int m_fps;
57
58 private int m_frameMS;
59 private int m_imageMS;
60 private int m_inPacketsPerSecond;
61 private int m_netMS;
62 private int m_numPrim;
63 private int m_otherMS;
64 private int m_outPacketsPerSecond;
65 private int m_pendingDownloads;
66 private int m_pendingUploads;
67 private float m_pfps;
68 private int m_physicsMS;
69 private int m_rootAgents;
70 private int m_scriptLinesPerSecond;
71 private float m_timeDilation;
72 private int m_unAckedBytes;
73 42
74 private int objectCapacity = 45000; 43 private enum Stats : uint
75 private float statsUpdateFactor; 44 {
45 TimeDilation = 0,
46 SimFPS = 1,
47 PhysicsFPS = 2,
48 AgentUpdates = 3,
49 FrameMS = 4,
50 NetMS = 5,
51 OtherMS = 6,
52 PhysicsMS = 7,
53 AgentMS = 8,
54 ImageMS = 9,
55 ScriptMS = 10,
56 TotalPrim = 11,
57 ActivePrim = 12,
58 Agents = 13,
59 ChildAgents = 14,
60 ActiveScripts = 15,
61 ScriptLinesPerSecond = 16,
62 InPacketsPerSecond = 17,
63 OutPacketsPerSecond = 18,
64 PendingDownloads = 19,
65 PendingUploads = 20,
66 UnAckedBytes = 24,
67
68 // Havok4 related... May or may not be in upcoming LLclients
69 // (kelly added them sometime late in January 2008)
70 NumRCCSLODReduced = 25,
71 NumRCCSFixed = 26
72 }
73
74 // Sending a stats update every 3 seconds
76 private int statsUpdatesEveryMS = 3000; 75 private int statsUpdatesEveryMS = 3000;
76 private float statsUpdateFactor = 0;
77 private float m_timeDilation = 0;
78 private int m_fps = 0;
79 private float m_pfps = 0;
80 private int m_agentUpdates = 0;
81
82 private int m_frameMS = 0;
83 private int m_netMS = 0;
84 private int m_agentMS = 0;
85 private int m_physicsMS = 0;
86 private int m_imageMS = 0;
87 private int m_otherMS = 0;
88
89//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
90//Ckrinke private int m_scriptMS = 0;
91
92 private int m_rootAgents = 0;
93 private int m_childAgents = 0;
94 private int m_numPrim = 0;
95 private int m_inPacketsPerSecond = 0;
96 private int m_outPacketsPerSecond = 0;
97 private int m_activePrim = 0;
98 private int m_unAckedBytes = 0;
99 private int m_pendingDownloads = 0;
100 private int m_pendingUploads = 0;
101 private int m_activeScripts = 0;
102 private int m_scriptLinesPerSecond = 0;
103
104 private int objectCapacity = 45000;
105
106
107 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
108 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
109 SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats);
110
111
112 private RegionInfo ReportingRegion;
113
114 private Timer m_report = new Timer();
77 115
78 116
79 public SimStatsReporter(RegionInfo regionData) 117 public SimStatsReporter(RegionInfo regionData)
80 { 118 {
81 statsUpdateFactor = (statsUpdatesEveryMS / 1000); 119
120 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
82 ReportingRegion = regionData; 121 ReportingRegion = regionData;
83 for (int i = 0; i < 21; i++) 122 for (int i = 0; i<21;i++)
84 { 123 {
85 sb[i] = new SimStatsPacket.StatBlock(); 124 sb[i] = new SimStatsPacket.StatBlock();
86 } 125 }
87 m_report.AutoReset = true; 126 m_report.AutoReset = true;
88 m_report.Interval = statsUpdatesEveryMS; 127 m_report.Interval = statsUpdatesEveryMS;
89 m_report.Elapsed += statsHeartBeat; 128 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
90 m_report.Enabled = true; 129 m_report.Enabled = true;
91 } 130 }
92 131
93 public event SendStatResult OnSendStatsResult;
94
95 public void SetUpdateMS(int ms) 132 public void SetUpdateMS(int ms)
96 { 133 {
97 statsUpdatesEveryMS = ms; 134 statsUpdatesEveryMS = ms;
98 statsUpdateFactor = (statsUpdatesEveryMS / 1000); 135 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
99 m_report.Interval = statsUpdatesEveryMS; 136 m_report.Interval = statsUpdatesEveryMS;
100 } 137 }
101 138
@@ -106,8 +143,8 @@ namespace OpenSim.Region.Environment.Scenes
106 lock (m_report) 143 lock (m_report)
107 { 144 {
108 // Packet is already initialized and ready for data insert 145 // Packet is already initialized and ready for data insert
109 146
110 147
111 statpack.Region = rb; 148 statpack.Region = rb;
112 statpack.Region.RegionX = ReportingRegion.RegionLocX; 149 statpack.Region.RegionX = ReportingRegion.RegionLocX;
113 statpack.Region.RegionY = ReportingRegion.RegionLocY; 150 statpack.Region.RegionY = ReportingRegion.RegionLocY;
@@ -117,102 +154,102 @@ namespace OpenSim.Region.Environment.Scenes
117 } 154 }
118 catch (Exception) 155 catch (Exception)
119 { 156 {
120 statpack.Region.RegionFlags = 0; 157 statpack.Region.RegionFlags = (uint) 0;
121 } 158 }
122 statpack.Region.ObjectCapacity = (uint) objectCapacity; 159 statpack.Region.ObjectCapacity = (uint) objectCapacity;
123 160
124 #region various statistic googly moogly 161#region various statistic googly moogly
125 162
126 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there 163 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
127 // 0-50 is pretty close to 0-45 164 // 0-50 is pretty close to 0-45
128 float simfps = ((m_fps * 5)); 165 float simfps = (int) ((m_fps * 5));
129 166
130 //if (simfps > 45) 167 //if (simfps > 45)
131 //simfps = simfps - (simfps - 45); 168 //simfps = simfps - (simfps - 45);
132 //if (simfps < 0) 169 //if (simfps < 0)
133 //simfps = 0; 170 //simfps = 0;
134 171
135 // 172 //
136 float physfps = ((m_pfps / 1000)); 173 float physfps = ((m_pfps / 1000));
137 174
138 //if (physfps > 600) 175 //if (physfps > 600)
139 //physfps = physfps - (physfps - 600); 176 //physfps = physfps - (physfps - 600);
140 177
141 if (physfps < 0) 178 if (physfps < 0)
142 physfps = 0; 179 physfps = 0;
143 180
144 #endregion 181#endregion
145 182
146 //Our time dilation is 0.91 when we're running a full speed, 183 //Our time dilation is 0.91 when we're running a full speed,
147 // therefore to make sure we get an appropriate range, 184 // therefore to make sure we get an appropriate range,
148 // we have to factor in our error. (0.10f * statsUpdateFactor) 185 // we have to factor in our error. (0.10f * statsUpdateFactor)
149 // multiplies the fix for the error times the amount of times it'll occur a second 186 // multiplies the fix for the error times the amount of times it'll occur a second
150 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 187 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
151 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 188 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
152 189
153 sb[0].StatID = (uint) Stats.TimeDilation; 190 sb[0].StatID = (uint) Stats.TimeDilation;
154 sb[0].StatValue = m_timeDilation; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 191 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
155 192
156 sb[1].StatID = (uint) Stats.SimFPS; 193 sb[1].StatID = (uint) Stats.SimFPS;
157 sb[1].StatValue = simfps / statsUpdateFactor; 194 sb[1].StatValue = simfps/statsUpdateFactor;
158 195
159 sb[2].StatID = (uint) Stats.PhysicsFPS; 196 sb[2].StatID = (uint) Stats.PhysicsFPS;
160 sb[2].StatValue = physfps / statsUpdateFactor; 197 sb[2].StatValue = physfps / statsUpdateFactor;
161 198
162 sb[3].StatID = (uint) Stats.AgentUpdates; 199 sb[3].StatID = (uint) Stats.AgentUpdates;
163 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 200 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);
164 201
165 sb[4].StatID = (uint) Stats.Agents; 202 sb[4].StatID = (uint) Stats.Agents;
166 sb[4].StatValue = m_rootAgents; 203 sb[4].StatValue = m_rootAgents;
167 204
168 sb[5].StatID = (uint) Stats.ChildAgents; 205 sb[5].StatID = (uint) Stats.ChildAgents;
169 sb[5].StatValue = m_childAgents; 206 sb[5].StatValue = m_childAgents;
170 207
171 sb[6].StatID = (uint) Stats.TotalPrim; 208 sb[6].StatID = (uint) Stats.TotalPrim;
172 sb[6].StatValue = m_numPrim; 209 sb[6].StatValue = m_numPrim;
173 210
174 sb[7].StatID = (uint) Stats.ActivePrim; 211 sb[7].StatID = (uint) Stats.ActivePrim;
175 sb[7].StatValue = m_activePrim; 212 sb[7].StatValue = m_activePrim;
176 213
177 sb[8].StatID = (uint) Stats.FrameMS; 214 sb[8].StatID = (uint)Stats.FrameMS;
178 sb[8].StatValue = m_frameMS / statsUpdateFactor; 215 sb[8].StatValue = m_frameMS / statsUpdateFactor;
179 216
180 sb[9].StatID = (uint) Stats.NetMS; 217 sb[9].StatID = (uint)Stats.NetMS;
181 sb[9].StatValue = m_netMS / statsUpdateFactor; 218 sb[9].StatValue = m_netMS / statsUpdateFactor;
182 219
183 sb[10].StatID = (uint) Stats.PhysicsMS; 220 sb[10].StatID = (uint)Stats.PhysicsMS;
184 sb[10].StatValue = m_physicsMS / statsUpdateFactor; 221 sb[10].StatValue = m_physicsMS / statsUpdateFactor;
185 222
186 sb[11].StatID = (uint) Stats.ImageMS; 223 sb[11].StatID = (uint)Stats.ImageMS ;
187 sb[11].StatValue = m_imageMS / statsUpdateFactor; 224 sb[11].StatValue = m_imageMS / statsUpdateFactor;
188 225
189 sb[12].StatID = (uint) Stats.OtherMS; 226 sb[12].StatID = (uint)Stats.OtherMS;
190 sb[12].StatValue = m_otherMS / statsUpdateFactor; 227 sb[12].StatValue = m_otherMS / statsUpdateFactor;
191 228
192 sb[13].StatID = (uint) Stats.InPacketsPerSecond; 229 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
193 sb[13].StatValue = (m_inPacketsPerSecond); 230 sb[13].StatValue = (m_inPacketsPerSecond);
194 231
195 sb[14].StatID = (uint) Stats.OutPacketsPerSecond; 232 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
196 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 233 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
197 234
198 sb[15].StatID = (uint) Stats.UnAckedBytes; 235 sb[15].StatID = (uint)Stats.UnAckedBytes;
199 sb[15].StatValue = m_unAckedBytes; 236 sb[15].StatValue = m_unAckedBytes;
200 237
201 sb[16].StatID = (uint) Stats.AgentMS; 238 sb[16].StatID = (uint)Stats.AgentMS;
202 sb[16].StatValue = m_agentMS / statsUpdateFactor; 239 sb[16].StatValue = m_agentMS / statsUpdateFactor;
203 240
204 sb[17].StatID = (uint) Stats.PendingDownloads; 241 sb[17].StatID = (uint)Stats.PendingDownloads;
205 sb[17].StatValue = m_pendingDownloads; 242 sb[17].StatValue = m_pendingDownloads;
206 243
207 sb[18].StatID = (uint) Stats.PendingUploads; 244 sb[18].StatID = (uint)Stats.PendingUploads;
208 sb[18].StatValue = m_pendingUploads; 245 sb[18].StatValue = m_pendingUploads;
209 246
210 sb[19].StatID = (uint) Stats.ActiveScripts; 247 sb[19].StatID = (uint)Stats.ActiveScripts;
211 sb[19].StatValue = m_activeScripts; 248 sb[19].StatValue = m_activeScripts;
212 249
213 sb[20].StatID = (uint) Stats.ScriptLinesPerSecond; 250 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
214 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 251 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
215 252
216 statpack.Stat = sb; 253 statpack.Stat = sb;
217 254
218 handlerSendStatResult = OnSendStatsResult; 255 handlerSendStatResult = OnSendStatsResult;
@@ -223,7 +260,7 @@ namespace OpenSim.Region.Environment.Scenes
223 resetvalues(); 260 resetvalues();
224 } 261 }
225 } 262 }
226 263
227 private void resetvalues() 264 private void resetvalues()
228 { 265 {
229 m_timeDilation = 0; 266 m_timeDilation = 0;
@@ -247,7 +284,6 @@ namespace OpenSim.Region.Environment.Scenes
247 } 284 }
248 285
249 # region methods called from Scene 286 # region methods called from Scene
250
251 // The majority of these functions are additive 287 // The majority of these functions are additive
252 // so that you can easily change the amount of 288 // so that you can easily change the amount of
253 // seconds in between sim stats updates 289 // seconds in between sim stats updates
@@ -256,10 +292,10 @@ namespace OpenSim.Region.Environment.Scenes
256 { 292 {
257 //float tdsetting = td; 293 //float tdsetting = td;
258 //if (tdsetting > 1.0f) 294 //if (tdsetting > 1.0f)
259 //tdsetting = (tdsetting - (tdsetting - 0.91f)); 295 //tdsetting = (tdsetting - (tdsetting - 0.91f));
260 296
261 //if (tdsetting < 0) 297 //if (tdsetting < 0)
262 //tdsetting = 0.0f; 298 //tdsetting = 0.0f;
263 m_timeDilation = td; 299 m_timeDilation = td;
264 } 300 }
265 301
@@ -317,35 +353,30 @@ namespace OpenSim.Region.Environment.Scenes
317 { 353 {
318 m_frameMS += ms; 354 m_frameMS += ms;
319 } 355 }
320
321 public void addNetMS(int ms) 356 public void addNetMS(int ms)
322 { 357 {
323 m_netMS += ms; 358 m_netMS += ms;
324 } 359 }
325
326 public void addAgentMS(int ms) 360 public void addAgentMS(int ms)
327 { 361 {
328 m_agentMS += ms; 362 m_agentMS += ms;
329 } 363 }
330
331 public void addPhysicsMS(int ms) 364 public void addPhysicsMS(int ms)
332 { 365 {
333 m_physicsMS += ms; 366 m_physicsMS += ms;
334 } 367 }
335
336 public void addImageMS(int ms) 368 public void addImageMS(int ms)
337 { 369 {
338 m_imageMS += ms; 370 m_imageMS += ms;
339 } 371 }
340
341 public void addOtherMS(int ms) 372 public void addOtherMS(int ms)
342 { 373 {
343 m_otherMS += ms; 374 m_otherMS += ms;
344 } 375 }
345 376
346// private static readonly log4net.ILog m_log 377// private static readonly log4net.ILog m_log
347// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 378// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
348 379
349 public void addPendingDownload(int count) 380 public void addPendingDownload(int count)
350 { 381 {
351 m_pendingDownloads += count; 382 m_pendingDownloads += count;
@@ -368,40 +399,5 @@ namespace OpenSim.Region.Environment.Scenes
368 } 399 }
369 400
370 #endregion 401 #endregion
371
372 #region Nested type: Stats
373
374 private enum Stats : uint
375 {
376 TimeDilation = 0,
377 SimFPS = 1,
378 PhysicsFPS = 2,
379 AgentUpdates = 3,
380 FrameMS = 4,
381 NetMS = 5,
382 OtherMS = 6,
383 PhysicsMS = 7,
384 AgentMS = 8,
385 ImageMS = 9,
386 ScriptMS = 10,
387 TotalPrim = 11,
388 ActivePrim = 12,
389 Agents = 13,
390 ChildAgents = 14,
391 ActiveScripts = 15,
392 ScriptLinesPerSecond = 16,
393 InPacketsPerSecond = 17,
394 OutPacketsPerSecond = 18,
395 PendingDownloads = 19,
396 PendingUploads = 20,
397 UnAckedBytes = 24,
398
399 // Havok4 related... May or may not be in upcoming LLclients
400 // (kelly added them sometime late in January 2008)
401 NumRCCSLODReduced = 25,
402 NumRCCSFixed = 26
403 }
404
405 #endregion
406 } 402 }
407} \ No newline at end of file 403}