Add "show caps stats by user" and "show caps stats by cap" console commands to print various counts of capability invocation by user and by cap
This currently prints caps requests received and handled, so that overload of received compared to handled or deadlock can be detected. This involves making BaseStreamHandler and BaseOutputStream record the ints, which means inheritors should subclass ProcessRequest() instead of Handle() However, existing inheriting classes overriding Handle() will still work, albeit without stats recording. "show caps" becomes "show caps list" to disambiguate between show caps commandscpu-performance
parent
a38c2abae4
commit
e19defde36
|
@ -113,7 +113,7 @@ namespace OpenSim.Groups
|
|||
m_GroupsService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace OpenSim.Groups
|
|||
m_GroupsService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace OpenSim.OfflineIM
|
|||
m_OfflineIMService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace OpenSim.Framework.Capabilities
|
|||
/// </summary>
|
||||
public class CapsHandlers
|
||||
{
|
||||
private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
|
||||
private Dictionary<string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
|
||||
private IHttpServer m_httpListener;
|
||||
private string m_httpListenerHostName;
|
||||
private uint m_httpListenerPort;
|
||||
|
@ -184,5 +184,17 @@ namespace OpenSim.Framework.Capabilities
|
|||
|
||||
return caps;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the dictionary of all the HTTP cap handlers
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The dictionary copy. The key is the capability name, the value is the HTTP handler.
|
||||
/// </returns>
|
||||
public Dictionary<string, IRequestHandler> GetCapsHandlers()
|
||||
{
|
||||
lock (m_capsHandlers)
|
||||
return new Dictionary<string, IRequestHandler>(m_capsHandlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Capabilities.Handlers
|
|||
m_PeopleService = peopleService;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace OpenSim.Capabilities.Handlers
|
|||
m_assetService = assService;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Capabilities
|
|||
m_method = method;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
//Encoding encoding = Util.UTF8;
|
||||
|
|
|
@ -31,6 +31,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
{
|
||||
public abstract class BaseRequestHandler
|
||||
{
|
||||
public int RequestsReceived { get; protected set; }
|
||||
|
||||
public int RequestsHandled { get; protected set; }
|
||||
|
||||
public virtual string ContentType
|
||||
{
|
||||
get { return "application/xml"; }
|
||||
|
|
|
@ -29,14 +29,35 @@ using System.IO;
|
|||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Base streamed request handler.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inheriting classes should override ProcessRequest() rather than Handle()
|
||||
/// </remarks>
|
||||
public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler
|
||||
{
|
||||
public abstract byte[] Handle(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
|
||||
|
||||
protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
|
||||
|
||||
protected BaseStreamHandler(string httpMethod, string path, string name, string description)
|
||||
: base(httpMethod, path, name, description) {}
|
||||
|
||||
public virtual byte[] Handle(
|
||||
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
RequestsReceived++;
|
||||
|
||||
byte[] result = ProcessRequest(path, request, httpRequest, httpResponse);
|
||||
|
||||
RequestsHandled++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected virtual byte[] ProcessRequest(
|
||||
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
m_method = binaryMethod;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
byte[] data = ReadFully(request);
|
||||
string param = GetParam(path);
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
{
|
||||
public interface IRequestHandler
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Name for this handler.
|
||||
/// </summary>
|
||||
|
@ -59,6 +58,19 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
|
||||
// Return path
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of requests received by this handler
|
||||
/// </summary>
|
||||
int RequestsReceived { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of requests handled.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Should be equal to RequestsReceived unless requested are being handled slowly or there is deadlock.
|
||||
/// </remarks>
|
||||
int RequestsHandled { get; }
|
||||
}
|
||||
|
||||
public interface IStreamedRequestHandler : IRequestHandler
|
||||
|
@ -69,7 +81,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
|
||||
public interface IStreamHandler : IRequestHandler
|
||||
{
|
||||
// Handle request stream, return byte array
|
||||
void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
{
|
||||
public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
|
||||
|
||||
public class RestDeserialiseHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
|
||||
public class RestDeserialiseHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
|
||||
where TRequest : new()
|
||||
{
|
||||
private RestDeserialiseMethod<TRequest, TResponse> m_method;
|
||||
|
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
m_method = method;
|
||||
}
|
||||
|
||||
public void Handle(string path, Stream request, Stream responseStream,
|
||||
protected override void ProcessRequest(string path, Stream request, Stream responseStream,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
TRequest deserial;
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
|
||||
public delegate bool CheckIdentityMethod(string sid, string aid);
|
||||
|
||||
public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
|
||||
public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
|
||||
where TRequest : new()
|
||||
{
|
||||
private static readonly ILog m_log
|
||||
|
@ -201,7 +201,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
m_method = method;
|
||||
}
|
||||
|
||||
public void Handle(string path, Stream request, Stream responseStream,
|
||||
protected override void ProcessRequest(string path, Stream request, Stream responseStream,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>);
|
||||
|
@ -237,7 +237,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
|
||||
public delegate bool CheckTrustedSourceMethod(IPEndPoint peer);
|
||||
|
||||
public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
|
||||
public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
|
||||
where TRequest : new()
|
||||
{
|
||||
private static readonly ILog m_log
|
||||
|
@ -260,7 +260,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
m_method = method;
|
||||
}
|
||||
|
||||
public void Handle(string path, Stream request, Stream responseStream,
|
||||
protected override void ProcessRequest(string path, Stream request, Stream responseStream,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
TRequest deserial = default(TRequest);
|
||||
|
@ -292,6 +292,5 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
serializer.Serialize(xmlWriter, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
|||
m_restMethod = restMethod;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
Encoding encoding = Encoding.UTF8;
|
||||
StreamReader streamReader = new StreamReader(request, encoding);
|
||||
|
|
|
@ -766,7 +766,7 @@ namespace OpenSim
|
|||
{
|
||||
public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return Util.UTF8.GetBytes("OK");
|
||||
|
@ -792,7 +792,7 @@ namespace OpenSim
|
|||
m_opensim = sim;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
|
||||
|
@ -810,7 +810,7 @@ namespace OpenSim
|
|||
/// If the request contains a key, "callback" the response will be wrappend in the
|
||||
/// associated value for jsonp used with ajax/javascript
|
||||
/// </summary>
|
||||
public class UXSimStatusHandler : BaseStreamHandler
|
||||
protected class UXSimStatusHandler : BaseStreamHandler
|
||||
{
|
||||
OpenSimBase m_opensim;
|
||||
|
||||
|
@ -820,7 +820,7 @@ namespace OpenSim
|
|||
m_opensim = sim;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_isGod = m_scene.Permissions.IsGod(agentID);
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader reader = new StreamReader(request);
|
||||
string message = reader.ReadToEnd();
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
|||
m_FriendsModule = fmodule;
|
||||
}
|
||||
|
||||
public override byte[] Handle(
|
||||
protected override byte[] ProcessRequest(
|
||||
string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
|
@ -37,6 +38,7 @@ using OpenMetaverse;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using Caps=OpenSim.Framework.Capabilities.Caps;
|
||||
|
@ -58,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>();
|
||||
|
||||
protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
|
||||
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
|
||||
= new Dictionary<UUID, Dictionary<ulong, string>>();
|
||||
|
||||
|
@ -70,9 +73,24 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Comms", false, "show caps",
|
||||
"show caps",
|
||||
"Shows all registered capabilities for users", HandleShowCapsCommand);
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Comms", false, "show caps list",
|
||||
"show caps list",
|
||||
"Shows list of registered capabilities for users.", HandleShowCapsListCommand);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Comms", false, "show caps stats by user",
|
||||
"show caps stats [<first-name> <last-name>]",
|
||||
"Shows statistics on capabilities use by user.",
|
||||
"If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.",
|
||||
HandleShowCapsStatsByUserCommand);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand(
|
||||
"Comms", false, "show caps stats by cap",
|
||||
"show caps stats by cap [<cap-name>]",
|
||||
"Shows statistics on capabilities use by capability.",
|
||||
"If a capability name is given, then prints a detailed breakdown of use by each user.",
|
||||
HandleShowCapsStatsByCapCommand);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
|
@ -262,8 +280,11 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
}
|
||||
}
|
||||
|
||||
private void HandleShowCapsCommand(string module, string[] cmdparams)
|
||||
private void HandleShowCapsListCommand(string module, string[] cmdParams)
|
||||
{
|
||||
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
|
||||
return;
|
||||
|
||||
StringBuilder caps = new StringBuilder();
|
||||
caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
|
||||
|
||||
|
@ -286,5 +307,210 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
|
||||
MainConsole.Instance.Output(caps.ToString());
|
||||
}
|
||||
|
||||
private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
|
||||
{
|
||||
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
|
||||
return;
|
||||
|
||||
if (cmdParams.Length != 5 && cmdParams.Length != 6)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]");
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("Region {0}:\n", m_scene.Name);
|
||||
|
||||
if (cmdParams.Length == 5)
|
||||
{
|
||||
BuildSummaryStatsByCapReport(sb);
|
||||
}
|
||||
else if (cmdParams.Length == 6)
|
||||
{
|
||||
BuildDetailedStatsByCapReport(sb, cmdParams[5]);
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(sb.ToString());
|
||||
}
|
||||
|
||||
private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
|
||||
{
|
||||
sb.AppendFormat("Capability name {0}\n", capName);
|
||||
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("User Name", 34);
|
||||
cdt.AddColumn("Req Received", 12);
|
||||
cdt.AddColumn("Req Handled", 12);
|
||||
cdt.Indent = 2;
|
||||
|
||||
Dictionary<string, int> receivedStats = new Dictionary<string, int>();
|
||||
Dictionary<string, int> handledStats = new Dictionary<string, int>();
|
||||
|
||||
m_scene.ForEachScenePresence(
|
||||
sp =>
|
||||
{
|
||||
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
|
||||
|
||||
if (caps == null)
|
||||
return;
|
||||
|
||||
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
|
||||
|
||||
IRequestHandler reqHandler;
|
||||
if (capsHandlers.TryGetValue(capName, out reqHandler))
|
||||
{
|
||||
receivedStats[sp.Name] = reqHandler.RequestsReceived;
|
||||
handledStats[sp.Name] = reqHandler.RequestsHandled;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
|
||||
{
|
||||
cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
|
||||
}
|
||||
|
||||
sb.Append(cdt.ToString());
|
||||
}
|
||||
|
||||
private void BuildSummaryStatsByCapReport(StringBuilder sb)
|
||||
{
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("Name", 34);
|
||||
cdt.AddColumn("Req Received", 12);
|
||||
cdt.AddColumn("Req Handled", 12);
|
||||
cdt.Indent = 2;
|
||||
|
||||
Dictionary<string, int> receivedStats = new Dictionary<string, int>();
|
||||
Dictionary<string, int> handledStats = new Dictionary<string, int>();
|
||||
|
||||
m_scene.ForEachScenePresence(
|
||||
sp =>
|
||||
{
|
||||
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
|
||||
|
||||
if (caps == null)
|
||||
return;
|
||||
|
||||
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
|
||||
|
||||
foreach (IRequestHandler reqHandler in capsHandlers.Values)
|
||||
{
|
||||
string reqName = reqHandler.Name ?? "";
|
||||
|
||||
if (!receivedStats.ContainsKey(reqName))
|
||||
{
|
||||
receivedStats[reqName] = reqHandler.RequestsReceived;
|
||||
handledStats[reqName] = reqHandler.RequestsHandled;
|
||||
}
|
||||
else
|
||||
{
|
||||
receivedStats[reqName] += reqHandler.RequestsReceived;
|
||||
handledStats[reqName] += reqHandler.RequestsHandled;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
|
||||
cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
|
||||
|
||||
sb.Append(cdt.ToString());
|
||||
}
|
||||
|
||||
private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
|
||||
{
|
||||
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
|
||||
return;
|
||||
|
||||
if (cmdParams.Length != 5 && cmdParams.Length != 7)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]");
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("Region {0}:\n", m_scene.Name);
|
||||
|
||||
if (cmdParams.Length == 5)
|
||||
{
|
||||
BuildSummaryStatsByUserReport(sb);
|
||||
}
|
||||
else if (cmdParams.Length == 7)
|
||||
{
|
||||
string firstName = cmdParams[5];
|
||||
string lastName = cmdParams[6];
|
||||
|
||||
ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
|
||||
|
||||
if (sp == null)
|
||||
return;
|
||||
|
||||
BuildDetailedStatsByUserReport(sb, sp);
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(sb.ToString());
|
||||
}
|
||||
|
||||
private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
|
||||
{
|
||||
sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
|
||||
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("Cap Name", 34);
|
||||
cdt.AddColumn("Req Received", 12);
|
||||
cdt.AddColumn("Req Handled", 12);
|
||||
cdt.Indent = 2;
|
||||
|
||||
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
|
||||
|
||||
if (caps == null)
|
||||
return;
|
||||
|
||||
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
|
||||
|
||||
foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived))
|
||||
{
|
||||
cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled);
|
||||
}
|
||||
|
||||
sb.Append(cdt.ToString());
|
||||
}
|
||||
|
||||
private void BuildSummaryStatsByUserReport(StringBuilder sb)
|
||||
{
|
||||
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
|
||||
cdt.AddColumn("Name", 32);
|
||||
cdt.AddColumn("Type", 5);
|
||||
cdt.AddColumn("Req Received", 12);
|
||||
cdt.AddColumn("Req Handled", 12);
|
||||
cdt.Indent = 2;
|
||||
|
||||
m_scene.ForEachScenePresence(
|
||||
sp =>
|
||||
{
|
||||
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
|
||||
|
||||
if (caps == null)
|
||||
return;
|
||||
|
||||
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
|
||||
|
||||
int totalRequestsReceived = 0;
|
||||
int totalRequestsHandled = 0;
|
||||
|
||||
foreach (IRequestHandler reqHandler in capsHandlers.Values)
|
||||
{
|
||||
totalRequestsReceived += reqHandler.RequestsReceived;
|
||||
totalRequestsHandled += reqHandler.RequestsHandled;
|
||||
}
|
||||
|
||||
cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
|
||||
}
|
||||
);
|
||||
|
||||
sb.Append(cdt.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
|||
m_EstateModule = fmodule;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
|
||||
}
|
||||
|
||||
public override byte[] Handle(
|
||||
protected override byte[] ProcessRequest(
|
||||
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return Util.UTF8.GetBytes(Report());
|
||||
|
|
|
@ -281,7 +281,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
|
|||
m_module = module;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader reader = new StreamReader(request);
|
||||
string requestBody = reader.ReadToEnd();
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
|
|||
m_WorldViewModule = fmodule;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
httpResponse.ContentType = "image/jpeg";
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
m_allowedTypes = allowedTypes;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
bool result = false;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
m_AssetService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
byte[] result = new byte[0];
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
m_AssetService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
AssetBase asset;
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
|||
}
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
string[] p = SplitParams(path);
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
|||
#endregion
|
||||
}
|
||||
|
||||
public class OpenIdStreamHandler : IStreamHandler
|
||||
public class OpenIdStreamHandler : BaseOutputStreamHandler
|
||||
{
|
||||
#region HTML
|
||||
|
||||
|
@ -191,42 +191,34 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
|
|||
|
||||
#endregion HTML
|
||||
|
||||
public string Name { get { return "OpenId"; } }
|
||||
public string Description { get { return null; } }
|
||||
public string ContentType { get { return m_contentType; } }
|
||||
public string HttpMethod { get { return m_httpMethod; } }
|
||||
public string Path { get { return m_path; } }
|
||||
|
||||
string m_contentType;
|
||||
string m_httpMethod;
|
||||
string m_path;
|
||||
IAuthenticationService m_authenticationService;
|
||||
IUserAccountService m_userAccountService;
|
||||
ProviderMemoryStore m_openidStore = new ProviderMemoryStore();
|
||||
|
||||
public override string ContentType { get { return "text/html"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService)
|
||||
public OpenIdStreamHandler(
|
||||
string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService)
|
||||
: base(httpMethod, path, "OpenId", "OpenID stream handler")
|
||||
{
|
||||
m_authenticationService = authService;
|
||||
m_userAccountService = userService;
|
||||
m_httpMethod = httpMethod;
|
||||
m_path = path;
|
||||
|
||||
m_contentType = "text/html";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles all GET and POST requests for OpenID identifier pages and endpoint
|
||||
/// server communication
|
||||
/// </summary>
|
||||
public void Handle(string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override void ProcessRequest(
|
||||
string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath));
|
||||
|
||||
// Defult to returning HTML content
|
||||
m_contentType = "text/html";
|
||||
httpResponse.ContentType = ContentType;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -276,7 +268,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
|
|||
|
||||
string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type");
|
||||
if (contentTypeValues != null && contentTypeValues.Length == 1)
|
||||
m_contentType = contentTypeValues[0];
|
||||
httpResponse.ContentType = contentTypeValues[0];
|
||||
|
||||
// Set the response code and document body based on the OpenID result
|
||||
httpResponse.StatusCode = (int)provider.Request.Response.Code;
|
||||
|
@ -344,4 +336,4 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Authorization
|
|||
m_AuthorizationService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest));
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Avatar
|
|||
m_AvatarService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Friends
|
|||
m_FriendsService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Grid
|
|||
m_GridService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.GridUser
|
|||
m_GridUserService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!");
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
m_HandlersType = handlersType;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
return OKResponse(httpResponse);
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
{
|
||||
return new ExtendedAgentDestinationData();
|
||||
}
|
||||
|
||||
protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
|
||||
{
|
||||
base.UnpackData(args, d, request);
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Inventory
|
|||
m_InventoryService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>));
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
m_InventoryService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace OpenSim.Server.Handlers.MapImage
|
|||
m_Proxy = proxy;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace OpenSim.Server.Handlers.MapImage
|
|||
m_MapService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
byte[] result = new byte[0];
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
|||
// TODO: unused: m_AuthenticationService = authentication;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Not implemented yet
|
||||
|
@ -83,7 +83,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
|||
// TODO: unused: m_AllowForeignGuests = foreignGuests;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
byte[] result = new byte[0];
|
||||
|
@ -176,7 +176,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
|||
// TODO: unused: m_AuthenticationService = authentication;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Not implemented yet
|
||||
|
@ -197,7 +197,7 @@ namespace OpenSim.Server.Handlers.Neighbour
|
|||
// TODO: unused: m_AuthenticationService = authentication;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Not implemented yet
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Presence
|
|||
m_PresenceService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
|||
m_SimulationService = null;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// m_log.DebugFormat("[SIMULATION]: Stream handler called");
|
||||
|
@ -457,7 +457,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
|||
m_SimulationService = null;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// m_log.DebugFormat("[SIMULATION]: Stream handler called");
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
|||
}
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
|
|
Loading…
Reference in New Issue