Make it possible to specify display of stats in a particular 'container' by separating category and container with a period.

e.g. "show stats server.network"
I failed to realize this had already been implemented without the period in the show stats command (as the command help had not been updated).
However, I would prefer the . approach as it will allow specifying multiple stats, easier wildcarding, etc.
This commit also prevents any stat from having a period in its short name.
cpu-performance
Justin Clark-Casey (justincc) 2013-06-20 00:00:39 +01:00
parent 84af1cab9b
commit 086fd70a5f
2 changed files with 17 additions and 3 deletions

View File

@ -42,6 +42,8 @@ namespace OpenSim.Framework.Monitoring
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static readonly char[] DisallowedShortNameCharacters = { '.' };
/// <summary> /// <summary>
/// Category of this stat (e.g. cache, scene, etc). /// Category of this stat (e.g. cache, scene, etc).
/// </summary> /// </summary>
@ -166,6 +168,12 @@ namespace OpenSim.Framework.Monitoring
throw new Exception( throw new Exception(
string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category));
foreach (char c in DisallowedShortNameCharacters)
{
if (shortName.IndexOf(c) != -1)
throw new Exception(string.Format("Stat name {0} cannot contain character {1}", shortName, c));
}
ShortName = shortName; ShortName = shortName;
Name = name; Name = name;
Description = description; Description = description;

View File

@ -68,12 +68,13 @@ namespace OpenSim.Framework.Monitoring
"General", "General",
false, false,
"show stats", "show stats",
"show stats [list|all|<category>]", "show stats [list|all|<category>[.<container>]",
"Show statistical information for this server", "Show statistical information for this server",
"If no final argument is specified then legacy statistics information is currently shown.\n" "If no final argument is specified then legacy statistics information is currently shown.\n"
+ "If list is specified then statistic categories are shown.\n" + "If list is specified then statistic categories are shown.\n"
+ "If all is specified then all registered statistics are shown.\n" + "If all is specified then all registered statistics are shown.\n"
+ "If a category name is specified then only statistics from that category are shown.\n" + "If a category name is specified then only statistics from that category are shown.\n"
+ "If a category container is also specified then only statistics from that category in that container are shown.\n"
+ "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
HandleShowStatsCommand); HandleShowStatsCommand);
} }
@ -84,8 +85,11 @@ namespace OpenSim.Framework.Monitoring
if (cmd.Length > 2) if (cmd.Length > 2)
{ {
var categoryName = cmd[2]; string name = cmd[2];
var containerName = cmd.Length > 3 ? cmd[3] : String.Empty; string[] components = name.Split('.');
string categoryName = components[0];
string containerName = components.Length > 1 ? components[1] : null;
if (categoryName == AllSubCommand) if (categoryName == AllSubCommand)
{ {
@ -107,7 +111,9 @@ namespace OpenSim.Framework.Monitoring
else else
{ {
if (String.IsNullOrEmpty(containerName)) if (String.IsNullOrEmpty(containerName))
{
OutputCategoryStatsToConsole(con, category); OutputCategoryStatsToConsole(con, category);
}
else else
{ {
SortedDictionary<string, Stat> container; SortedDictionary<string, Stat> container;