private void HandleShowServerThrottlesCommand(string module, string[] args) { if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) { return; } m_console.OutputFormat("Throttles for {0}", m_udpServer.Scene.Name); ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.AddRow("Adaptive throttles", m_udpServer.ThrottleRates.AdaptiveThrottlesEnabled); long maxSceneDripRate = (long)m_udpServer.Throttle.MaxDripRate; cdl.AddRow( "Max scene throttle", maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset"); int maxClientDripRate = m_udpServer.ThrottleRates.Total; cdl.AddRow( "Max new client throttle", maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset"); m_console.Output(cdl.ToString()); m_console.OutputFormat("{0}\n", GetServerThrottlesReport(m_udpServer)); }
/// ----------------------------------------------------------------- /// <summary> /// </summary> /// ----------------------------------------------------------------- private void HandleShowCapabilities(string module, string[] cmd) { ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.Indent = 2; cdt.AddColumn("Capability", 36); cdt.AddColumn("Expiration", 15); cdt.AddColumn("User Name", 30); cdt.AddColumn("Scene", 30); cdt.AddColumn("Domains", 50); int now = Util.EnvironmentTickCount(); List <CapabilityInfo> caps = m_capCache.DumpCapabilities(); foreach (CapabilityInfo cap in caps) { int span = (cap.LifeSpan - Util.EnvironmentTickCountSubtract(now, cap.LastRefresh)) / 1000; string name = cap.Account.FirstName + ' ' + cap.Account.LastName; string time = DateTime.Now.AddSeconds(span).ToLongTimeString(); string doms = ""; foreach (string s in cap.DomainList) { doms += s + ","; } cdt.AddRow(cap.Capability.ToString(), time, name, cap.SceneName, doms); } m_console.OutputFormat(cdt.ToString()); }
/// <summary> /// Console output is only possible if a console has been established. /// That is something that cannot be determined within this class. So /// all attempts to use the console MUST be verified. /// </summary> /// <param name="format"></param> /// <param name="components"></param> protected void Notice(string format, params object[] components) { if (m_console != null) { m_console.OutputFormat(format, components); } }
public static void HandleShowchecksCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { foreach (string name in cmd.Skip(2)) { string[] components = name.Split('.'); string categoryName = components[0]; // string containerName = components.Length > 1 ? components[1] : null; if (categoryName == ListSubCommand) { con.Output("check categories available are:"); foreach (string category in RegisteredChecks.Keys) { con.OutputFormat(" {0}", category); } } // else // { // SortedDictionary<string, SortedDictionary<string, Check>> category; // if (!Registeredchecks.TryGetValue(categoryName, out category)) // { // con.OutputFormat("No such category as {0}", categoryName); // } // else // { // if (String.IsNullOrEmpty(containerName)) // { // OutputConfiguredToConsole(con, category); // } // else // { // SortedDictionary<string, Check> container; // if (category.TryGetValue(containerName, out container)) // { // OutputContainerChecksToConsole(con, container); // } // else // { // con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); // } // } // } // } } } else { OutputAllChecksToConsole(con); } }
/// <summary> /// Check if the given file path exists. /// </summary> /// <remarks>If not, warning is printed to the given console.</remarks> /// <returns>true if the file does not exist, false otherwise.</returns> /// <param name='console'></param> /// <param name='path'></param> public static bool CheckFileDoesNotExist(ICommandConsole console, string path) { if (File.Exists(path)) { console.OutputFormat("File {0} already exists. Please move or remove it.", path); return(false); } return(true); }
/// <summary> /// Check if the given file path exists. /// </summary> /// <remarks>If not, warning is printed to the given console.</remarks> /// <returns>true if the file does not exist, false otherwise.</returns> /// <param name='console'></param> /// <param name='path'></param> public static bool CheckFileDoesNotExist(ICommandConsole console, string path) { if (File.Exists(path)) { console.OutputFormat("File {0} already exists. Please move or remove it.", path); return false; } return true; }
public static void HandleShowStatsCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { var categoryName = cmd[2]; if (categoryName == AllSubCommand) { foreach (var category in RegisteredStats.Values) { OutputCategoryStatsToConsole(con, category); } } else if (categoryName == ListSubCommand) { con.Output("Statistic categories available are:"); foreach (string category in RegisteredStats.Keys) { con.OutputFormat(" {0}", category); } } else { Dictionary <string, Dictionary <string, Stat> > category; if (!RegisteredStats.TryGetValue(categoryName, out category)) { con.OutputFormat("No such category as {0}", categoryName); } else { OutputCategoryStatsToConsole(con, category); } } } else { // Legacy con.Output(SimExtraStats.Report()); } }
/// <summary> /// Convert a console integer to an int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) { if (!int.TryParse(rawConsoleInt, out i)) { if (console != null) { console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); } return(false); } return(true); }
/// <summary> /// Convert a console integer to an int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleVector'>/param> /// <param name='vector'></param> /// <returns></returns> public static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b) { if (!bool.TryParse(rawConsoleString, out b)) { if (console != null) { console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); } return(false); } return(true); }
/// <summary> /// Try to parse a console UUID from the console. /// </summary> /// <remarks> /// Will complain to the console if parsing fails. /// </remarks> /// <returns></returns> /// <param name='console'>If null then no complaint is printed.</param> /// <param name='rawUuid'></param> /// <param name='uuid'></param> public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) { if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) { console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); } return(false); } return(true); }
/// <summary> /// Convert a console input to a double, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInput'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i) { if (!double.TryParse(rawConsoleInput, out i)) { if (console != null) { console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); } return(false); } return(true); }
public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) { if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) { console.OutputFormat("ERROR: {0} is not a valid local id", localId); } return(false); } if (localId == 0) { if (console != null) { console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); } return(false); } return(true); }
/// <summary> /// Convert a console integer to a natural int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i) { if (TryParseConsoleInt(console, rawConsoleInt, out i)) { if (i < 0) { if (console != null) { console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); } return(false); } return(true); } return(false); }
/// <summary> /// Tries to parse the input as either a UUID or a local ID. /// </summary> /// <returns>true if parsing succeeded, false otherwise.</returns> /// <param name='console'></param> /// <param name='rawId'></param> /// <param name='uuid'></param> /// <param name='localId'> /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. /// </param> public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) { if (TryParseConsoleUuid(null, rawId, out uuid)) { localId = LocalIdNotFound; return(true); } if (TryParseConsoleLocalId(null, rawId, out localId)) { return(true); } if (console != null) { console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); } return(false); }
public static void HandleStatsRecordCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length != 4) { con.Output("Usage: debug stats record start|stop"); return; } if (cmd[3] == "start") { Start(); con.OutputFormat("Now recording all stats to file every {0}ms", m_statsLogIntervalMs); } else if (cmd[3] == "stop") { Stop(); con.Output("Stopped recording stats to file."); } }
// AKIDO: remove this commented code // public static void RegisterConsoleCommands(ICommandConsole console) // { // console.Commands.AddCommand( // "General", // false, // "show stats", // "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" // + "'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); // // StatsLogger.RegisterConsoleCommands(console); // } public static void HandleShowStatsCommand(string module, string[] cmd) { ICommandConsole con = MainConsole.Instance; if (cmd.Length > 2) { foreach (string name in cmd.Skip(2)) { string[] components = name.Split('.'); 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)) { con.OutputFormat("No such category as {0}", categoryName); } else { if (String.IsNullOrEmpty(containerName)) { OutputCategoryStatsToConsole(con, category); } else { 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); } } } } } } else { // Legacy if (SimExtraStats != null) { con.Output(SimExtraStats.Report()); } else { OutputAllStatsToConsole(con); } } }
/// <summary> /// Outputs the sogs to console. /// </summary> /// <param name='searchPredicate'></param> /// <param name='showFull'>If true then output all part details. If false then output summary.</param> private void OutputSogsToConsole(Predicate <SceneObjectGroup> searchPredicate, bool showFull) { List <SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups().FindAll(searchPredicate); StringBuilder sb = new StringBuilder(); foreach (SceneObjectGroup so in sceneObjects) { AddSceneObjectReport(sb, so, showFull); sb.Append("\n"); } sb.AppendFormat("{0} object(s) found in {1}\n", sceneObjects.Count, m_scene.Name); m_console.OutputFormat(sb.ToString()); }
private List <SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams) { bool useRegex = false; OptionSet options = new OptionSet().Add("regex", v => useRegex = v != null); List <string> mainParams = options.Parse(cmdparams); if (mainParams.Count < 4) { m_console.OutputFormat("Usage: delete object name [--regex] <name>"); return(null); } string name = mainParams[3]; List <SceneObjectGroup> sceneObjects = new List <SceneObjectGroup>(); Action <SceneObjectGroup> searchAction; if (useRegex) { Regex nameRegex = new Regex(name); searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); } }; } else { searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); } }; } m_scene.ForEachSOG(searchAction); if (sceneObjects.Count == 0) { m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); } return(sceneObjects); }
private void HandleConsoleCommand(string module, string[] cmdparams) { ICommandConsole con = MainConsole.Instance; if (cmdparams.Length >= 2) { string cmd = cmdparams[1]; switch (cmd) { case "status": if (m_MemoryCacheEnabled) { con.OutputFormat("Memory Cache: {0} assets", m_MemoryCache.Count); } else { con.OutputFormat("Memory cache disabled"); } if (m_FileCacheEnabled) { int fileCount = GetFileCacheCount(m_CacheDirectory); con.OutputFormat("File Cache: {0} assets", fileCount); } else { con.Output("File cache disabled"); } GenerateCacheHitReport().ForEach(l => con.Output(l)); if (m_FileCacheEnabled) { con.Output("Deep scans have previously been performed on the following regions:"); foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) { string RegionID = s.Remove(0, s.IndexOf("_")).Replace(".fac", ""); DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); con.OutputFormat("Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); } } break; case "clear": if (cmdparams.Length < 2) { con.Output("Usage is fcache clear [file] [memory]"); break; } bool clearMemory = false, clearFile = false; if (cmdparams.Length == 2) { clearMemory = true; clearFile = true; } foreach (string s in cmdparams) { if (s.ToLower() == "memory") { clearMemory = true; } else if (s.ToLower() == "file") { clearFile = true; } } if (clearMemory) { if (m_MemoryCacheEnabled) { m_MemoryCache.Clear(); con.Output("Memory cache cleared."); } else { con.Output("Memory cache not enabled."); } } if (clearFile) { if (m_FileCacheEnabled) { ClearFileCache(); con.Output("File cache cleared."); } else { con.Output("File cache not enabled."); } } break; case "assets": con.Output("Ensuring assets are cached for all scenes."); Watchdog.RunInThread(delegate { int assetReferenceTotal = TouchAllSceneAssets(true); con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal); }, "TouchAllSceneAssets", null); break; case "expire": if (cmdparams.Length < 3) { con.OutputFormat("Invalid parameters for Expire, please specify a valid date & time", cmd); break; } string s_expirationDate = ""; DateTime expirationDate; if (cmdparams.Length > 3) { s_expirationDate = string.Join(" ", cmdparams, 2, cmdparams.Length - 2); } else { s_expirationDate = cmdparams[2]; } if (!DateTime.TryParse(s_expirationDate, out expirationDate)) { con.OutputFormat("{0} is not a valid date & time", cmd); break; } if (m_FileCacheEnabled) { CleanExpiredFiles(m_CacheDirectory, expirationDate); } else { con.OutputFormat("File cache not active, not clearing."); } break; default: con.OutputFormat("Unknown command {0}", cmd); break; } } else if (cmdparams.Length == 1) { con.Output("fcache assets - Attempt a deep cache of all assets in all scenes"); con.Output("fcache expire <datetime> - Purge assets older then the specified date & time"); con.Output("fcache clear [file] [memory] - Remove cached assets"); con.Output("fcache status - Display cache status"); } }
/// <summary> /// Try to parse a console UUID from the console. /// </summary> /// <remarks> /// Will complain to the console if parsing fails. /// </remarks> /// <returns></returns> /// <param name='console'>If null then no complaint is printed.</param> /// <param name='rawUuid'></param> /// <param name='uuid'></param> public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) { if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); return false; } return true; }
/// <summary> /// Convert a console integer to an int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) { if (!int.TryParse(rawConsoleInt, out i)) { if (console != null) console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); return false; } return true; }
/// <summary> /// Convert a console integer to a natural int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInt'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i) { if (TryParseConsoleInt(console, rawConsoleInt, out i)) { if (i < 0) { if (console != null) console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); return false; } return true; } return false; }
/// <summary> /// Convert a console integer to an int, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleVector'>/param> /// <param name='vector'></param> /// <returns></returns> public static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b) { if (!bool.TryParse(rawConsoleString, out b)) { if (console != null) console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); return false; } return true; }
/// <summary> /// Tries to parse the input as either a UUID or a local ID. /// </summary> /// <returns>true if parsing succeeded, false otherwise.</returns> /// <param name='console'></param> /// <param name='rawId'></param> /// <param name='uuid'></param> /// <param name='localId'> /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. /// </param> public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) { if (TryParseConsoleUuid(null, rawId, out uuid)) { localId = LocalIdNotFound; return true; } if (TryParseConsoleLocalId(null, rawId, out localId)) { return true; } if (console != null) console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); return false; }
public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) { if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) console.OutputFormat("ERROR: {0} is not a valid local id", localId); return false; } if (localId == 0) { if (console != null) console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); return false; } return true; }
/// <summary> /// Convert a console input to a double, automatically complaining if a console is given. /// </summary> /// <param name='console'>Can be null if no console is available.</param> /// <param name='rawConsoleInput'>/param> /// <param name='i'></param> /// <returns></returns> public static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i) { if (!double.TryParse(rawConsoleInput, out i)) { if (console != null) console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); return false; } return true; }
private void HandleShowObjectByUuid(string module, string[] cmd) { if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) { return; } if (cmd.Length < 4) { m_console.OutputFormat("Usage: show object uuid <uuid>"); return; } UUID objectUuid; if (!UUID.TryParse(cmd[3], out objectUuid)) { m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); return; } SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); if (so == null) { // m_console.OutputFormat("No part found with uuid {0}", objectUuid); return; } StringBuilder sb = new StringBuilder(); AddSceneObjectReport(sb, so); m_console.OutputFormat(sb.ToString()); }