From 25111e703f54d84c7c51e32db1f94332ea3ffd00 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 11 Sep 2012 21:48:02 +0100 Subject: Add levels 4 and 5 to "debug http" console command that will log a sample of incoming request data and the entire incoming data respectively. See "help debug http" for more details. --- OpenSim/Framework/Servers/MainServer.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 8dc0e3a..1ac0953 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -111,6 +111,8 @@ namespace OpenSim.Framework.Servers + "If level >= 1, then short warnings are logged when receiving bad input data.\n" + "If level >= 2, then long warnings are logged when receiving bad input data.\n" + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" + + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" + + "If level >= 5, then the entire incoming data is logged.\n" + "If no level is specified then the current level is returned.", HandleDebugHttpCommand); } -- cgit v1.1 From d53a53d4c599e77f039149128526ac67570b30fb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Sep 2012 00:10:48 +0100 Subject: Make "show http-handlers" command available for ROBUST instances as well as the simulator executable. --- OpenSim/Framework/Servers/MainServer.cs | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 1ac0953..b367b12 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Net; +using System.Text; using log4net; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -105,6 +106,11 @@ namespace OpenSim.Framework.Servers public static void RegisterHttpConsoleCommands(ICommandConsole console) { console.Commands.AddCommand( + "Comms", false, "show http-handlers", + "show http-handlers", + "Show all registered http handlers", HandleShowHttpHandlersCommand); + + console.Commands.AddCommand( "Debug", false, "debug http", "debug http []", "Turn on inbound non-poll http request debugging.", "If level <= 0, then no extra logging is done.\n" @@ -142,6 +148,51 @@ namespace OpenSim.Framework.Servers } } + private static void HandleShowHttpHandlersCommand(string module, string[] args) + { + if (args.Length != 2) + { + MainConsole.Instance.Output("Usage: show http-handlers"); + return; + } + + StringBuilder handlers = new StringBuilder(); + + lock (m_Servers) + { + foreach (BaseHttpServer httpServer in m_Servers.Values) + { + handlers.AppendFormat( + "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); + + handlers.AppendFormat("* XMLRPC:\n"); + foreach (String s in httpServer.GetXmlRpcHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* HTTP:\n"); + List poll = httpServer.GetPollServiceHandlerKeys(); + foreach (String s in httpServer.GetHTTPHandlerKeys()) + handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); + + handlers.AppendFormat("* Agent:\n"); + foreach (String s in httpServer.GetAgentHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* LLSD:\n"); + foreach (String s in httpServer.GetLLSDHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); + foreach (String s in httpServer.GetStreamHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.Append("\n"); + } + } + + MainConsole.Instance.Output(handlers.ToString()); + } + /// /// Register an already started HTTP server to the collection of known servers. /// -- cgit v1.1 From cdc3781f42869586aa4bba482359f8cda21cb912 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Sep 2012 23:02:25 +0100 Subject: Fix usage statement on "debug http" console command since max level is now 5 rather than 3 --- OpenSim/Framework/Servers/MainServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index b367b12..7402c73 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -144,7 +144,7 @@ namespace OpenSim.Framework.Servers } else { - MainConsole.Instance.Output("Usage: debug http 0..3"); + MainConsole.Instance.Output("Usage: debug http 0..5"); } } -- cgit v1.1 From 387a1bb283c0c55178421f2c28b0d28a24dac7a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 20 Sep 2012 22:36:47 +0100 Subject: Add ability to turn on/off logging of outgoing HTTP requests flowing through WebUtil. This is for debugging purposes. This is controlled via the "debug http" command which can already log incoming requests. This now gains a mandatory parameter of in, out or all to control what is logged. Log messages are also shortened and labelled and HTTP IN or HTTP OUT to be consistent with existing UDP PACKET IN and PACKET OUT messages. --- OpenSim/Framework/Servers/MainServer.cs | 87 ++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 7402c73..b7a133e 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -48,9 +48,11 @@ namespace OpenSim.Framework.Servers /// Control the printing of certain debug messages. /// /// - /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. - /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. - /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. + /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. + /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. + /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. + /// If DebugLevel >= 4 then the start of the body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 5 then the entire body of incoming non-poll HTTP requests will be logged. /// public static int DebugLevel { @@ -102,7 +104,6 @@ namespace OpenSim.Framework.Servers get { return new Dictionary(m_Servers); } } - public static void RegisterHttpConsoleCommands(ICommandConsole console) { console.Commands.AddCommand( @@ -111,15 +112,18 @@ namespace OpenSim.Framework.Servers "Show all registered http handlers", HandleShowHttpHandlersCommand); console.Commands.AddCommand( - "Debug", false, "debug http", "debug http []", - "Turn on inbound non-poll http request debugging.", - "If level <= 0, then no extra logging is done.\n" - + "If level >= 1, then short warnings are logged when receiving bad input data.\n" - + "If level >= 2, then long warnings are logged when receiving bad input data.\n" - + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" - + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" - + "If level >= 5, then the entire incoming data is logged.\n" - + "If no level is specified then the current level is returned.", + "Debug", false, "debug http", "debug http []", + "Turn on http request logging.", + "If in or all and\n" + + " level <= 0, then no extra logging is done.\n" + + " level >= 1, then short warnings are logged when receiving bad input data.\n" + + " level >= 2, then long warnings are logged when receiving bad input data.\n" + + " level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" + + " level >= 4, then a sample from the beginning of the incoming data is logged.\n" + + " level >= 5, then the entire incoming data is logged.\n" + + " no level is specified then the current level is returned.\n\n" + + "If out or all and\n" + + " level >= 3. then short notices about all outgoing requests going through WebUtil are logged.\n", HandleDebugHttpCommand); } @@ -127,24 +131,63 @@ namespace OpenSim.Framework.Servers /// Turn on some debugging values for OpenSim. /// /// - private static void HandleDebugHttpCommand(string module, string[] args) + private static void HandleDebugHttpCommand(string module, string[] cmdparams) { - if (args.Length == 3) + if (cmdparams.Length < 3) { + MainConsole.Instance.Output("Usage: debug http 0..5"); + return; + } + + bool inReqs = false; + bool outReqs = false; + bool allReqs = false; + + string subCommand = cmdparams[2]; + + if (subCommand == "in") + inReqs = true; + else if (subCommand == "out") + outReqs = true; + else + allReqs = true; + + if (cmdparams.Length >= 4) + { + string rawNewDebug = cmdparams[3]; int newDebug; - if (int.TryParse(args[2], out newDebug)) + + if (!int.TryParse(rawNewDebug, out newDebug)) + { + MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); + return; + } + + if (newDebug < 0 || newDebug > 5) + { + MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug); + return; + } + + if (allReqs || inReqs) { MainServer.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("In debug level set to {0}", newDebug); + } + + if (allReqs || outReqs) + { + WebUtil.DebugLevel = newDebug; + MainConsole.Instance.OutputFormat("Out debug level set to {0}", newDebug); } - } - else if (args.Length == 2) - { - MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); } else { - MainConsole.Instance.Output("Usage: debug http 0..5"); + if (allReqs || inReqs) + MainConsole.Instance.OutputFormat("Current in debug level is {0}", MainServer.DebugLevel); + + if (allReqs || outReqs) + MainConsole.Instance.OutputFormat("Current out debug level is {0}", WebUtil.DebugLevel); } } -- cgit v1.1 From a5b3989e5db0a3b22e44b84412227a8e487bcef2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 20 Sep 2012 23:18:19 +0100 Subject: Insert a new log level 4 for HTTP IN and HTTP OUT that will log how long the request took. This is only printed if debug http level >= 4 and the request didn't take more than the time considered 'long', in which case the existing log message is printed. This displaces the previous log levels 4 and 5 which are now 5 and 6 respectively. --- OpenSim/Framework/Servers/MainServer.cs | 48 +++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index b7a133e..72f9cce 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -51,8 +51,9 @@ namespace OpenSim.Framework.Servers /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. - /// If DebugLevel >= 4 then the start of the body of incoming non-poll HTTP requests will be logged. - /// If DebugLevel >= 5 then the entire body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. + /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. /// public static int DebugLevel { @@ -115,15 +116,17 @@ namespace OpenSim.Framework.Servers "Debug", false, "debug http", "debug http []", "Turn on http request logging.", "If in or all and\n" - + " level <= 0, then no extra logging is done.\n" - + " level >= 1, then short warnings are logged when receiving bad input data.\n" - + " level >= 2, then long warnings are logged when receiving bad input data.\n" - + " level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" - + " level >= 4, then a sample from the beginning of the incoming data is logged.\n" - + " level >= 5, then the entire incoming data is logged.\n" + + " level <= 0 then no extra logging is done.\n" + + " level >= 1 then short warnings are logged when receiving bad input data.\n" + + " level >= 2 then long warnings are logged when receiving bad input data.\n" + + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" + + " level >= 4 then the time taken to fulfill the request is logged.\n" + + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" + + " level >= 6 then the entire incoming data is logged.\n" + " no level is specified then the current level is returned.\n\n" + "If out or all and\n" - + " level >= 3. then short notices about all outgoing requests going through WebUtil are logged.\n", + + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" + + " level >= 4 then the time taken to fulfill the request is logged.\n", HandleDebugHttpCommand); } @@ -135,7 +138,7 @@ namespace OpenSim.Framework.Servers { if (cmdparams.Length < 3) { - MainConsole.Instance.Output("Usage: debug http 0..5"); + MainConsole.Instance.Output("Usage: debug http 0..6"); return; } @@ -145,12 +148,23 @@ namespace OpenSim.Framework.Servers string subCommand = cmdparams[2]; - if (subCommand == "in") + if (subCommand.ToLower() == "in") + { inReqs = true; - else if (subCommand == "out") + } + else if (subCommand.ToLower() == "out") + { outReqs = true; - else + } + else if (subCommand.ToLower() == "all") + { allReqs = true; + } + else + { + MainConsole.Instance.Output("You must specify in, out or all"); + return; + } if (cmdparams.Length >= 4) { @@ -172,22 +186,22 @@ namespace OpenSim.Framework.Servers if (allReqs || inReqs) { MainServer.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("In debug level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); } if (allReqs || outReqs) { WebUtil.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("Out debug level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); } } else { if (allReqs || inReqs) - MainConsole.Instance.OutputFormat("Current in debug level is {0}", MainServer.DebugLevel); + MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); if (allReqs || outReqs) - MainConsole.Instance.OutputFormat("Current out debug level is {0}", WebUtil.DebugLevel); + MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); } } -- cgit v1.1 From 1b0abf8f0cd417e2a37cffc96379274ad98183f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 Sep 2012 00:29:13 +0100 Subject: Comment out the long unused afaik HTTP agent handlers. As far as I know, this was only used by the IBM Rest modules, much of which has been commented out for a very long time now. Other similar code uses HTTP or stream handlers instead. So commenting this out to reduce code complexity and the need to make this facility consistent with the others where it may not be used anyway. If this facility is actually being used then please notify me or uncomment it if you are core. --- OpenSim/Framework/Servers/MainServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 72f9cce..4b61b18 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -231,9 +231,9 @@ namespace OpenSim.Framework.Servers foreach (String s in httpServer.GetHTTPHandlerKeys()) handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); - handlers.AppendFormat("* Agent:\n"); - foreach (String s in httpServer.GetAgentHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); +// handlers.AppendFormat("* Agent:\n"); +// foreach (String s in httpServer.GetAgentHandlerKeys()) +// handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("* LLSD:\n"); foreach (String s in httpServer.GetLLSDHandlerKeys()) -- cgit v1.1 From f4579527551f474f68f368ffdd0cd0a89d31d504 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Sep 2012 02:38:21 +0100 Subject: Fix bug where debug http level 6 could not be specified. Also converts newlines at this level to '\n' to enable them to be logged. --- OpenSim/Framework/Servers/MainServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Servers/MainServer.cs') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 4b61b18..ae7d515 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -177,9 +177,9 @@ namespace OpenSim.Framework.Servers return; } - if (newDebug < 0 || newDebug > 5) + if (newDebug < 0 || newDebug > 6) { - MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug); + MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); return; } -- cgit v1.1