diff options
author | Melanie | 2013-08-07 23:29:42 +0100 |
---|---|---|
committer | Melanie | 2013-08-07 23:29:42 +0100 |
commit | 005c69511dac490a8353233423a3152abf5580dd (patch) | |
tree | abae7717af4af3ed7844f3747ab28398fdad9cdf /OpenSim/Framework/Monitoring | |
parent | Merge branch 'avination-current' into careminster (diff) | |
parent | minor: add some method doc to ScenePresence fields used for entity transfer, ... (diff) | |
download | opensim-SC-005c69511dac490a8353233423a3152abf5580dd.zip opensim-SC-005c69511dac490a8353233423a3152abf5580dd.tar.gz opensim-SC-005c69511dac490a8353233423a3152abf5580dd.tar.bz2 opensim-SC-005c69511dac490a8353233423a3152abf5580dd.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Monitoring/Checks/Check.cs | 118 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/ChecksManager.cs | 262 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsLogger.cs | 108 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 58 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/Watchdog.cs | 1 |
5 files changed, 532 insertions, 15 deletions
diff --git a/OpenSim/Framework/Monitoring/Checks/Check.cs b/OpenSim/Framework/Monitoring/Checks/Check.cs new file mode 100644 index 0000000..594386a --- /dev/null +++ b/OpenSim/Framework/Monitoring/Checks/Check.cs | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.Framework.Monitoring | ||
32 | { | ||
33 | public class Check | ||
34 | { | ||
35 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
36 | |||
37 | public static readonly char[] DisallowedShortNameCharacters = { '.' }; | ||
38 | |||
39 | /// <summary> | ||
40 | /// Category of this stat (e.g. cache, scene, etc). | ||
41 | /// </summary> | ||
42 | public string Category { get; private set; } | ||
43 | |||
44 | /// <summary> | ||
45 | /// Containing name for this stat. | ||
46 | /// FIXME: In the case of a scene, this is currently the scene name (though this leaves | ||
47 | /// us with a to-be-resolved problem of non-unique region names). | ||
48 | /// </summary> | ||
49 | /// <value> | ||
50 | /// The container. | ||
51 | /// </value> | ||
52 | public string Container { get; private set; } | ||
53 | |||
54 | /// <summary> | ||
55 | /// Action used to check whether alert should go off. | ||
56 | /// </summary> | ||
57 | /// <remarks> | ||
58 | /// Should return true if check passes. False otherwise. | ||
59 | /// </remarks> | ||
60 | public Func<Check, bool> CheckFunc { get; private set; } | ||
61 | |||
62 | /// <summary> | ||
63 | /// Message from the last failure, if any. If there is no message or no failure then will be null. | ||
64 | /// </summary> | ||
65 | /// <remarks> | ||
66 | /// Should be set by the CheckFunc when applicable. | ||
67 | /// </remarks> | ||
68 | public string LastFailureMessage { get; set; } | ||
69 | |||
70 | public StatVerbosity Verbosity { get; private set; } | ||
71 | public string ShortName { get; private set; } | ||
72 | public string Name { get; private set; } | ||
73 | public string Description { get; private set; } | ||
74 | |||
75 | public Check( | ||
76 | string shortName, | ||
77 | string name, | ||
78 | string description, | ||
79 | string category, | ||
80 | string container, | ||
81 | Func<Check, bool> checkFunc, | ||
82 | StatVerbosity verbosity) | ||
83 | { | ||
84 | if (ChecksManager.SubCommands.Contains(category)) | ||
85 | throw new Exception( | ||
86 | string.Format("Alert cannot be in category '{0}' since this is reserved for a subcommand", category)); | ||
87 | |||
88 | foreach (char c in DisallowedShortNameCharacters) | ||
89 | { | ||
90 | if (shortName.IndexOf(c) != -1) | ||
91 | throw new Exception(string.Format("Alert name {0} cannot contain character {1}", shortName, c)); | ||
92 | } | ||
93 | |||
94 | ShortName = shortName; | ||
95 | Name = name; | ||
96 | Description = description; | ||
97 | Category = category; | ||
98 | Container = container; | ||
99 | CheckFunc = checkFunc; | ||
100 | Verbosity = verbosity; | ||
101 | } | ||
102 | |||
103 | public bool CheckIt() | ||
104 | { | ||
105 | return CheckFunc(this); | ||
106 | } | ||
107 | |||
108 | public virtual string ToConsoleString() | ||
109 | { | ||
110 | return string.Format( | ||
111 | "{0}.{1}.{2} - {3}", | ||
112 | Category, | ||
113 | Container, | ||
114 | ShortName, | ||
115 | Description); | ||
116 | } | ||
117 | } | ||
118 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs new file mode 100644 index 0000000..e4a7f8c --- /dev/null +++ b/OpenSim/Framework/Monitoring/ChecksManager.cs | |||
@@ -0,0 +1,262 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | |||
35 | namespace OpenSim.Framework.Monitoring | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Static class used to register/deregister checks on runtime conditions. | ||
39 | /// </summary> | ||
40 | public static class ChecksManager | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | // Subcommand used to list other stats. | ||
45 | public const string ListSubCommand = "list"; | ||
46 | |||
47 | // All subcommands | ||
48 | public static HashSet<string> SubCommands = new HashSet<string> { ListSubCommand }; | ||
49 | |||
50 | /// <summary> | ||
51 | /// Checks categorized by category/container/shortname | ||
52 | /// </summary> | ||
53 | /// <remarks> | ||
54 | /// Do not add or remove directly from this dictionary. | ||
55 | /// </remarks> | ||
56 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Check>>> RegisteredChecks | ||
57 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Check>>>(); | ||
58 | |||
59 | public static void RegisterConsoleCommands(ICommandConsole console) | ||
60 | { | ||
61 | console.Commands.AddCommand( | ||
62 | "General", | ||
63 | false, | ||
64 | "show checks", | ||
65 | "show checks", | ||
66 | "Show checks configured for this server", | ||
67 | "If no argument is specified then info on all checks will be shown.\n" | ||
68 | + "'list' argument will show check categories.\n" | ||
69 | + "THIS FACILITY IS EXPERIMENTAL", | ||
70 | HandleShowchecksCommand); | ||
71 | } | ||
72 | |||
73 | public static void HandleShowchecksCommand(string module, string[] cmd) | ||
74 | { | ||
75 | ICommandConsole con = MainConsole.Instance; | ||
76 | |||
77 | if (cmd.Length > 2) | ||
78 | { | ||
79 | foreach (string name in cmd.Skip(2)) | ||
80 | { | ||
81 | string[] components = name.Split('.'); | ||
82 | |||
83 | string categoryName = components[0]; | ||
84 | // string containerName = components.Length > 1 ? components[1] : null; | ||
85 | |||
86 | if (categoryName == ListSubCommand) | ||
87 | { | ||
88 | con.Output("check categories available are:"); | ||
89 | |||
90 | foreach (string category in RegisteredChecks.Keys) | ||
91 | con.OutputFormat(" {0}", category); | ||
92 | } | ||
93 | // else | ||
94 | // { | ||
95 | // SortedDictionary<string, SortedDictionary<string, Check>> category; | ||
96 | // if (!Registeredchecks.TryGetValue(categoryName, out category)) | ||
97 | // { | ||
98 | // con.OutputFormat("No such category as {0}", categoryName); | ||
99 | // } | ||
100 | // else | ||
101 | // { | ||
102 | // if (String.IsNullOrEmpty(containerName)) | ||
103 | // { | ||
104 | // OutputConfiguredToConsole(con, category); | ||
105 | // } | ||
106 | // else | ||
107 | // { | ||
108 | // SortedDictionary<string, Check> container; | ||
109 | // if (category.TryGetValue(containerName, out container)) | ||
110 | // { | ||
111 | // OutputContainerChecksToConsole(con, container); | ||
112 | // } | ||
113 | // else | ||
114 | // { | ||
115 | // con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | ||
116 | // } | ||
117 | // } | ||
118 | // } | ||
119 | // } | ||
120 | } | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | OutputAllChecksToConsole(con); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// Registers a statistic. | ||
130 | /// </summary> | ||
131 | /// <param name='stat'></param> | ||
132 | /// <returns></returns> | ||
133 | public static bool RegisterCheck(Check check) | ||
134 | { | ||
135 | SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; | ||
136 | SortedDictionary<string, Check> container = null, newContainer; | ||
137 | |||
138 | lock (RegisteredChecks) | ||
139 | { | ||
140 | // Check name is not unique across category/container/shortname key. | ||
141 | // XXX: For now just return false. This is to avoid problems in regression tests where all tests | ||
142 | // in a class are run in the same instance of the VM. | ||
143 | if (TryGetCheckParents(check, out category, out container)) | ||
144 | return false; | ||
145 | |||
146 | // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. | ||
147 | // This means that we don't need to lock or copy them on iteration, which will be a much more | ||
148 | // common operation after startup. | ||
149 | if (container != null) | ||
150 | newContainer = new SortedDictionary<string, Check>(container); | ||
151 | else | ||
152 | newContainer = new SortedDictionary<string, Check>(); | ||
153 | |||
154 | if (category != null) | ||
155 | newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); | ||
156 | else | ||
157 | newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(); | ||
158 | |||
159 | newContainer[check.ShortName] = check; | ||
160 | newCategory[check.Container] = newContainer; | ||
161 | RegisteredChecks[check.Category] = newCategory; | ||
162 | } | ||
163 | |||
164 | return true; | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// Deregister an check | ||
169 | /// </summary>> | ||
170 | /// <param name='stat'></param> | ||
171 | /// <returns></returns> | ||
172 | public static bool DeregisterCheck(Check check) | ||
173 | { | ||
174 | SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; | ||
175 | SortedDictionary<string, Check> container = null, newContainer; | ||
176 | |||
177 | lock (RegisteredChecks) | ||
178 | { | ||
179 | if (!TryGetCheckParents(check, out category, out container)) | ||
180 | return false; | ||
181 | |||
182 | newContainer = new SortedDictionary<string, Check>(container); | ||
183 | newContainer.Remove(check.ShortName); | ||
184 | |||
185 | newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); | ||
186 | newCategory.Remove(check.Container); | ||
187 | |||
188 | newCategory[check.Container] = newContainer; | ||
189 | RegisteredChecks[check.Category] = newCategory; | ||
190 | |||
191 | return true; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | public static bool TryGetCheckParents( | ||
196 | Check check, | ||
197 | out SortedDictionary<string, SortedDictionary<string, Check>> category, | ||
198 | out SortedDictionary<string, Check> container) | ||
199 | { | ||
200 | category = null; | ||
201 | container = null; | ||
202 | |||
203 | lock (RegisteredChecks) | ||
204 | { | ||
205 | if (RegisteredChecks.TryGetValue(check.Category, out category)) | ||
206 | { | ||
207 | if (category.TryGetValue(check.Container, out container)) | ||
208 | { | ||
209 | if (container.ContainsKey(check.ShortName)) | ||
210 | return true; | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | |||
215 | return false; | ||
216 | } | ||
217 | |||
218 | public static void CheckChecks() | ||
219 | { | ||
220 | lock (RegisteredChecks) | ||
221 | { | ||
222 | foreach (SortedDictionary<string, SortedDictionary<string, Check>> category in RegisteredChecks.Values) | ||
223 | { | ||
224 | foreach (SortedDictionary<string, Check> container in category.Values) | ||
225 | { | ||
226 | foreach (Check check in container.Values) | ||
227 | { | ||
228 | if (!check.CheckIt()) | ||
229 | m_log.WarnFormat( | ||
230 | "[CHECKS MANAGER]: Check {0}.{1}.{2} failed with message {3}", check.Category, check.Container, check.ShortName, check.LastFailureMessage); | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static void OutputAllChecksToConsole(ICommandConsole con) | ||
238 | { | ||
239 | foreach (var category in RegisteredChecks.Values) | ||
240 | { | ||
241 | OutputCategoryChecksToConsole(con, category); | ||
242 | } | ||
243 | } | ||
244 | |||
245 | private static void OutputCategoryChecksToConsole( | ||
246 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Check>> category) | ||
247 | { | ||
248 | foreach (var container in category.Values) | ||
249 | { | ||
250 | OutputContainerChecksToConsole(con, container); | ||
251 | } | ||
252 | } | ||
253 | |||
254 | private static void OutputContainerChecksToConsole(ICommandConsole con, SortedDictionary<string, Check> container) | ||
255 | { | ||
256 | foreach (Check check in container.Values) | ||
257 | { | ||
258 | con.Output(check.ToConsoleString()); | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Monitoring/StatsLogger.cs b/OpenSim/Framework/Monitoring/StatsLogger.cs new file mode 100644 index 0000000..fa2e1b6 --- /dev/null +++ b/OpenSim/Framework/Monitoring/StatsLogger.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Timers; | ||
31 | using log4net; | ||
32 | |||
33 | namespace OpenSim.Framework.Monitoring | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Provides a means to continuously log stats for debugging purposes. | ||
37 | /// </summary> | ||
38 | public static class StatsLogger | ||
39 | { | ||
40 | private static readonly ILog m_statsLog = LogManager.GetLogger("special.StatsLogger"); | ||
41 | |||
42 | private static Timer m_loggingTimer; | ||
43 | private static int m_statsLogIntervalMs = 5000; | ||
44 | |||
45 | public static void RegisterConsoleCommands(ICommandConsole console) | ||
46 | { | ||
47 | console.Commands.AddCommand( | ||
48 | "Debug", | ||
49 | false, | ||
50 | "debug stats record", | ||
51 | "debug stats record start|stop", | ||
52 | "Control whether stats are being regularly recorded to a separate file.", | ||
53 | "For debug purposes. Experimental.", | ||
54 | HandleStatsRecordCommand); | ||
55 | } | ||
56 | |||
57 | public static void HandleStatsRecordCommand(string module, string[] cmd) | ||
58 | { | ||
59 | ICommandConsole con = MainConsole.Instance; | ||
60 | |||
61 | if (cmd.Length != 4) | ||
62 | { | ||
63 | con.Output("Usage: debug stats record start|stop"); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | if (cmd[3] == "start") | ||
68 | { | ||
69 | Start(); | ||
70 | con.OutputFormat("Now recording all stats very {0}ms to file", m_statsLogIntervalMs); | ||
71 | } | ||
72 | else if (cmd[3] == "stop") | ||
73 | { | ||
74 | Stop(); | ||
75 | con.Output("Stopped recording stats to file."); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public static void Start() | ||
80 | { | ||
81 | if (m_loggingTimer != null) | ||
82 | Stop(); | ||
83 | |||
84 | m_loggingTimer = new Timer(m_statsLogIntervalMs); | ||
85 | m_loggingTimer.AutoReset = false; | ||
86 | m_loggingTimer.Elapsed += Log; | ||
87 | m_loggingTimer.Start(); | ||
88 | } | ||
89 | |||
90 | public static void Stop() | ||
91 | { | ||
92 | if (m_loggingTimer != null) | ||
93 | { | ||
94 | m_loggingTimer.Stop(); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | private static void Log(object sender, ElapsedEventArgs e) | ||
99 | { | ||
100 | m_statsLog.InfoFormat("*** STATS REPORT AT {0} ***", DateTime.Now); | ||
101 | |||
102 | foreach (string report in StatsManager.GetAllStatsReports()) | ||
103 | m_statsLog.Info(report); | ||
104 | |||
105 | m_loggingTimer.Start(); | ||
106 | } | ||
107 | } | ||
108 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index e6a2304..c8e838c 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -35,9 +35,9 @@ using OpenMetaverse.StructuredData; | |||
35 | namespace OpenSim.Framework.Monitoring | 35 | namespace OpenSim.Framework.Monitoring |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Singleton used to provide access to statistics reporters | 38 | /// Static class used to register/deregister/fetch statistics |
39 | /// </summary> | 39 | /// </summary> |
40 | public class StatsManager | 40 | public static class StatsManager |
41 | { | 41 | { |
42 | // Subcommand used to list other stats. | 42 | // Subcommand used to list other stats. |
43 | public const string AllSubCommand = "all"; | 43 | public const string AllSubCommand = "all"; |
@@ -81,6 +81,8 @@ namespace OpenSim.Framework.Monitoring | |||
81 | + "More than one name can be given separated by spaces.\n" | 81 | + "More than one name can be given separated by spaces.\n" |
82 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", | 82 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", |
83 | HandleShowStatsCommand); | 83 | HandleShowStatsCommand); |
84 | |||
85 | StatsLogger.RegisterConsoleCommands(console); | ||
84 | } | 86 | } |
85 | 87 | ||
86 | public static void HandleShowStatsCommand(string module, string[] cmd) | 88 | public static void HandleShowStatsCommand(string module, string[] cmd) |
@@ -145,29 +147,55 @@ namespace OpenSim.Framework.Monitoring | |||
145 | } | 147 | } |
146 | } | 148 | } |
147 | 149 | ||
148 | private static void OutputAllStatsToConsole(ICommandConsole con) | 150 | public static List<string> GetAllStatsReports() |
149 | { | 151 | { |
152 | List<string> reports = new List<string>(); | ||
153 | |||
150 | foreach (var category in RegisteredStats.Values) | 154 | foreach (var category in RegisteredStats.Values) |
151 | { | 155 | reports.AddRange(GetCategoryStatsReports(category)); |
152 | OutputCategoryStatsToConsole(con, category); | 156 | |
153 | } | 157 | return reports; |
158 | } | ||
159 | |||
160 | private static void OutputAllStatsToConsole(ICommandConsole con) | ||
161 | { | ||
162 | foreach (string report in GetAllStatsReports()) | ||
163 | con.Output(report); | ||
164 | } | ||
165 | |||
166 | private static List<string> GetCategoryStatsReports( | ||
167 | SortedDictionary<string, SortedDictionary<string, Stat>> category) | ||
168 | { | ||
169 | List<string> reports = new List<string>(); | ||
170 | |||
171 | foreach (var container in category.Values) | ||
172 | reports.AddRange(GetContainerStatsReports(container)); | ||
173 | |||
174 | return reports; | ||
154 | } | 175 | } |
155 | 176 | ||
156 | private static void OutputCategoryStatsToConsole( | 177 | private static void OutputCategoryStatsToConsole( |
157 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) | 178 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) |
158 | { | 179 | { |
159 | foreach (var container in category.Values) | 180 | foreach (string report in GetCategoryStatsReports(category)) |
160 | { | 181 | con.Output(report); |
161 | OutputContainerStatsToConsole(con, container); | ||
162 | } | ||
163 | } | 182 | } |
164 | 183 | ||
165 | private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) | 184 | private static List<string> GetContainerStatsReports(SortedDictionary<string, Stat> container) |
166 | { | 185 | { |
186 | List<string> reports = new List<string>(); | ||
187 | |||
167 | foreach (Stat stat in container.Values) | 188 | foreach (Stat stat in container.Values) |
168 | { | 189 | reports.Add(stat.ToConsoleString()); |
169 | con.Output(stat.ToConsoleString()); | 190 | |
170 | } | 191 | return reports; |
192 | } | ||
193 | |||
194 | private static void OutputContainerStatsToConsole( | ||
195 | ICommandConsole con, SortedDictionary<string, Stat> container) | ||
196 | { | ||
197 | foreach (string report in GetContainerStatsReports(container)) | ||
198 | con.Output(report); | ||
171 | } | 199 | } |
172 | 200 | ||
173 | // Creates an OSDMap of the format: | 201 | // Creates an OSDMap of the format: |
@@ -257,7 +285,7 @@ namespace OpenSim.Framework.Monitoring | |||
257 | // } | 285 | // } |
258 | 286 | ||
259 | /// <summary> | 287 | /// <summary> |
260 | /// Registers a statistic. | 288 | /// Register a statistic. |
261 | /// </summary> | 289 | /// </summary> |
262 | /// <param name='stat'></param> | 290 | /// <param name='stat'></param> |
263 | /// <returns></returns> | 291 | /// <returns></returns> |
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 69d2db5..32724ec 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -380,6 +380,7 @@ namespace OpenSim.Framework.Monitoring | |||
380 | if (MemoryWatchdog.Enabled) | 380 | if (MemoryWatchdog.Enabled) |
381 | MemoryWatchdog.Update(); | 381 | MemoryWatchdog.Update(); |
382 | 382 | ||
383 | ChecksManager.CheckChecks(); | ||
383 | StatsManager.RecordStats(); | 384 | StatsManager.RecordStats(); |
384 | 385 | ||
385 | m_watchdogTimer.Start(); | 386 | m_watchdogTimer.Start(); |