Allow more than one stat category to be specified in "show stats"
e.g. "show stats httpserver.9000 server.network"cpu-performance
							parent
							
								
									5b1a9f84fd
								
							
						
					
					
						commit
						05790ba1cf
					
				| 
						 | 
				
			
			@ -27,6 +27,7 @@
 | 
			
		|||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Framework.Monitoring
 | 
			
		||||
| 
						 | 
				
			
			@ -68,13 +69,14 @@ namespace OpenSim.Framework.Monitoring
 | 
			
		|||
                "General",
 | 
			
		||||
                false,
 | 
			
		||||
                "show stats",
 | 
			
		||||
                "show stats [list|all|<category>[.<container>]",
 | 
			
		||||
                "show stats [list|all|(<category>[.<container>])+",
 | 
			
		||||
                "Show statistical information for this server",
 | 
			
		||||
                "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 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 container is also specified then only statistics from that category in that container are shown.\n"
 | 
			
		||||
                    + "'list' argument will show statistic categories.\n"
 | 
			
		||||
                    + "'all' will show all statistics.\n"
 | 
			
		||||
                    + "A <category> name will show statistics from that category.\n"
 | 
			
		||||
                    + "A <category>.<container> name will show statistics from that category in that container.\n"
 | 
			
		||||
                    + "More than one name can be given separated by spaces.\n"
 | 
			
		||||
                    + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
 | 
			
		||||
                HandleShowStatsCommand);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -85,45 +87,47 @@ namespace OpenSim.Framework.Monitoring
 | 
			
		|||
 | 
			
		||||
            if (cmd.Length > 2)
 | 
			
		||||
            {
 | 
			
		||||
                string name = cmd[2];
 | 
			
		||||
                string[] components = name.Split('.');
 | 
			
		||||
                foreach (string name in cmd.Skip(2))
 | 
			
		||||
                {
 | 
			
		||||
                    string[] components = name.Split('.');
 | 
			
		||||
 | 
			
		||||
                string categoryName = components[0];
 | 
			
		||||
                string containerName = components.Length > 1 ? components[1] : null;
 | 
			
		||||
                    string categoryName = components[0];
 | 
			
		||||
                    string containerName = components.Length > 1 ? components[1] : null;
 | 
			
		||||
 | 
			
		||||
                if (categoryName == AllSubCommand)
 | 
			
		||||
                {
 | 
			
		||||
                    OutputAllStatsToConsole(con);
 | 
			
		||||
                }
 | 
			
		||||
                else if (categoryName == ListSubCommand)
 | 
			
		||||
                {
 | 
			
		||||
                    con.Output("Statistic categories available are:");
 | 
			
		||||
                    foreach (string category in RegisteredStats.Keys)
 | 
			
		||||
                        con.OutputFormat("  {0}", category);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    SortedDictionary<string, SortedDictionary<string, Stat>> category;
 | 
			
		||||
                    if (!RegisteredStats.TryGetValue(categoryName, out category))
 | 
			
		||||
                    if (categoryName == AllSubCommand)
 | 
			
		||||
                    {
 | 
			
		||||
                        con.OutputFormat("No such category as {0}", categoryName);
 | 
			
		||||
                        OutputAllStatsToConsole(con);
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (categoryName == ListSubCommand)
 | 
			
		||||
                    {
 | 
			
		||||
                        con.Output("Statistic categories available are:");
 | 
			
		||||
                        foreach (string category in RegisteredStats.Keys)
 | 
			
		||||
                            con.OutputFormat("  {0}", category);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        if (String.IsNullOrEmpty(containerName))
 | 
			
		||||
                        SortedDictionary<string, SortedDictionary<string, Stat>> category;
 | 
			
		||||
                        if (!RegisteredStats.TryGetValue(categoryName, out category))
 | 
			
		||||
                        {
 | 
			
		||||
                            OutputCategoryStatsToConsole(con, category);
 | 
			
		||||
                            con.OutputFormat("No such category as {0}", categoryName);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            SortedDictionary<string, Stat> container;
 | 
			
		||||
                            if (category.TryGetValue(containerName, out container))
 | 
			
		||||
                            if (String.IsNullOrEmpty(containerName))
 | 
			
		||||
                            {
 | 
			
		||||
                                OutputContainerStatsToConsole(con, container);
 | 
			
		||||
                                OutputCategoryStatsToConsole(con, category);
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                con.OutputFormat("No such container {0} in category {1}", containerName, categoryName);
 | 
			
		||||
                                SortedDictionary<string, Stat> container;
 | 
			
		||||
                                if (category.TryGetValue(containerName, out container))
 | 
			
		||||
                                {
 | 
			
		||||
                                    OutputContainerStatsToConsole(con, container);
 | 
			
		||||
                                }
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    con.OutputFormat("No such container {0} in category {1}", containerName, categoryName);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue