diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | 92 |
1 files changed, 73 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index bd60611..ad1c4ce 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
80 | 80 | ||
81 | MainConsole.Instance.Commands.AddCommand( | 81 | MainConsole.Instance.Commands.AddCommand( |
82 | "Comms", false, "show caps stats by user", | 82 | "Comms", false, "show caps stats by user", |
83 | "show caps stats [<first-name> <last-name>]", | 83 | "show caps stats by user [<first-name> <last-name>]", |
84 | "Shows statistics on capabilities use by user.", | 84 | "Shows statistics on capabilities use by user.", |
85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", | 85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", |
86 | HandleShowCapsStatsByUserCommand); | 86 | HandleShowCapsStatsByUserCommand); |
@@ -285,27 +285,31 @@ namespace OpenSim.Region.CoreModules.Framework | |||
285 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | 285 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
286 | return; | 286 | return; |
287 | 287 | ||
288 | StringBuilder caps = new StringBuilder(); | 288 | StringBuilder capsReport = new StringBuilder(); |
289 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 289 | capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); |
290 | 290 | ||
291 | lock (m_capsObjects) | 291 | lock (m_capsObjects) |
292 | { | 292 | { |
293 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) | 293 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) |
294 | { | 294 | { |
295 | caps.AppendFormat("** User {0}:\n", kvp.Key); | 295 | capsReport.AppendFormat("** User {0}:\n", kvp.Key); |
296 | Caps caps = kvp.Value; | ||
296 | 297 | ||
297 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 298 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) |
298 | { | 299 | { |
299 | Uri uri = new Uri(kvp2.Value.ToString()); | 300 | Uri uri = new Uri(kvp2.Value.ToString()); |
300 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | 301 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); |
301 | } | 302 | } |
302 | 303 | ||
303 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | 304 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers()) |
304 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | 305 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url); |
306 | |||
307 | foreach (KeyValuePair<string, string> kvp3 in caps.ExternalCapsHandlers) | ||
308 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
305 | } | 309 | } |
306 | } | 310 | } |
307 | 311 | ||
308 | MainConsole.Instance.Output(caps.ToString()); | 312 | MainConsole.Instance.Output(capsReport.ToString()); |
309 | } | 313 | } |
310 | 314 | ||
311 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) | 315 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) |
@@ -362,7 +366,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
362 | { | 366 | { |
363 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | 367 | receivedStats[sp.Name] = reqHandler.RequestsReceived; |
364 | handledStats[sp.Name] = reqHandler.RequestsHandled; | 368 | handledStats[sp.Name] = reqHandler.RequestsHandled; |
365 | } | 369 | } |
370 | else | ||
371 | { | ||
372 | PollServiceEventArgs pollHandler = null; | ||
373 | if (caps.TryGetPollHandler(capName, out pollHandler)) | ||
374 | { | ||
375 | receivedStats[sp.Name] = pollHandler.RequestsReceived; | ||
376 | handledStats[sp.Name] = pollHandler.RequestsHandled; | ||
377 | } | ||
378 | } | ||
366 | } | 379 | } |
367 | ); | 380 | ); |
368 | 381 | ||
@@ -391,11 +404,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
391 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | 404 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
392 | 405 | ||
393 | if (caps == null) | 406 | if (caps == null) |
394 | return; | 407 | return; |
395 | |||
396 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
397 | 408 | ||
398 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | 409 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
399 | { | 410 | { |
400 | string reqName = reqHandler.Name ?? ""; | 411 | string reqName = reqHandler.Name ?? ""; |
401 | 412 | ||
@@ -410,6 +421,23 @@ namespace OpenSim.Region.CoreModules.Framework | |||
410 | handledStats[reqName] += reqHandler.RequestsHandled; | 421 | handledStats[reqName] += reqHandler.RequestsHandled; |
411 | } | 422 | } |
412 | } | 423 | } |
424 | |||
425 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) | ||
426 | { | ||
427 | string name = kvp.Key; | ||
428 | PollServiceEventArgs pollHandler = kvp.Value; | ||
429 | |||
430 | if (!receivedStats.ContainsKey(name)) | ||
431 | { | ||
432 | receivedStats[name] = pollHandler.RequestsReceived; | ||
433 | handledStats[name] = pollHandler.RequestsHandled; | ||
434 | } | ||
435 | else | ||
436 | { | ||
437 | receivedStats[name] += pollHandler.RequestsReceived; | ||
438 | handledStats[name] += pollHandler.RequestsHandled; | ||
439 | } | ||
440 | } | ||
413 | } | 441 | } |
414 | ); | 442 | ); |
415 | 443 | ||
@@ -468,12 +496,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
468 | if (caps == null) | 496 | if (caps == null) |
469 | return; | 497 | return; |
470 | 498 | ||
471 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | 499 | List<CapTableRow> capRows = new List<CapTableRow>(); |
472 | 500 | ||
473 | foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived)) | 501 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
474 | { | 502 | capRows.Add(new CapTableRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled)); |
475 | cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled); | 503 | |
476 | } | 504 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) |
505 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); | ||
506 | |||
507 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) | ||
508 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); | ||
477 | 509 | ||
478 | sb.Append(cdt.ToString()); | 510 | sb.Append(cdt.ToString()); |
479 | } | 511 | } |
@@ -505,6 +537,14 @@ namespace OpenSim.Region.CoreModules.Framework | |||
505 | totalRequestsReceived += reqHandler.RequestsReceived; | 537 | totalRequestsReceived += reqHandler.RequestsReceived; |
506 | totalRequestsHandled += reqHandler.RequestsHandled; | 538 | totalRequestsHandled += reqHandler.RequestsHandled; |
507 | } | 539 | } |
540 | |||
541 | Dictionary<string, PollServiceEventArgs> capsPollHandlers = caps.GetPollHandlers(); | ||
542 | |||
543 | foreach (PollServiceEventArgs handler in capsPollHandlers.Values) | ||
544 | { | ||
545 | totalRequestsReceived += handler.RequestsReceived; | ||
546 | totalRequestsHandled += handler.RequestsHandled; | ||
547 | } | ||
508 | 548 | ||
509 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | 549 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); |
510 | } | 550 | } |
@@ -512,5 +552,19 @@ namespace OpenSim.Region.CoreModules.Framework | |||
512 | 552 | ||
513 | sb.Append(cdt.ToString()); | 553 | sb.Append(cdt.ToString()); |
514 | } | 554 | } |
555 | |||
556 | private class CapTableRow | ||
557 | { | ||
558 | public string Name { get; set; } | ||
559 | public int RequestsReceived { get; set; } | ||
560 | public int RequestsHandled { get; set; } | ||
561 | |||
562 | public CapTableRow(string name, int requestsReceived, int requestsHandled) | ||
563 | { | ||
564 | Name = name; | ||
565 | RequestsReceived = requestsReceived; | ||
566 | RequestsHandled = requestsHandled; | ||
567 | } | ||
568 | } | ||
515 | } | 569 | } |
516 | } \ No newline at end of file | 570 | } \ No newline at end of file |