mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
Write UDP statistics to the log, not just the console (e.g., "show queues")
This commit is contained in:
@@ -30,6 +30,8 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse.StructuredData;
|
||||
@@ -41,6 +43,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// </summary>
|
||||
public static class StatsManager
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// Subcommand used to list other stats.
|
||||
public const string AllSubCommand = "all";
|
||||
|
||||
@@ -98,6 +102,7 @@ namespace OpenSim.Framework.Monitoring
|
||||
public static void HandleShowStatsCommand(string module, string[] cmd)
|
||||
{
|
||||
ICommandConsole con = MainConsole.Instance;
|
||||
StringBuilder report = new StringBuilder();
|
||||
|
||||
if (cmd.Length > 2)
|
||||
{
|
||||
@@ -111,7 +116,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
|
||||
if (categoryName == AllSubCommand)
|
||||
{
|
||||
OutputAllStatsToConsole(con);
|
||||
foreach (string report2 in GetAllStatsReports())
|
||||
report.AppendLine(report2);
|
||||
}
|
||||
else if (categoryName == ListSubCommand)
|
||||
{
|
||||
@@ -130,7 +136,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
if (String.IsNullOrEmpty(containerName))
|
||||
{
|
||||
OutputCategoryStatsToConsole(con, category);
|
||||
foreach (string report2 in GetCategoryStatsReports(category))
|
||||
report.AppendLine(report2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -139,14 +146,15 @@ namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
if (String.IsNullOrEmpty(statName))
|
||||
{
|
||||
OutputContainerStatsToConsole(con, container);
|
||||
foreach (string report2 in GetContainerStatsReports(container))
|
||||
report.AppendLine(report2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stat stat;
|
||||
if (container.TryGetValue(statName, out stat))
|
||||
{
|
||||
OutputStatToConsole(con, stat);
|
||||
report.AppendLine(stat.ToConsoleString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,10 +176,18 @@ namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
// Legacy
|
||||
if (SimExtraStats != null)
|
||||
con.Output(SimExtraStats.Report());
|
||||
{
|
||||
report.Append(SimExtraStats.Report());
|
||||
}
|
||||
else
|
||||
OutputAllStatsToConsole(con);
|
||||
{
|
||||
foreach (string report2 in GetAllStatsReports())
|
||||
report.AppendLine(report2);
|
||||
}
|
||||
}
|
||||
|
||||
if (report.Length > 0)
|
||||
m_log.Debug(string.Join(" ", cmd) + "\n" + report.ToString());
|
||||
}
|
||||
|
||||
public static List<string> GetAllStatsReports()
|
||||
@@ -184,12 +200,6 @@ namespace OpenSim.Framework.Monitoring
|
||||
return reports;
|
||||
}
|
||||
|
||||
private static void OutputAllStatsToConsole(ICommandConsole con)
|
||||
{
|
||||
foreach (string report in GetAllStatsReports())
|
||||
con.Output(report);
|
||||
}
|
||||
|
||||
private static List<string> GetCategoryStatsReports(
|
||||
SortedDictionary<string, SortedDictionary<string, Stat>> category)
|
||||
{
|
||||
@@ -201,13 +211,6 @@ namespace OpenSim.Framework.Monitoring
|
||||
return reports;
|
||||
}
|
||||
|
||||
private static void OutputCategoryStatsToConsole(
|
||||
ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category)
|
||||
{
|
||||
foreach (string report in GetCategoryStatsReports(category))
|
||||
con.Output(report);
|
||||
}
|
||||
|
||||
private static List<string> GetContainerStatsReports(SortedDictionary<string, Stat> container)
|
||||
{
|
||||
List<string> reports = new List<string>();
|
||||
@@ -218,18 +221,6 @@ namespace OpenSim.Framework.Monitoring
|
||||
return reports;
|
||||
}
|
||||
|
||||
private static void OutputContainerStatsToConsole(
|
||||
ICommandConsole con, SortedDictionary<string, Stat> container)
|
||||
{
|
||||
foreach (string report in GetContainerStatsReports(container))
|
||||
con.Output(report);
|
||||
}
|
||||
|
||||
private static void OutputStatToConsole(ICommandConsole con, Stat stat)
|
||||
{
|
||||
con.Output(stat.ToConsoleString());
|
||||
}
|
||||
|
||||
// Creates an OSDMap of the format:
|
||||
// { categoryName: {
|
||||
// containerName: {
|
||||
|
||||
Reference in New Issue
Block a user